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
040e2038
Commit
040e2038
authored
Jul 30, 2020
by
Karthik Ponnam
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
minor updated
parent
cdb4c960
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
27 deletions
+25
-27
lib/fluttertoast_web.dart
+25
-27
No files found.
lib/fluttertoast_web.dart
View file @
040e2038
import
'dart:async'
;
import
'dart:html'
as
html
;
import
'dart:ui'
as
ui
;
import
'dart:js'
as
js
;
import
'package:flutter/services.dart'
;
import
'package:flutter_web_plugins/flutter_web_plugins.dart'
;
class
FluttertoastWebPlugin
{
FluttertoastWebPlugin
()
{
injectCssAndJSLibraries
();
}
static
void
registerWith
(
Registrar
registrar
)
{
final
MethodChannel
channel
=
MethodChannel
(
'PonnamKarthik/fluttertoast'
,
const
StandardMethodCodec
(),
registrar
.
messenger
);
final
MethodChannel
channel
=
MethodChannel
(
'PonnamKarthik/fluttertoast'
,
const
StandardMethodCodec
(),
registrar
.
messenger
);
final
FluttertoastWebPlugin
instance
=
FluttertoastWebPlugin
();
channel
.
setMethodCallHandler
(
instance
.
handleMethodCall
);
}
...
...
@@ -33,10 +29,10 @@ class FluttertoastWebPlugin {
}
}
Future
<
void
>
showToast
(
args
)
{
showToast
(
args
)
{
String
msg
=
args
[
'msg'
];
String
gravity
=
"top"
;
if
(
args
[
'gravity'
]
==
"top"
||
args
[
'gravity'
]
==
"bottom"
)
{
if
(
args
[
'gravity'
]
==
"top"
||
args
[
'gravity'
]
==
"bottom"
)
{
gravity
=
args
[
"gravity"
];
}
...
...
@@ -56,25 +52,31 @@ class FluttertoastWebPlugin {
final
List
<
html
.
HtmlElement
>
tags
=
<
html
.
HtmlElement
>[];
final
html
.
StyleElement
css
=
html
.
StyleElement
()
..
id
=
'toast-css'
..
appendText
(
"@import url('https://cdn.jsdelivr.net/npm/toastify-js/src/toastify.min.css');"
);
tags
.
add
(
css
);
..
id
=
'toast-css'
..
appendText
(
"@import url('https://cdn.jsdelivr.net/npm/toastify-js/src/toastify.min.css');"
);
tags
.
add
(
css
);
final
html
.
ScriptElement
script
=
html
.
ScriptElement
()
..
async
=
true
..
defer
=
true
..
src
=
"https://cdn.jsdelivr.net/npm/toastify-js"
;
loading
.
add
(
script
.
onLoad
.
first
);
tags
.
add
(
script
);
..
async
=
true
..
defer
=
true
..
src
=
"https://cdn.jsdelivr.net/npm/toastify-js"
;
loading
.
add
(
script
.
onLoad
.
first
);
tags
.
add
(
script
);
html
.
querySelector
(
'head'
).
children
.
addAll
(
tags
);
await
Future
.
wait
(
loading
);
// addHtmlToast();
// addHtmlToast();
}
addHtmlToast
({
String
msg
=
""
,
String
gravity
=
"top"
,
String
position
=
"right"
,
String
bgcolor
=
"linear-gradient(to right, #00b09b, #96c93d)"
,
int
time
=
3000
,
bool
showClose
=
false
})
{
addHtmlToast
(
{
String
msg
=
""
,
String
gravity
=
"top"
,
String
position
=
"right"
,
String
bgcolor
=
"linear-gradient(to right, #00b09b, #96c93d)"
,
int
time
=
3000
,
bool
showClose
=
false
})
{
print
(
html
.
querySelector
(
"#toast-content"
));
html
.
Element
ele
=
html
.
querySelector
(
"#toast-content"
);
String
content
=
"""
...
...
@@ -88,16 +90,12 @@ class FluttertoastWebPlugin {
});
toastElement.showToast();
"""
;
if
(
html
.
querySelector
(
"#toast-content"
)
!=
null
)
{
if
(
html
.
querySelector
(
"#toast-content"
)
!=
null
)
{
ele
.
remove
();
}
final
html
.
ScriptElement
scriptText
=
html
.
ScriptElement
()
..
id
=
"toast-content"
..
innerHtml
=
content
;
html
.
querySelector
(
'head'
).
children
.
add
(
scriptText
);
final
html
.
ScriptElement
scriptText
=
html
.
ScriptElement
()
..
id
=
"toast-content"
..
innerHtml
=
content
;
html
.
querySelector
(
'head'
).
children
.
add
(
scriptText
);
}
}
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