【发布时间】:2019-04-16 09:48:49
【问题描述】:
【问题讨论】:
标签: dart flutter flutter-layout
【问题讨论】:
标签: dart flutter flutter-layout
好像
Widget createListView(BuildContext context, AsyncSnapshot snapshot) {
// ...
children: List.generate(values.length, (index) {
长度错误。
请注意,您的 build 方法可以随时被调用(当您导航时它肯定会被调用)。
所以你的
getRegister1()
被多次调用,因此您需要进一步研究此方法,因为未提供 HelperDatabase1 背后的代码。
(也许这是你的问题...
var catLocal = (await HelperDatabase1().displayDefCatRelation())
var defCatLocal = (await HelperDatabase1().display()) +
cat.add(catLocal[i].c); // maybe this actually saves in your db/cache
但我不能确定 )
您应该查看的另一件事是您的 getRegister1() 应该是“以前获得的”。 检查来自flutter docs的这个sniper。
FutureBuilder<String>(
future: _calculation, // a previously-obtained Future<String> or null
builder: (BuildContext context, AsyncSnapshot<String> snapshot) {
switch (snapshot.connectionState) {
case ConnectionState.none:
return Text('Press button to start.');
case ConnectionState.active:
case ConnectionState.waiting:
return Text('Awaiting result...');
case ConnectionState.done:
if (snapshot.hasError)
return Text('Error: ${snapshot.error}');
return Text('Result: ${snapshot.data}');
}
return null; // unreachable
},
)
【讨论】: