xxxxxxxxxx
# add this line to your dependencies
# put the current version
fluttertoast: ^8.0.9
# import file
import 'package:fluttertoast/fluttertoast.dart';
# Usage
Fluttertoast.showToast(
msg: "This is Center Short Toast",
toastLength: Toast.LENGTH_SHORT,
gravity: ToastGravity.CENTER,
timeInSecForIosWeb: 1,
backgroundColor: Colors.red,
textColor: Colors.white,
fontSize: 16.0
);
xxxxxxxxxx
# add this line to your dependencies
fluttertoast: ^7.1.1
Fluttertoast.showToast(
msg: "This is Center Short Toast",
toastLength: Toast.LENGTH_SHORT,
gravity: ToastGravity.CENTER,
timeInSecForIosWeb: 1,
backgroundColor: Colors.red,
textColor: Colors.white,
fontSize: 16.0
);
xxxxxxxxxx
Scaffold.of(context).showSnackBar(SnackBar(
content: Text("Sending Message"),
));
xxxxxxxxxx
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
content: Text("Sending Message"),
));
// Learn Flutter inside VS Code at sideguide.dev/courses/flutter?ref=grepper
xxxxxxxxxx
Toast.show("Toast plugin app", duration: Toast.lengthShort, gravity: Toast.bottom);
xxxxxxxxxx
Fluttertoast.showToast(
msg: "This is Center Short Toast",
toastLength: Toast.LENGTH_SHORT,
gravity: ToastGravity.CENTER,
timeInSecForIosWeb: 1,
backgroundColor: Colors.red,
textColor: Colors.white,
fontSize: 16.0
);
xxxxxxxxxx
#add f(luttertoast:<latest-version>) dependency to your pubspec
#if its giving no platform set for toast then simple just unistall
#app from phone and re-run
Future<bool?> showToastMessage(message, color)
{
return Fluttertoast.showToast(
msg: message,
toastLength: Toast.LENGTH_SHORT,
gravity: ToastGravity.CENTER,
timeInSecForIosWeb: 1,
backgroundColor: color,
textColor: Colors.white,
fontSize: 16.0
);
}
xxxxxxxxxx
import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Toast Example',
home: Scaffold(
appBar: AppBar(
title: Text('Flutter Toast Example'),
),
body: Center(
child: RaisedButton(
onPressed: () {
Fluttertoast.showToast(
msg: 'This is a toast message',
toastLength: Toast.LENGTH_SHORT,
gravity: ToastGravity.CENTER,
timeInSecForIosWeb: 1,
backgroundColor: Colors.grey[700],
textColor: Colors.white,
);
},
child: Text('Show Toast'),
),
),
),
);
}
}