am trying to call a Page from a home page navigation drawer, but getting the above error regarding providers where I am passing a bloc to update the page in a stream builder.
Below is the code for calling the page:
Navigator.push(context, PageRoutes(page:
NotificationPage()));And in the build widget I have Scaffold and the body has the below code:
Widget build(BuildContext context) {
final
notificationBloc=Provider.of<NotificationBloc>
(context);
return
Scaffold(
appBar: AppBar(title:Text('Tiles')),
body: Provider<NotificationBloc>(
create: (_)=>NotificationBloc(),
builder:(context,_){
return Column(
children: [
StreamBuilder<List<NotificationModel>>(
stream: notificationBloc.notifications,
builder: (context, snapshot) {
if(snapshot.hasData){
final notifications=snapshot.data;
_fadeInController.forward();
if(notifications.isEmpty){
return Container();
}
return Expanded(
child: AnimatedBuilder(
animation: _fadeInController,
builder: (context, child) {
return Opacity(
opacity: _fadeInController.value,
child: ListView.builder(
padding: const EdgeInsets.all(12),
itemCount: notifications.length,
itemBuilder: (context, index) {
final notification = notifications[index];
return NotificationTile(
notification: notification,
);
},
),
);
},
),
);
}
return Expanded(child: SizedBox());
}
),
// CustomWideFlatButton(
//onPressed: navigateToNotificationCreation,
//backgroundColor: Colors.blue.shade300,
//foregroundColor: Colors.blue.shade900,
//isRoundedAtBottom: false,
// )
],
);
}
But every time I click on the drawer icon to invoke the page, get the error in subject. Can you please help, I have tried multiple changes and tried to research it online but could not get any solution
--
You received this message because you are subscribed to the Google Groups "Flutter Development (flutter-dev)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flutter-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/flutter-dev/78c24afb-c802-4b0f-a475-37e8faf359c4o%40googlegroups.com.