-
-
Save Nikhil725051/da37b069ba2d8baf94f1562749d0e94c 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
class SnackBarRoute extends StatelessWidget { | |
const SnackBarRoute({Key? key}) : super(key: key); | |
@override | |
Widget build(BuildContext context) { | |
return Center( | |
child: ElevatedButton( | |
onPressed: () { | |
//Create the SnackBar | |
final snackBar = SnackBar( | |
content: const Text('Hi there! I am a snackbar.'), | |
action: SnackBarAction( | |
label: 'Undo', | |
onPressed: () { | |
// Place the code to undo the change. | |
}, | |
), | |
); | |
// Use ScaffoldMessenger to show the SnackBar. | |
ScaffoldMessenger.of(context).showSnackBar(snackBar); | |
}, | |
child: const Text('Show SnackBar'), | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment