Skip to content

Instantly share code, notes, and snippets.

@mhassanist
Last active February 10, 2019 06:59
Show Gist options
  • Save mhassanist/4c65a25e679bf7ed1a721524a5626288 to your computer and use it in GitHub Desktop.
Save mhassanist/4c65a25e679bf7ed1a721524a5626288 to your computer and use it in GitHub Desktop.
Basic Flutter app with a button that shows Toast without using MaterialApp
import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart';
void main() {
runApp(WidgetsApp(
builder: (context, int) {
return Container(
color: Colors.white,
child:Center(
child: RaisedButton(
onPressed: () {
Fluttertoast.showToast(
msg: "This is Center Short Toast",
toastLength: Toast.LENGTH_SHORT,
gravity: ToastGravity.BOTTOM,
timeInSecForIos: 1,
backgroundColor: Colors.red,
textColor: Colors.white,
fontSize: 16.0
);
},
child: Text(
'Hello, world 2!',
textDirection: TextDirection.ltr,
),
),
));
},
color: Colors.blue,
));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment