Skip to content

Instantly share code, notes, and snippets.

@krishnakumarcn
Last active September 21, 2022 11:51
Show Gist options
  • Save krishnakumarcn/37b6db0f1a246bed13aaf526ac8ffff7 to your computer and use it in GitHub Desktop.
Save krishnakumarcn/37b6db0f1a246bed13aaf526ac8ffff7 to your computer and use it in GitHub Desktop.
Krishnakumar's DartPad
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