Commit 1dd40fb3 by Caijinglong

the android toast use single instance

parent 3f324bc8
...@@ -24,7 +24,7 @@ import android.graphics.drawable.shapes.RoundRectShape ...@@ -24,7 +24,7 @@ import android.graphics.drawable.shapes.RoundRectShape
class FluttertoastPlugin(context: Context): MethodCallHandler { class FluttertoastPlugin(context: Context): MethodCallHandler {
var ctx: Context? = context var ctx: Context? = context
var toast: Toast? = null
companion object { companion object {
@JvmStatic @JvmStatic
fun registerWith(registrar: Registrar): Unit { fun registerWith(registrar: Registrar): Unit {
...@@ -44,8 +44,8 @@ class FluttertoastPlugin(context: Context): MethodCallHandler { ...@@ -44,8 +44,8 @@ class FluttertoastPlugin(context: Context): MethodCallHandler {
val bgcolor: String = call.argument("bgcolor") val bgcolor: String = call.argument("bgcolor")
val textcolor: String = call.argument("textcolor") val textcolor: String = call.argument("textcolor")
var toast: Toast = Toast.makeText(ctx, msg, Toast.LENGTH_SHORT); val toast: Toast = this.toast?:Toast.makeText(ctx, msg, Toast.LENGTH_SHORT);
this.toast = toast
if(length.equals("long")) { if(length.equals("long")) {
toast.duration = Toast.LENGTH_LONG toast.duration = Toast.LENGTH_LONG
} else { } else {
......
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