I’m trying to add quick actions to my app which is built using GoRouter and Bloc. My problem is that all the examples are adding the quick action initialization to either the _AppState
or the _HomePageState
.
Adding it to _AppState
doesn’t work because the context there is above the MaterialApp.router
widget that I’d use to actually navigate based on the quick action type.
class _AppState extends State<App> {
@override
void initState() {
super.initState();
const QuickActions quickActions = QuickActions();
quickActions.initialize((type) {
if(type == 'share') context.go('/share'); // The context here has no router information
});
quickActions.setShortcutItems([
const ShortcutItem(type: 'share', localizedTitle: 'Share', icon: 'share'),
]);
}
...
Adding it to a specific page is also problematic because the app will start up a different page if a user is logged in.
Stephanie is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.