The error: NoSuchMethodError: invalid member on null: 'toList comes, but code works when I use the commented provider i.e. final userdetails = Provider.of<List>(context).toList() ?? [];
However, if I use final userdetails = Provider.of<List>(context).toList() ?? []; I get this two errors, and app displays red screen. 1- NoSuchMethodError: invalid member on null: 'toList 2- An exception was throw by _MapStream<QuerySnapshot, List> listened by
import 'package:traveltogether_admin/Admin_Screens/Admin_ManageUsers_Tile.dart';
import 'package:traveltogether_admin/Models/user.dart';
class ManageUsers extends StatelessWidget {
static const id = 'Admin_manage_users';
@override
Widget build(BuildContext context) {
final userdetails = Provider.of<List<MyUserData>>(context).toList() ?? [];
// final userdetails = Provider.of<List<RequestToJoinData>>(context).toList() ?? [];
final user= userdetails;
return ListView.builder(
// shrinkWrap: true,
// physics: NeverScrollableScrollPhysics(),
// primary: false,
itemCount: userdetails.length,
itemBuilder: (context,index)
{
print(userdetails);
return ManageUserTile(user[index]);
});
}
}
Aucun commentaire:
Enregistrer un commentaire