Last active
September 21, 2022 11:51
-
-
Save krishnakumarcn/37b6db0f1a246bed13aaf526ac8ffff7 to your computer and use it in GitHub Desktop.
Krishnakumar's DartPad
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
import 'package:flutter/material.dart'; | |
void main() { | |
runApp(MyApp()); | |
} | |
class MyApp extends StatefulWidget { | |
const MyApp({Key? key}) : super(key: key); | |
@override | |
MyAppState createState() => MyAppState(); | |
} | |
class MyAppState extends State<MyApp> { | |
String SnackBarText = "Yaay, a Snackbar!!"; | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
title: 'A Snackbar Sample', | |
home: Scaffold( | |
body: Center( | |
child: Row( | |
children: [ | |
getSnackBarButton(), | |
], | |
), | |
), | |
), | |
); | |
} | |
getSnackBarButton() { | |
return TextButton( | |
child: Text("Show Snackbar"), | |
onPressed: () { | |
ScaffoldMessenger.of(context).showSnackBar( | |
SnackBar(content: Text(SnackBarText)), | |
); | |
}, | |
); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment