Skip to content

Instantly share code, notes, and snippets.

@joramkimata
Created April 4, 2020 06:14
Show Gist options
  • Save joramkimata/1504e05b975ab5c653f8cabbccc9a461 to your computer and use it in GitHub Desktop.
Save joramkimata/1504e05b975ab5c653f8cabbccc9a461 to your computer and use it in GitHub Desktop.
Flutter Toast
import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart';
void main() => runApp(MyApp());
class MyApp extends StatefulWidget {
@override
State<StatefulWidget> createState() {
return _MyApp();
}
}
class _MyApp extends State<MyApp> {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(title: Text("ToastApp")),
body: Container(
child: Center(
child: FlatButton(
color: Colors.amber,
onPressed: () {
// Show Toast here
Fluttertoast.showToast(
msg: "This is Colored Toast with android duration of 5 Sec",
toastLength: Toast.LENGTH_SHORT,
backgroundColor: Colors.green,
textColor: Colors.white);
},
child: Text("Show Toast!"),
),
),
),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment