type 'int' is not subtype of type 'String' on Flutter

醉酒当歌 提交于 2021-01-29 07:16:07

问题


I modified description value to 1 on my database.

List<DataEquipmentReg> values = snapshot.data;


 assetArray.add('${values[i].eq_no.toString()} : ${values[i].description.toString()}');

After edit description value to String, Error is not coming

DataEquipmentReg POJO Class

class DataEquipmentReg {
 final String eq_no;
  final String description;
}

Widget

   Text(assetArray[index].toString(),),

Database in sqlite

  await db.execute("""CREATE TABLE EquipmentRegTable(eq_no STRING, description STRING)""");

回答1:


I solved this problem like this,

in my read data on cache method, I changed this,

  Future<List<DataEquipmentReg>> displayEquipmentReg() async {
    var db = await db1;
    final List<Map<String, dynamic>> maps = await db.query('EquipmentRegTable');

    return List.generate(maps.length, (i) {
      return DataEquipmentReg(
        eq_no: '${maps[i]['eq_no']}',
        description'${ maps[i]['description']}',
      );
    });
  }


来源:https://stackoverflow.com/questions/56375509/type-int-is-not-subtype-of-type-string-on-flutter

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!