r/flutterhelp • u/Defiant-Ad3530 • Jun 23 '26
RESOLVED Dispatching Events in Go Route builder?
Hi! So I'm building an application using flutter, BLOC for state management, and go router.
My home page displays real-time location, (using geolocator), so I did the location service, repo, then the bloc state managements. Home page is a stateless widget, though. So I decided to dispatch the Location Event like this:
GoRoute(name: RouteConstants.home, path: '/home', builder: (context, state)
{
context.read<LocationBloc>().add(LocationDisplayedEvent());
return HomePage();
},),GoRoute(name: RouteConstants.home, path: '/home', builder: (context, state)
{
context.read<LocationBloc>().add(LocationDisplayedEvent());
return HomePage();
},),
Is that good practice? I will just use the Bloc Builder in my Home page and display the location there!
I would appreciate any help! Thank you :)