-
-
Save harshsoni1110/3f4d781b7850291dd711cd52c8875c71 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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