Commit 5c23b9c7 by Salih Agić Committed by GitHub

Added new option for ToastGravity called SNACKBAR. (#227)

* Added new option for ToastGravity called SNACKBAR which renders toast message much like a SnackBar widget does

* minor fix
parent 0dac6831
...@@ -5,7 +5,7 @@ import 'package:flutter/services.dart'; ...@@ -5,7 +5,7 @@ import 'package:flutter/services.dart';
enum Toast { LENGTH_SHORT, LENGTH_LONG } enum Toast { LENGTH_SHORT, LENGTH_LONG }
enum ToastGravity { TOP, BOTTOM, CENTER, TOP_LEFT, TOP_RIGHT, BOTTOM_LEFT, BOTTOM_RIGHT, CENTER_LEFT, CENTER_RIGHT } enum ToastGravity { TOP, BOTTOM, CENTER, TOP_LEFT, TOP_RIGHT, BOTTOM_LEFT, BOTTOM_RIGHT, CENTER_LEFT, CENTER_RIGHT, SNACKBAR }
class Fluttertoast { class Fluttertoast {
static const MethodChannel _channel = const MethodChannel('PonnamKarthik/fluttertoast'); static const MethodChannel _channel = const MethodChannel('PonnamKarthik/fluttertoast');
...@@ -15,8 +15,8 @@ class Fluttertoast { ...@@ -15,8 +15,8 @@ class Fluttertoast {
return res; return res;
} }
static Future<bool> showToast( static Future<bool> showToast({
{@required String msg, @required String msg,
Toast toastLength, Toast toastLength,
int timeInSecForIosWeb = 1, int timeInSecForIosWeb = 1,
double fontSize, double fontSize,
...@@ -25,7 +25,7 @@ class Fluttertoast { ...@@ -25,7 +25,7 @@ class Fluttertoast {
Color textColor, Color textColor,
bool webShowClose = false, bool webShowClose = false,
webBgColor: "linear-gradient(to right, #00b09b, #96c93d)", webBgColor: "linear-gradient(to right, #00b09b, #96c93d)",
webPosition: "right" webPosition: "right",
// Function(bool) didTap, // Function(bool) didTap,
}) async { }) async {
// this.didTap = didTap; // this.didTap = didTap;
...@@ -157,6 +157,9 @@ class FToast { ...@@ -157,6 +157,9 @@ class FToast {
case ToastGravity.BOTTOM_RIGHT: case ToastGravity.BOTTOM_RIGHT:
return Positioned(bottom: 50.0, right: 24.0, child: newChild); return Positioned(bottom: 50.0, right: 24.0, child: newChild);
break; break;
case ToastGravity.SNACKBAR:
return Positioned(bottom: MediaQuery.of(context).viewInsets.bottom, left: 0, right: 0, child: newChild);
break;
case ToastGravity.BOTTOM: case ToastGravity.BOTTOM:
default: default:
return Positioned(bottom: 50.0, left: 24.0, right: 24.0, child: newChild); return Positioned(bottom: 50.0, left: 24.0, right: 24.0, child: newChild);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment