my main.dart file looks like this.
home: MultiBlocProvider(
providers: [
BlocProvider<UserBloc>(
create: (BuildContext context) => UserBloc()..add(GetUser(userId:"5e0b62023b75dd60e22edaad")),
),
BlocProvider<TodoBloc>(
create: (BuildContext context)=> TodoBloc()..add(AddTodoEvent()),)
],
child: FirstScreen(),
),
I want to navigate to the second screen on button press in FirstScreen.
var router = new MaterialPageRoute(
builder: (BuildContext context){
return BlocProvider<UserBloc>(
create: (BuildContext context) => UserBloc(),
child: SecondScreen(),
);
});
Navigator.of(context).push(router);
It works fine,but it will create new UserBloc initial state. What I want is to get the currect state on UserBlog.
I tried this
UserBloc userBloc = BlocProvider.of<UserBloc>(context);
BlocProvider<CounterBloc>(
bloc: userBloc,
child: SecondScreen()
)
bloc gives an error. Is there any way to navigate to the SecondScreen and have the same state.