Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
fluttertoast
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
songyanzhi
fluttertoast
Commits
a71ea49b
Commit
a71ea49b
authored
Sep 11, 2020
by
Karthik Ponnam
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
formated
parent
a10da367
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
12 deletions
+35
-12
lib/fluttertoast.dart
+35
-11
lib/fluttertoast_web.dart
+0
-1
No files found.
lib/fluttertoast.dart
View file @
a71ea49b
...
...
@@ -5,10 +5,22 @@ import 'package:flutter/services.dart';
enum
Toast
{
LENGTH_SHORT
,
LENGTH_LONG
}
enum
ToastGravity
{
TOP
,
BOTTOM
,
CENTER
,
TOP_LEFT
,
TOP_RIGHT
,
BOTTOM_LEFT
,
BOTTOM_RIGHT
,
CENTER_LEFT
,
CENTER_RIGHT
,
SNACKBAR
}
enum
ToastGravity
{
TOP
,
BOTTOM
,
CENTER
,
TOP_LEFT
,
TOP_RIGHT
,
BOTTOM_LEFT
,
BOTTOM_RIGHT
,
CENTER_LEFT
,
CENTER_RIGHT
,
SNACKBAR
}
class
Fluttertoast
{
static
const
MethodChannel
_channel
=
const
MethodChannel
(
'PonnamKarthik/fluttertoast'
);
static
const
MethodChannel
_channel
=
const
MethodChannel
(
'PonnamKarthik/fluttertoast'
);
static
Future
<
bool
>
cancel
()
async
{
bool
res
=
await
_channel
.
invokeMethod
(
"cancel"
);
...
...
@@ -43,7 +55,8 @@ class Fluttertoast {
gravityToast
=
"bottom"
;
}
if
(
backgroundColor
==
null
&&
defaultTargetPlatform
==
TargetPlatform
.
iOS
)
{
if
(
backgroundColor
==
null
&&
defaultTargetPlatform
==
TargetPlatform
.
iOS
)
{
backgroundColor
=
Colors
.
black
;
}
if
(
textColor
==
null
&&
defaultTargetPlatform
==
TargetPlatform
.
iOS
)
{
...
...
@@ -67,7 +80,8 @@ class Fluttertoast {
}
}
typedef
PositionedToastBuilder
=
Widget
Function
(
BuildContext
context
,
Widget
child
);
typedef
PositionedToastBuilder
=
Widget
Function
(
BuildContext
context
,
Widget
child
);
class
FToast
{
BuildContext
context
;
...
...
@@ -95,7 +109,8 @@ class FToast {
}
_ToastEntry
_toastEntry
=
_overlayQueue
.
removeAt
(
0
);
_entry
=
_toastEntry
.
entry
;
if
(
context
==
null
)
throw
(
"Error: Context is null, Please call init(context) before showing toast."
);
if
(
context
==
null
)
throw
(
"Error: Context is null, Please call init(context) before showing toast."
);
Overlay
.
of
(
context
).
insert
(
_entry
);
_timer
=
Timer
(
_toastEntry
.
duration
,
()
{
...
...
@@ -131,10 +146,12 @@ class FToast {
toastDuration
??
Duration
(
seconds:
2
),
);
OverlayEntry
newEntry
=
OverlayEntry
(
builder:
(
context
)
{
if
(
positionedToastBuilder
!=
null
)
return
positionedToastBuilder
(
context
,
newChild
);
if
(
positionedToastBuilder
!=
null
)
return
positionedToastBuilder
(
context
,
newChild
);
return
_getPostionWidgetBasedOnGravity
(
newChild
,
gravity
);
});
_overlayQueue
.
add
(
_ToastEntry
(
entry:
newEntry
,
duration:
toastDuration
??
Duration
(
seconds:
2
)));
_overlayQueue
.
add
(
_ToastEntry
(
entry:
newEntry
,
duration:
toastDuration
??
Duration
(
seconds:
2
)));
if
(
_timer
==
null
)
_showOverlay
();
}
...
...
@@ -150,7 +167,8 @@ class FToast {
return
Positioned
(
top:
100.0
,
right:
24.0
,
child:
child
);
break
;
case
ToastGravity
.
CENTER
:
return
Positioned
(
top:
50.0
,
bottom:
50.0
,
left:
24.0
,
right:
24.0
,
child:
child
);
return
Positioned
(
top:
50.0
,
bottom:
50.0
,
left:
24.0
,
right:
24.0
,
child:
child
);
break
;
case
ToastGravity
.
CENTER_LEFT
:
return
Positioned
(
top:
50.0
,
bottom:
50.0
,
left:
24.0
,
child:
child
);
...
...
@@ -165,7 +183,11 @@ class FToast {
return
Positioned
(
bottom:
50.0
,
right:
24.0
,
child:
child
);
break
;
case
ToastGravity
.
SNACKBAR
:
return
Positioned
(
bottom:
MediaQuery
.
of
(
context
).
viewInsets
.
bottom
,
left:
0
,
right:
0
,
child:
child
);
return
Positioned
(
bottom:
MediaQuery
.
of
(
context
).
viewInsets
.
bottom
,
left:
0
,
right:
0
,
child:
child
);
break
;
case
ToastGravity
.
BOTTOM
:
default
:
...
...
@@ -191,7 +213,8 @@ class _ToastStateFul extends StatefulWidget {
ToastStateFulState
createState
()
=>
ToastStateFulState
();
}
class
ToastStateFulState
extends
State
<
_ToastStateFul
>
with
SingleTickerProviderStateMixin
{
class
ToastStateFulState
extends
State
<
_ToastStateFul
>
with
SingleTickerProviderStateMixin
{
showIt
()
{
_animationController
.
forward
();
}
...
...
@@ -212,7 +235,8 @@ class ToastStateFulState extends State<_ToastStateFul> with SingleTickerProvider
vsync:
this
,
duration:
const
Duration
(
milliseconds:
350
),
);
_fadeAnimation
=
CurvedAnimation
(
parent:
_animationController
,
curve:
Curves
.
easeIn
);
_fadeAnimation
=
CurvedAnimation
(
parent:
_animationController
,
curve:
Curves
.
easeIn
);
super
.
initState
();
showIt
();
...
...
lib/fluttertoast_web.dart
View file @
a71ea49b
import
'dart:async'
;
import
'dart:html'
as
html
;
import
'package:flutter/cupertino.dart'
;
import
'package:flutter/services.dart'
;
import
'package:flutter_web_plugins/flutter_web_plugins.dart'
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment