toast 0.0.6 toast: ^0.0.6 copied to clipboard
A Flutter Toast plugin.
import 'package:flutter/material.dart';
import 'package:toast/toast.dart';
void main() => runApp(MyApp());
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Toast plugin example app'),
),
body: Center(
child: Column(
children: <Widget>[
Padding(
padding: const EdgeInsets.all(10.0),
child: RaisedButton(
child: Text('Show Short Toast'),
onPressed: () => showToast("Show Short Toast")),
),
Padding(
padding: const EdgeInsets.all(10.0),
child: RaisedButton(
child: Text('Show Long Toast'),
onPressed: () => showToast("Show Long Toast", duration: Toast.LENGTH_LONG)),
),
Padding(
padding: const EdgeInsets.all(10.0),
child: RaisedButton(
child: Text('Show Bottom Toast'),
onPressed: () => showToast("Show Bottom Toast", gravity: Toast.BOTTOM)),
),
Padding(
padding: const EdgeInsets.all(10.0),
child: RaisedButton(
child: Text('Show Center Toast'),
onPressed: () => showToast("Show Center Toast", gravity: Toast.CENTER)),
),
Padding(
padding: const EdgeInsets.all(10.0),
child: RaisedButton(
child: Text('Show Top Toast'),
onPressed: () => showToast("Show Top Toast", gravity: Toast.TOP)),
),
],
),
),
),
);
}
void showToast(String msg, {int duration, int gravity}) {
Toast.show(msg, duration: duration, gravity: gravity);
}
}