Commit 040e2038 by Karthik Ponnam

minor updated

parent cdb4c960
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"];
}
......@@ -74,7 +70,13 @@ class FluttertoastWebPlugin {
// 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);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment