Last updated:
0 purchases
realank flutter bloc
realank_flutter_bloc #
a bloc wrapper package
Introduce #
relank_flutter_bloc contains 3 classes:
RLKBaseBLoC:a BLoC data that can store any type of data
RLKBLoCProvider:the root widget of whose widgets need to use RLKBaseBLoC's data
RLKBLoCBuilder:a RLKBaseBLoC getter
example #
1. extends RLKBaseBLoC to add custom operation (optional)
class CountBLoC extends RLKBaseBLoC<int> {
CountBLoC(int data) : super(data);
increment() {
changeData(data + 1);
}
}
copied to clipboard
2. wrap root widget with RLKBLoCProvider, and pass a RLKBaseBLoC instance
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return RLKBLoCProvider(
bloc: CountBLoC(0),
child: MaterialApp(
theme: ThemeData.light(),
home: TopPage(),
),
);
}
}
copied to clipboard
3. use RLKBLoCBuilder to get RLKBaseBLoC and it's data anywhere
RLKBLoCBuilder(builder: (BuildContext context, int data, RLKBaseBLoC bloc) {
return Text(
'You hit me: $data times',
style: Theme.of(context).textTheme.display1,
);
})
copied to clipboard
Getting Started #
For help getting started with Flutter, view our online documentation.
For help on editing package code, view the documentation.
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.