Skip to content

Commit c9d47d6

Browse files
committed
sth
1 parent 22de05f commit c9d47d6

File tree

1 file changed

+58
-0
lines changed

1 file changed

+58
-0
lines changed

lib/common/ShowToast.dart

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import 'dart:async';
2+
3+
import 'package:flutter/services.dart';
4+
import 'package:meta/meta.dart';
5+
6+
7+
enum Toast {
8+
LENGTH_SHORT,
9+
LENGTH_LONG
10+
}
11+
12+
enum ToastGravity {
13+
TOP,
14+
BOTTOM,
15+
CENTER
16+
}
17+
18+
19+
class Fluttertoast {
20+
21+
static const MethodChannel _channel =
22+
const MethodChannel('PonnamKarthik/fluttertoast');
23+
24+
static Future<String> showToast ({
25+
@required String msg,
26+
Toast toastLength,
27+
int timeInSecForIos = 1,
28+
ToastGravity gravity,
29+
String bgcolor = "null",
30+
String textcolor = "null"
31+
}) async {
32+
String toast = "short";
33+
if(toastLength == Toast.LENGTH_LONG) {
34+
toast = "long";
35+
}
36+
37+
String gravityToast = "bottom";
38+
if(gravity == ToastGravity.TOP) {
39+
gravityToast = "top";
40+
} else if(gravity == ToastGravity.CENTER) {
41+
gravityToast = "center";
42+
} else {
43+
gravityToast = "bottom";
44+
}
45+
46+
final Map<String, dynamic> params = <String, dynamic> {
47+
'msg': msg,
48+
'length': toast,
49+
'time': timeInSecForIos,
50+
'gravity': gravityToast,
51+
'bgcolor': bgcolor,
52+
'textcolor': textcolor
53+
};
54+
String res = await _channel.invokeMethod('showToast', params);
55+
return res;
56+
}
57+
58+
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy