Commit 37a29c8d by Karthik Ponnam

Fixed Unresolved reference: Q

parent 11882aea
## [8.0.5]
- Fixed Unresolved reference: R (Issue with Android API 30)
## [8.0.4] ## [8.0.4]
- Fixed Unresolved reference: R (Issue with Android API 30) - Fixed Unresolved reference: R (Issue with Android API 30)
......
...@@ -34,7 +34,7 @@ This one has limited features and no control over UI ...@@ -34,7 +34,7 @@ This one has limited features and no control over UI
```yaml ```yaml
# add this line to your dependencies # add this line to your dependencies
fluttertoast: ^8.0.4 fluttertoast: ^8.0.5
``` ```
```dart ```dart
......
...@@ -5,8 +5,12 @@ import android.content.Context ...@@ -5,8 +5,12 @@ import android.content.Context
import android.graphics.PorterDuff import android.graphics.PorterDuff
import android.graphics.drawable.Drawable import android.graphics.drawable.Drawable
import android.os.Build import android.os.Build
import android.os.Handler
import android.view.Gravity import android.view.Gravity
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View
import android.view.WindowInsets
import android.view.inputmethod.InputMethodManager
import android.widget.TextView import android.widget.TextView
import android.widget.Toast import android.widget.Toast
import io.flutter.plugin.common.MethodCall import io.flutter.plugin.common.MethodCall
...@@ -42,7 +46,7 @@ internal class MethodCallHandlerImpl(var context: Context) : MethodCallHandler { ...@@ -42,7 +46,7 @@ internal class MethodCallHandlerImpl(var context: Context) : MethodCallHandler {
Toast.LENGTH_SHORT Toast.LENGTH_SHORT
} }
if (bgcolor != null && Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) { if (bgcolor != null && Build.VERSION.SDK_INT < 29) {
val layout = (context.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater).inflate(R.layout.toast_custom, null) val layout = (context.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater).inflate(R.layout.toast_custom, null)
val text = layout.findViewById<TextView>(R.id.text) val text = layout.findViewById<TextView>(R.id.text)
text.text = mMessage text.text = mMessage
...@@ -67,7 +71,7 @@ internal class MethodCallHandlerImpl(var context: Context) : MethodCallHandler { ...@@ -67,7 +71,7 @@ internal class MethodCallHandlerImpl(var context: Context) : MethodCallHandler {
mToast.view = layout mToast.view = layout
} else { } else {
mToast = Toast.makeText(context, mMessage, mDuration) mToast = Toast.makeText(context, mMessage, mDuration)
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) { if (Build.VERSION.SDK_INT < 29) {
try { try {
val textView: TextView = mToast.view!!.findViewById(android.R.id.message) val textView: TextView = mToast.view!!.findViewById(android.R.id.message)
if (textSize != null) { if (textSize != null) {
...@@ -95,11 +99,19 @@ internal class MethodCallHandlerImpl(var context: Context) : MethodCallHandler { ...@@ -95,11 +99,19 @@ internal class MethodCallHandlerImpl(var context: Context) : MethodCallHandler {
} }
} }
// } // }
// val inputMethodManager = context.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
// if(inputMethodManager.isAcceptingText) {
// mToast.setGravity(Gravity.CENTER, 0, 0)
// }
if (context is Activity) { if (context is Activity) {
(context as Activity).runOnUiThread { mToast.show() } (context as Activity).runOnUiThread { mToast.show() }
} else { } else {
mToast.show() mToast.show()
} }
result.success(true) result.success(true)
} }
"cancel" -> { "cancel" -> {
...@@ -111,4 +123,16 @@ internal class MethodCallHandlerImpl(var context: Context) : MethodCallHandler { ...@@ -111,4 +123,16 @@ internal class MethodCallHandlerImpl(var context: Context) : MethodCallHandler {
else -> result.notImplemented() else -> result.notImplemented()
} }
} }
fun resetToast() {
if (::mToast.isInitialized && mToast != null) {
if (mToast.view.visibility != View.VISIBLE) {
mToast
} else {
Handler().postDelayed(Runnable {
resetToast()
}, 1000);
}
}
}
} }
name: fluttertoast name: fluttertoast
description: Toast Library for Flutter, Easily create toast messages in single line of code description: Toast Library for Flutter, Easily create toast messages in single line of code
version: 8.0.4 version: 8.0.5
homepage: https://github.com/PonnamKarthik/FlutterToast homepage: https://github.com/PonnamKarthik/FlutterToast
issue_tracker: https://github.com/ponnamkarthik/FlutterToast/issues issue_tracker: https://github.com/ponnamkarthik/FlutterToast/issues
......
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