Created the home bloc provider
This commit is contained in:
parent
4d6fb3d04e
commit
b9f0831c27
2 changed files with 21 additions and 0 deletions
21
lib/src/blocs/home_provider.dart
Normal file
21
lib/src/blocs/home_provider.dart
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
import './home_bloc.dart';
|
||||
export './home_bloc.dart';
|
||||
|
||||
class HomeProvider extends InheritedWidget {
|
||||
final HomeBloc bloc;
|
||||
|
||||
HomeProvider({
|
||||
Key key,
|
||||
Widget child,
|
||||
}) : bloc = HomeBloc(),
|
||||
super(key: key, child: child);
|
||||
|
||||
bool updateShouldNotify(InheritedWidget oldWidget) => true;
|
||||
|
||||
static HomeBloc of(BuildContext context) {
|
||||
return (context.inheritFromWidgetOfExactType(HomeProvider) as HomeProvider)
|
||||
.bloc;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue