Add quick_actions: ^0.3.0+2 package in your .yaml file
import the quick_actions package and create a new instance of the QuickActions in the Manager's state class.
import 'package:quick_actions/quick_actions.dart'; class _QuickActionsManagerState extends State { final QuickActions quickActions = QuickActions(); }
Setup Quick Actions.
void _setupQuickActions() { quickActions.setShortcutItems([ ShortcutItem( type: 'action_main', localizedTitle: 'Main view', icon: icons.menu), ShortcutItem( type: 'action_help', localizedTitle: 'Help', icon: icons.help) ]); }
Handle Selected Action.
void _handleQuickActions() { quickActions.initialize((shortcutType) { if (shortcutType == 'action_main') { Navigator.push( context, MaterialPageRoute(builder: (context) => Login())); } else if(shortcutType == 'action_help') { print('Show the help dialog!'); } }); }
Use it.
@override void initState() { super.initState(); _setupQuickActions(); _handleQuickActions(); }