I have a class called A which is a Stateless
class and I have a class called B which is a Stateful
class
The build method of A class is as follows
@override
Widget build(BuildContext context) {
return BlocProvider(
bloc: DashboardListBloc(),
child: Scaffold(
body: SingleChildScrollView(
child: Column(
children: <Widget>[
SafeArea(child: _dashboardAppBar(context)),
SizedBox(
height: 10.0,
),
B() // this is class B
],
),
)),
);
I have declared my bloc object in B class
Suppose in body of class A, i wrap SingleChildScrollView
with RefreshIndicator
, so how in its refresh property
i am supposed to call the methods of Bloc class whose reference are defined in class B.
I thought of moving everything to class B and removing class A but
that causes another problem as i have to initialise Bloc
in init method and as init is called before build,
bloc will always result in null as i will be using BlocProvider
InheritedWidget
in build method of class B