Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chapter 6, Flutter type 'List<ShoppingList>' is not a subtype of type 'int' #6

Closed
imamtarique opened this issue Aug 11, 2020 · 1 comment

Comments

@imamtarique
Copy link

Here is my getList function:

Future<List> getLists() async {
final List<Map<String, dynamic>> maps = await db.query('lists');
// ignore: missing_return
return List.generate(maps.length, (i) {
return ShoppingList(
maps[i]['id'],
maps[i]['name'],
maps[i]['priority'],
);
});
}

I am calling it from here
showData() async {
dynamic bb;
await helper.openDb();
shoppingList = await helper.getLists();

setState(() {
shoppingList=shoppingList;
});
}
}

I am getting the error

type 'List' is not a subtype of type 'int'

@simoales
Copy link
Collaborator

Hi @imamtarique ,

How did you declare shoppingList? From the error you mention it seems shoppingList is declared as int, while getLists() returns a Future of type List. So shoppingList should be declared as "List": like

List shoppingList = List();

Hope this helps

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants