小编Oua*_*dia的帖子

小部件内的抖动循环

我是新手,但想知道是否有人可以引导我。

我想通过从json文件中检索的字符串来激怒。我想分别显示每个字母。下面的例子。

输出 完成字:Hi字母pos 0:H字母pos 1:I

到目前为止,我尝试在itemBuilder下添加一个for循环,但无法检索卡内的变量。我尝试在小部件内添加for循环,但不允许我这样做。

任何投入将不胜感激!

import 'dart:convert';

import 'package:flutter/material.dart';


void main() {
  runApp(new MaterialApp(
    home: new MyApp(),
  ));
}

class MyApp extends StatefulWidget {
  @override
  MyAppState createState() => new MyAppState();
}

class MyAppState extends State<MyApp> {
  List data;

  @override
  Widget build(BuildContext context) {
    return new Scaffold(
        appBar: new AppBar(
          title: new Text("Load local JSON file"),
        ),
        body: new Container(
          child: new Center(
            // Use future builder and DefaultAssetBundle to load the local JSON file
            child: new FutureBuilder( …
Run Code Online (Sandbox Code Playgroud)

dart flutter

4
推荐指数
1
解决办法
9977
查看次数

Flutter - 从 firestore 获取数据并将其显示在下拉列表中

我正在尝试从 firestore 获取数据并将其显示在下拉菜单中。我尝试像下面这样声明列表: \xc2\xa0 List Makes = [\'\'] 但我可以 \xe2\x80\x99t 查看数据,直到我单击另一个字段并且下拉列表多次填充。我将它放在一个方法中,因为最终,我想创建第二个下拉列表,其中数据库查询中有一个条件\xe2\x80\x99s。

\n\n

前任。如果选择丰田,则显示该特定品牌的所有型号。

\n\n
new StreamBuilder<QuerySnapshot>(\n      stream: Firestore.instance.collection("makesModels").snapshots(),\n      builder: (context, snapshot) {\n        if (!snapshot.hasData) return new Text("Please wait");\n        return new DropdownButton(\n          items: snapshot.data.documents.map((DocumentSnapshot document) {\n            return DropdownMenuItem(\n                value: document.data["make"],\n                child: new Text(document.data["make"]));\n          }).toList(),\n          value: category,\n          onChanged: (value) {\n            setState(() {\n              category = value;\n            });\n          },\n          hint: new Text("Makes"),\n          style: TextStyle(color: Colors.black),\n        );\n      }),\n      new StreamBuilder<QuerySnapshot>(\n      stream: Firestore.instance.collection("makesModels").where(\'make\', isEqualTo: category).snapshots(),\n      builder: (context, snapshot) {\n\n        if (!snapshot.hasData) return new Text("Please wait");\n        return …
Run Code Online (Sandbox Code Playgroud)

firebase flutter google-cloud-firestore

1
推荐指数
1
解决办法
6309
查看次数

标签 统计

flutter ×2

dart ×1

firebase ×1

google-cloud-firestore ×1