Flutter / Dart:将getter'length'调用为null

时间:2020-04-10 09:06:54

标签: flutter dart

I/flutter ( 9255): ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
I/flutter ( 9255): The following NoSuchMethodError was thrown building FutureBuilder<List<Asset>>(dirty, state:
I/flutter ( 9255): _FutureBuilderState<List<Asset>>#734fc):
I/flutter ( 9255): The getter 'length' was called on null.
I/flutter ( 9255): Receiver: null
I/flutter ( 9255): Tried calling: length

---------代码段----------

Future<List<Asset>> getAssets() async {
  var dbClient = await db;
  List<Map> list = await dbClient.rawQuery('SELECT * FROM Assets');
  print("created List Map from DB table Assets");
  //List<Asset> assets = List();
  List assets = [];
  for (int i = 0; i < list.length; i++) {
    assets.add(Asset());
  }
  print(assets.length);
  return assets;
}

1 个答案:

答案 0 :(得分:1)

This site can’t be reached strapi.live-for-good.org refused to connect. Try: Checking the connection Checking the proxy and the firewall ERR_CONNECTION_REFUSED 返回null。

您应该像这样更新代码

This site can’t provide a secure connection
strapi.live-for-good.org sent an invalid response. 
ERR_SSL_PROTOCOL_ERROR