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
f829e327
Commit
f829e327
authored
Mar 21, 2021
by
Karthik Ponnam
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
NullSafety on master
parent
85bbe9eb
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
51 additions
and
46 deletions
+51
-46
CHANGELOG.md
+5
-0
example/pubspec.lock
+1
-1
lib/fluttertoast.dart
+34
-34
lib/fluttertoast_web.dart
+9
-9
pubspec.lock
+1
-1
pubspec.yaml
+1
-1
No files found.
CHANGELOG.md
View file @
f829e327
## [8.0.2]
-
Null Safety
-
Code Docs Added
## [7.1.8]
-
Web sourceMap Warning
...
...
example/pubspec.lock
View file @
f829e327
...
...
@@ -169,5 +169,5 @@ packages:
source: hosted
version: "2.1.0"
sdks:
dart: ">=2.12.0
-0.0
<3.0.0"
dart: ">=2.12.0 <3.0.0"
flutter: ">=1.10.0"
lib/fluttertoast.dart
View file @
f829e327
...
...
@@ -37,8 +37,8 @@ class Fluttertoast {
/// Let say you have an active show
/// Use this method to hide the toast immediately
static
Future
<
bool
>
cancel
()
async
{
bool
res
=
await
_channel
.
invokeMethod
(
"cancel"
);
static
Future
<
bool
?
>
cancel
()
async
{
bool
?
res
=
await
_channel
.
invokeMethod
(
"cancel"
);
return
res
;
}
...
...
@@ -49,14 +49,14 @@ class Fluttertoast {
/// Wraps the https://github.com/apvarun/toastify-js for Web
///
/// Parameter [msg] is required and remning all are options
static
Future
<
bool
>
showToast
({
@
required
String
msg
,
Toast
toastLength
,
static
Future
<
bool
?
>
showToast
({
required
String
msg
,
Toast
?
toastLength
,
int
timeInSecForIosWeb
=
1
,
double
fontSize
,
ToastGravity
gravity
,
Color
backgroundColor
,
Color
textColor
,
double
?
fontSize
,
ToastGravity
?
gravity
,
Color
?
backgroundColor
,
Color
?
textColor
,
bool
webShowClose
=
false
,
webBgColor:
"linear-gradient(to right, #00b09b, #96c93d)"
,
webPosition:
"right"
,
...
...
@@ -95,7 +95,7 @@ class Fluttertoast {
'webPosition'
:
webPosition
};
bool
res
=
await
_channel
.
invokeMethod
(
'showToast'
,
params
);
bool
?
res
=
await
_channel
.
invokeMethod
(
'showToast'
,
params
);
return
res
;
}
}
...
...
@@ -110,7 +110,7 @@ typedef PositionedToastBuilder = Widget Function(
/// fToast.showToast(child)
///
class
FToast
{
BuildContext
context
;
BuildContext
?
context
;
static
final
FToast
_instance
=
FToast
.
_internal
();
...
...
@@ -126,9 +126,9 @@ class FToast {
FToast
.
_internal
();
OverlayEntry
_entry
;
OverlayEntry
?
_entry
;
List
<
_ToastEntry
>
_overlayQueue
=
[];
Timer
_timer
;
Timer
?
_timer
;
/// Internal function which handles the adding
/// the overlay to the screen
...
...
@@ -142,9 +142,9 @@ class FToast {
_entry
=
_toastEntry
.
entry
;
if
(
context
==
null
)
throw
(
"Error: Context is null, Please call init(context) before showing toast."
);
Overlay
.
of
(
context
).
insert
(
_entry
);
Overlay
.
of
(
context
!)!.
insert
(
_entry
!
);
_timer
=
Timer
(
_toastEntry
.
duration
,
()
{
_timer
=
Timer
(
_toastEntry
.
duration
!
,
()
{
Future
.
delayed
(
Duration
(
milliseconds:
360
),
()
{
removeCustomToast
();
});
...
...
@@ -156,7 +156,7 @@ class FToast {
removeCustomToast
()
{
_timer
?.
cancel
();
_timer
=
null
;
if
(
_entry
!=
null
)
_entry
.
remove
();
if
(
_entry
!=
null
)
_entry
!
.
remove
();
_showOverlay
();
}
...
...
@@ -169,7 +169,7 @@ class FToast {
_timer
?.
cancel
();
_timer
=
null
;
_overlayQueue
.
clear
();
if
(
_entry
!=
null
)
_entry
.
remove
();
if
(
_entry
!=
null
)
_entry
!
.
remove
();
_entry
=
null
;
}
...
...
@@ -179,10 +179,10 @@ class FToast {
/// Paramenter [child] is requried
///
void
showToast
({
@
required
Widget
child
,
PositionedToastBuilder
positionedToastBuilder
,
Duration
toastDuration
,
ToastGravity
gravity
,
required
Widget
child
,
PositionedToastBuilder
?
positionedToastBuilder
,
Duration
?
toastDuration
,
ToastGravity
?
gravity
,
})
{
Widget
newChild
=
_ToastStateFul
(
child
,
...
...
@@ -201,7 +201,7 @@ class FToast {
/// _getPostionWidgetBasedOnGravity generates [Positioned] [Widget]
/// based on the gravity [ToastGravity] provided by the user in
/// [showToast]
_getPostionWidgetBasedOnGravity
(
Widget
child
,
ToastGravity
gravity
)
{
_getPostionWidgetBasedOnGravity
(
Widget
child
,
ToastGravity
?
gravity
)
{
switch
(
gravity
)
{
case
ToastGravity
.
TOP
:
return
Positioned
(
top:
100.0
,
left:
24.0
,
right:
24.0
,
child:
child
);
...
...
@@ -230,7 +230,7 @@ class FToast {
break
;
case
ToastGravity
.
SNACKBAR
:
return
Positioned
(
bottom:
MediaQuery
.
of
(
context
).
viewInsets
.
bottom
,
bottom:
MediaQuery
.
of
(
context
!
).
viewInsets
.
bottom
,
left:
0
,
right:
0
,
child:
child
);
...
...
@@ -246,8 +246,8 @@ class FToast {
/// each [OverlayEntry] and [Duration] for every toast user
/// triggered
class
_ToastEntry
{
final
OverlayEntry
entry
;
final
Duration
duration
;
final
OverlayEntry
?
entry
;
final
Duration
?
duration
;
_ToastEntry
({
this
.
entry
,
this
.
duration
});
}
...
...
@@ -255,7 +255,7 @@ class _ToastEntry {
/// internal [StatefulWidget] which handles the show and hide
/// animations for [FToast]
class
_ToastStateFul
extends
StatefulWidget
{
_ToastStateFul
(
this
.
child
,
this
.
duration
,
{
Key
key
})
:
super
(
key:
key
);
_ToastStateFul
(
this
.
child
,
this
.
duration
,
{
Key
?
key
})
:
super
(
key:
key
);
final
Widget
child
;
final
Duration
duration
;
...
...
@@ -269,20 +269,20 @@ class ToastStateFulState extends State<_ToastStateFul>
with
SingleTickerProviderStateMixin
{
/// Start the showing animations for the toast
showIt
()
{
_animationController
.
forward
();
_animationController
!
.
forward
();
}
/// Start the hidding animations for the toast
hideIt
()
{
_animationController
.
reverse
();
_animationController
!
.
reverse
();
_timer
?.
cancel
();
}
/// Controller to start and hide the animation
AnimationController
_animationController
;
Animation
_fadeAnimation
;
AnimationController
?
_animationController
;
late
Animation
_fadeAnimation
;
Timer
_timer
;
Timer
?
_timer
;
@override
void
initState
()
{
...
...
@@ -291,7 +291,7 @@ class ToastStateFulState extends State<_ToastStateFul>
duration:
const
Duration
(
milliseconds:
350
),
);
_fadeAnimation
=
CurvedAnimation
(
parent:
_animationController
,
curve:
Curves
.
easeIn
);
CurvedAnimation
(
parent:
_animationController
!
,
curve:
Curves
.
easeIn
);
super
.
initState
();
showIt
();
...
...
@@ -303,7 +303,7 @@ class ToastStateFulState extends State<_ToastStateFul>
@override
void
deactivate
()
{
_timer
?.
cancel
();
_animationController
.
stop
();
_animationController
!
.
stop
();
super
.
deactivate
();
}
...
...
@@ -317,7 +317,7 @@ class ToastStateFulState extends State<_ToastStateFul>
@override
Widget
build
(
BuildContext
context
)
{
return
FadeTransition
(
opacity:
_fadeAnimation
,
opacity:
_fadeAnimation
as
Animation
<
double
>
,
child:
Center
(
child:
Material
(
color:
Colors
.
transparent
,
...
...
lib/fluttertoast_web.dart
View file @
f829e327
...
...
@@ -37,7 +37,7 @@ class FluttertoastWebPlugin {
/// it to [addHtmlToast]
showToast
(
args
)
{
String
msg
=
args
[
'msg'
];
String
gravity
=
"top"
;
String
?
gravity
=
"top"
;
if
(
args
[
'gravity'
]
==
"top"
||
args
[
'gravity'
]
==
"bottom"
)
{
gravity
=
args
[
"gravity"
];
}
...
...
@@ -47,7 +47,7 @@ class FluttertoastWebPlugin {
String
bgColor
=
args
[
'webBgColor'
]
??
"linear-gradient(to right, #00b09b, #96c93d)"
;
int
textColor
=
args
[
'textcolor'
];
int
?
textColor
=
args
[
'textcolor'
];
int
time
=
args
[
'time'
]
==
null
?
3000
...
...
@@ -82,7 +82,7 @@ class FluttertoastWebPlugin {
..
src
=
"assets/packages/fluttertoast/assets/toastify.js"
;
loading
.
add
(
script
.
onLoad
.
first
);
tags
.
add
(
script
);
html
.
querySelector
(
'head'
).
children
.
addAll
(
tags
);
html
.
querySelector
(
'head'
)
!
.
children
.
addAll
(
tags
);
await
Future
.
wait
(
loading
);
}
...
...
@@ -91,14 +91,14 @@ class FluttertoastWebPlugin {
/// make toast visible on web
addHtmlToast
(
{
String
msg
=
""
,
String
gravity
=
"top"
,
String
?
gravity
=
"top"
,
String
position
=
"right"
,
String
bgcolor
=
"linear-gradient(to right, #00b09b, #96c93d)"
,
int
time
=
3000
,
bool
showClose
=
false
,
int
textColor
})
{
int
?
textColor
})
{
String
m
=
msg
.
replaceAll
(
"'"
,
"
\\
'"
).
replaceAll
(
"
\n
"
,
"<br />"
);
html
.
Element
ele
=
html
.
querySelector
(
"#toast-content"
);
html
.
Element
?
ele
=
html
.
querySelector
(
"#toast-content"
);
String
content
=
"""
var toastElement = Toastify({
text: '
$m
',
...
...
@@ -111,14 +111,14 @@ class FluttertoastWebPlugin {
toastElement.showToast();
"""
;
if
(
html
.
querySelector
(
"#toast-content"
)
!=
null
)
{
ele
.
remove
();
ele
!
.
remove
();
}
final
html
.
ScriptElement
scriptText
=
html
.
ScriptElement
()
..
id
=
"toast-content"
..
innerHtml
=
content
;
html
.
querySelector
(
'head'
).
children
.
add
(
scriptText
);
html
.
querySelector
(
'head'
)
!
.
children
.
add
(
scriptText
);
if
(
textColor
!=
null
)
{
html
.
Element
toast
=
html
.
querySelector
(
'.toastify'
);
html
.
Element
toast
=
html
.
querySelector
(
'.toastify'
)
!
;
String
tcRadix
=
textColor
.
toRadixString
(
16
);
final
String
tC
=
"
${tcRadix.substring(2)}${tcRadix.substring(0, 2)}
"
;
toast
.
style
.
setProperty
(
'color'
,
"#
$tC
"
);
...
...
pubspec.lock
View file @
f829e327
...
...
@@ -59,5 +59,5 @@ packages:
source: hosted
version: "2.1.0"
sdks:
dart: ">=2.12.0
-0
<3.0.0"
dart: ">=2.12.0 <3.0.0"
flutter: ">=1.10.0"
pubspec.yaml
View file @
f829e327
...
...
@@ -5,7 +5,7 @@ homepage: https://github.com/PonnamKarthik/FlutterToast
issue_tracker
:
https://github.com/ponnamkarthik/FlutterToast/issues
environment
:
sdk
:
"
>=2.7.0
<3.0.0"
sdk
:
'
>=2.12.0
<3.0.0'
flutter
:
"
>=1.10.0"
dependencies
:
...
...
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