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
a0c1abbe
Commit
a0c1abbe
authored
Apr 14, 2024
by
Karthik Ponnam
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
minor update
parent
f92a6be8
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
12 deletions
+39
-12
example/android/app/build.gradle
+1
-1
lib/fluttertoast.dart
+38
-11
No files found.
example/android/app/build.gradle
View file @
a0c1abbe
...
...
@@ -26,7 +26,7 @@ apply plugin: 'kotlin-android'
apply
from:
"$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android
{
compileSdkVersion
3
1
compileSdkVersion
3
3
ndkVersion
flutter
.
ndkVersion
compileOptions
{
...
...
lib/fluttertoast.dart
View file @
a0c1abbe
...
...
@@ -14,13 +14,26 @@ enum Toast {
/// ToastGravity
/// Used to define the position of the Toast on the screen
enum
ToastGravity
{
TOP
,
BOTTOM
,
CENTER
,
TOP_LEFT
,
TOP_RIGHT
,
BOTTOM_LEFT
,
BOTTOM_RIGHT
,
CENTER_LEFT
,
CENTER_RIGHT
,
SNACKBAR
,
NONE
}
enum
ToastGravity
{
TOP
,
BOTTOM
,
CENTER
,
TOP_LEFT
,
TOP_RIGHT
,
BOTTOM_LEFT
,
BOTTOM_RIGHT
,
CENTER_LEFT
,
CENTER_RIGHT
,
SNACKBAR
,
NONE
}
/// Plugin to show a toast message on screen
/// Only for android, ios and Web platforms
class
Fluttertoast
{
/// [MethodChannel] used to communicate with the platform side.
static
const
MethodChannel
_channel
=
const
MethodChannel
(
'PonnamKarthik/fluttertoast'
);
static
const
MethodChannel
_channel
=
const
MethodChannel
(
'PonnamKarthik/fluttertoast'
);
/// Let say you have an active show
/// Use this method to hide the toast immediately
...
...
@@ -90,7 +103,8 @@ class Fluttertoast {
}
/// Signature for a function to buildCustom Toast
typedef
PositionedToastBuilder
=
Widget
Function
(
BuildContext
context
,
Widget
child
);
typedef
PositionedToastBuilder
=
Widget
Function
(
BuildContext
context
,
Widget
child
);
/// Runs on dart side this has no interaction with the Native Side
/// Works with all platforms just in two lines of code
...
...
@@ -224,7 +238,8 @@ class FToast {
bool
ignorePointer
=
false
,
bool
isDismissable
=
false
,
})
{
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."
);
Widget
newChild
=
_ToastStateFul
(
child
,
toastDuration
,
...
...
@@ -245,10 +260,12 @@ class FToast {
}
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
,
fadeDuration:
fadeDuration
));
_overlayQueue
.
add
(
_ToastEntry
(
entry:
newEntry
,
duration:
toastDuration
,
fadeDuration:
fadeDuration
));
if
(
_timer
==
null
)
_showOverlay
();
}
...
...
@@ -264,7 +281,8 @@ class FToast {
case
ToastGravity
.
TOP_RIGHT
:
return
Positioned
(
top:
100.0
,
right:
24.0
,
child:
child
);
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
);
case
ToastGravity
.
CENTER_LEFT
:
return
Positioned
(
top:
50.0
,
bottom:
50.0
,
left:
24.0
,
child:
child
);
case
ToastGravity
.
CENTER_RIGHT
:
...
...
@@ -274,7 +292,11 @@ class FToast {
case
ToastGravity
.
BOTTOM_RIGHT
:
return
Positioned
(
bottom:
50.0
,
right:
24.0
,
child:
child
);
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
);
case
ToastGravity
.
NONE
:
return
Positioned
.
fill
(
child:
child
);
case
ToastGravity
.
BOTTOM
:
...
...
@@ -341,7 +363,10 @@ class _ToastEntry {
/// internal [StatefulWidget] which handles the show and hide
/// animations for [FToast]
class
_ToastStateFul
extends
StatefulWidget
{
_ToastStateFul
(
this
.
child
,
this
.
duration
,
this
.
fadeDuration
,
this
.
ignorePointer
,
this
.
onDismiss
,
{
Key
?
key
})
:
super
(
key:
key
);
_ToastStateFul
(
this
.
child
,
this
.
duration
,
this
.
fadeDuration
,
this
.
ignorePointer
,
this
.
onDismiss
,
{
Key
?
key
})
:
super
(
key:
key
);
final
Widget
child
;
final
Duration
duration
;
...
...
@@ -354,7 +379,8 @@ class _ToastStateFul extends StatefulWidget {
}
/// State for [_ToastStateFul]
class
ToastStateFulState
extends
State
<
_ToastStateFul
>
with
SingleTickerProviderStateMixin
{
class
ToastStateFulState
extends
State
<
_ToastStateFul
>
with
SingleTickerProviderStateMixin
{
/// Start the showing animations for the toast
showIt
()
{
_animationController
!.
forward
();
...
...
@@ -378,7 +404,8 @@ class ToastStateFulState extends State<_ToastStateFul> with SingleTickerProvider
vsync:
this
,
duration:
widget
.
fadeDuration
,
);
_fadeAnimation
=
CurvedAnimation
(
parent:
_animationController
!,
curve:
Curves
.
easeIn
);
_fadeAnimation
=
CurvedAnimation
(
parent:
_animationController
!,
curve:
Curves
.
easeIn
);
super
.
initState
();
showIt
();
...
...
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