display data stored on sqfliter in flutter

Asked

Viewed 11 times

0

Personal I am trying to display data that I take from sqlfliter and display in a listview but always gives error:

[ERROR:flutter/lib/ui/ui_dart_state.cc(199)] Unhandled Exception: type 'int' is not a subtype of type 'String

I think I’m not passing the data correctly, this is my method code that I’m taking the data it is in the Previous

Future<List<Modulo>> getLista() async {
    var moduloMapList = await getMapList();
    int count = moduloMapList.length;
    print(moduloMapList.toString());
    // ignore: deprecated_member_use
    List<Modulo> lista = List<Modulo>();
    for (int i = 0; i < count; i++) {
        lista.add(Modulo.fromMapObject(moduloMapList[i]));
    }
    return lista;
}

And I’m getting on the list like this:

Widget build(BuildContext context) {
    final ModuloProvider modulos = Provider.of(context);
    return Scaffold(
        appBar: AppBar(
            title:
                Text('Modulos', style: TextStyle(fontWeight: FontWeight.bold)),
            actions: <Widget>[
              IconButton(
                icon: Icon(Icons.add),
                onPressed: () {
                  Navigator.of(context).pushNamed(AppRouters.CREATEMODULO);
                },
              ),
            ]),
        body: FutureBuilder(
            future: modulos.getLista(),
            // ignore: missing_return
            builder: (context, AsyncSnapshot snapshot) {
              if (!snapshot.hasData) {
                print(modulos.getLista());
                return Center(child: CircularProgressIndicator());
              } else {
                ListView.builder(
                    itemCount: snapshot.data.length,
                    itemBuilder: (ctx, i) => ModuloTile(snapshot.data[i]));
              }
            }));
  }

In the ModuloTile I have a Dynamic data and display this way

title: Text(widget.data.nome,

How do I do it right?

  • Please clarify your problem or provide additional details in order to highlight exactly what you need. The way it’s written these days it’s hard to tell exactly what you’re asking.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.