Advertisement
Guest User

Untitled

a guest
Oct 20th, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. class MyApp extends StatelessWidget {
  2. final scaffoldKey = GlobalKey<ScaffoldState>();
  3.  
  4. @override
  5. Widget build(BuildContext context) {
  6. return MaterialApp(
  7. title: 'AppBar Widget',
  8. home: Scaffold(
  9. key: scaffoldKey,
  10. appBar: AppBar(
  11. leading: Icon(Icons.menu),
  12. title: const Text('AppBar Widget'),
  13. actions: [
  14. IconButton(
  15. icon: Icon(Icons.search),
  16. onPressed: () {
  17. scaffoldKey.currentState.hideCurrentSnackBar();
  18. scaffoldKey.currentState.showSnackBar(
  19. const SnackBar(content: Text('Pressed search icon')),
  20. );
  21. },
  22. ),
  23. ],
  24. ),
  25. ),
  26. );
  27. }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement