Приложение работает без сбоев. Но ошибка отображается на консоли.
Получатель 'length' был вызван на нуль. Получатель: null Пробный вызов: длина Созданный пользователем предок вызывающего ошибки виджета был:
StreamProvider> file: ///Users/Documents/flutter_job_manager/lib/components/router.dart: 23: 24
Я использую Firebase Cloud Storage с провайдером
Ошибка здесь: (на моем generateRoute)
case AddCategory.route:
return MaterialPageRoute(
builder: (_) => StreamProvider<List<CategoryModel>>.value(
value: DatabaseService().streamCategories(),
child: AddCategory()
)
);
просто чтобы знать: streamCategories
в DatabaseService ()
Stream<List<CategoryModel>> streamCategories() {
var ref = _db.collection('categories');
return ref.snapshots().map((list) =>
list.documents.map((doc) => CategoryModel.fromFirestore(doc)).toList());
}
AddCategory
в StatelessWidget
StreamProvider<List<CategoryModel>>.value(
value: db.streamCategories(),
child:ListView.builder(
itemCount: category.length,
itemBuilder: (BuildContext context, int index) {
return ListTile(
title: Text(
category[index].categoryName,
),
);
}),
))