Skip to content

Instantly share code, notes, and snippets.

@harshsoni1110
Last active June 17, 2020 14:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save harshsoni1110/3f4d781b7850291dd711cd52c8875c71 to your computer and use it in GitHub Desktop.
Save harshsoni1110/3f4d781b7850291dd711cd52c8875c71 to your computer and use it in GitHub Desktop.
void main() async {
WidgetsFlutterBinding.ensureInitialized();
NotificationBloc notificationBloc = new NotificationBloc();
await notificationBloc.initialize();
runApp(
MultiBlocProvider(providers: [
BlocProvider.value(value: notificationBloc),
], child: MyApp()),
);
}
class MyApp extends StatefulWidget {
const MyApp({Key key}) : super(key: key);
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
@override
void didChangeDependencies() {
super.didChangeDependencies();
BlocProvider.of<NotificationBloc>(context)
.checkForLaunchedNotifications();
}
@override
Widget build(BuildContext context) {
return BlocListener<NotificationBloc, NotificationState>(
listener: (context, state) {
if (state is IndexedNotification) {
UiUtilities.showSnack(
context, "Here you can navigate to index ${state.index}");
} else if (state is NotificationErrorState) {
UiUtilities.showSnack(context, state.error);
}
},
child: MaterialApp(
theme: bindTheme,
onGenerateRoute: router.generateRoute,
initialRoute: RouterConstants.myGuidRoute,
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment