Commit 44a47619 by Karthik Ponnam

Bug fixes & PR Merged

parent 9403dab9
......@@ -41,7 +41,7 @@ fluttertoast: ^7.1.6
import 'package:fluttertoast/fluttertoast.dart';
```
## Toast with No Build Context
## Toast with No Build Context (Android & iOS)
```dart
Fluttertoast.showToast(
......@@ -74,6 +74,14 @@ Fluttertoast.showToast(
Fluttertoast.cancel()
```
### Note Android
<img src="https://raw.githubusercontent.com/ponnamkarthik/FlutterToast/master/screenshot/toast_deprecated_setview.png" height="200px" />
> Custom Toast will not work on android 11 and above, it will only use *msg* and *toastLength* remaining all properties are ignored
### Custom Toast For Android
Create a file named `toast_custom.xml` in your project `app/res/layout` folder and do custom styling
......@@ -104,7 +112,7 @@ Create a file named `toast_custom.xml` in your project `app/res/layout` folder a
</FrameLayout>
```
## Toast with BuildContext
## Toast with BuildContext (All Platforms)
```dart
FToast fToast;
......
......@@ -25,7 +25,7 @@ apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
android {
compileSdkVersion 28
compileSdkVersion 30
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
......
......@@ -28,18 +28,21 @@ internal class MethodCallHandlerImpl(var context: Context) : MethodCallHandler {
val textcolor = call.argument<Number>("textcolor")
val textSize = call.argument<Number>("fontSize")
val mGravity: Int
mGravity = when (gravity) {
"top" -> Gravity.TOP
"center" -> Gravity.CENTER
else -> Gravity.BOTTOM
}
val mDuration: Int
mDuration = if (length == "long") {
Toast.LENGTH_LONG
} else {
Toast.LENGTH_SHORT
}
if (bgcolor != null) {
if (bgcolor != null && Build.VERSION.SDK_INT < Build.VERSION_CODES.R) {
val layout = (context.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater).inflate(R.layout.toast_custom, null)
val text = layout.findViewById<TextView>(R.id.text)
text.text = mMessage
......@@ -64,27 +67,32 @@ internal class MethodCallHandlerImpl(var context: Context) : MethodCallHandler {
mToast.view = layout
} else {
mToast = Toast.makeText(context, mMessage, mDuration)
try {
val textView: TextView = mToast.view!!.findViewById(android.R.id.message)
if(textSize != null) {
textView.textSize = textSize.toFloat()
}
if (textcolor != null) {
textView.setTextColor(textcolor.toInt())
if(Build.VERSION.SDK_INT < Build.VERSION_CODES.R) {
try {
val textView: TextView = mToast.view!!.findViewById(android.R.id.message)
if(textSize != null) {
textView.textSize = textSize.toFloat()
}
if (textcolor != null) {
textView.setTextColor(textcolor.toInt())
}
} catch(e: Exception) {
}
} catch(e: Exception) {
}
}
when (mGravity) {
Gravity.CENTER -> {
mToast.setGravity(mGravity, 0, 0)
}
Gravity.TOP -> {
mToast.setGravity(mGravity, 0, 100)
}
else -> {
mToast.setGravity(mGravity, 0, 100)
if(Build.VERSION.SDK_INT < Build.VERSION_CODES.R) {
when (mGravity) {
Gravity.CENTER -> {
mToast.setGravity(mGravity, 0, 0)
}
Gravity.TOP -> {
mToast.setGravity(mGravity, 0, 100)
}
else -> {
mToast.setGravity(mGravity, 0, 100)
}
}
}
if (context is Activity) {
......
......@@ -11,5 +11,4 @@
*
* Copyright (C) 2018 Varun A P
*/
.toastify{padding:12px 20px;color:#fff;display:inline-block;box-shadow:0 3px 6px -1px rgba(0,0,0,.12),0 10px 36px -4px rgba(77,96,232,.3);background:-webkit-linear-gradient(315deg,#73a5ff,#5477f5);background:linear-gradient(135deg,#73a5ff,#5477f5);position:fixed;opacity:0;transition:all .4s cubic-bezier(.215,.61,.355,1);border-radius:2px;cursor:pointer;text-decoration:none;max-width:calc(50% - 20px);z-index:2147483647}.toastify.on{opacity:1}.toast-close{opacity:.4;padding:0 5px}.toastify-right{right:15px}.toastify-left{left:15px}.toastify-top{top:-150px}.toastify-bottom{bottom:-150px}.toastify-rounded{border-radius:25px}.toastify-avatar{width:1.5em;height:1.5em;margin:-7px 5px;border-radius:2px}.toastify-center{margin-left:auto;margin-right:auto;left:0;right:0;max-width:fit-content;max-width:-moz-fit-content}@media only screen and (max-width:360px){.toastify-left,.toastify-right{margin-left:auto;margin-right:auto;left:0;right:0;max-width:fit-content}}
/*# sourceMappingURL=/sm/40f738e33ed5dbe7907b48c3be4b63e977eab6cb49c8df4f76f3edc3f1f2fb0d.map */
\ No newline at end of file
.toastify{padding:12px 20px;color:#fff;display:inline-block;box-shadow:0 3px 6px -1px rgba(0,0,0,.12),0 10px 36px -4px rgba(77,96,232,.3);background:-webkit-linear-gradient(315deg,#73a5ff,#5477f5);background:linear-gradient(135deg,#73a5ff,#5477f5);position:fixed;opacity:0;transition:all .4s cubic-bezier(.215,.61,.355,1);border-radius:2px;cursor:pointer;text-decoration:none;max-width:calc(50% - 20px);z-index:2147483647}.toastify.on{opacity:1}.toast-close{opacity:.4;padding:0 5px}.toastify-right{right:15px}.toastify-left{left:15px}.toastify-top{top:-150px}.toastify-bottom{bottom:-150px}.toastify-rounded{border-radius:25px}.toastify-avatar{width:1.5em;height:1.5em;margin:-7px 5px;border-radius:2px}.toastify-center{margin-left:auto;margin-right:auto;left:0;right:0;max-width:fit-content;max-width:-moz-fit-content}@media only screen and (max-width:360px){.toastify-left,.toastify-right{margin-left:auto;margin-right:auto;left:0;right:0;max-width:fit-content}}
\ No newline at end of file
......@@ -5,6 +5,8 @@ export "FLUTTER_APPLICATION_PATH=/Users/karthikponnam/Desktop/my/plugins/Flutter
export "FLUTTER_TARGET=lib/main.dart"
export "FLUTTER_BUILD_DIR=build"
export "SYMROOT=${SOURCE_ROOT}/../build/ios"
export "OTHER_LDFLAGS=$(inherited) -framework Flutter"
export "FLUTTER_FRAMEWORK_DIR=/usr/local/Caskroom/flutter/1.22.3/flutter/bin/cache/artifacts/engine/ios"
export "FLUTTER_BUILD_NAME=1.0.0"
export "FLUTTER_BUILD_NUMBER=1"
export "DART_OBFUSCATION=false"
......
......@@ -7,42 +7,42 @@ packages:
name: async
url: "https://pub.dartlang.org"
source: hosted
version: "2.5.0-nullsafety.3"
version: "2.5.0-nullsafety.1"
boolean_selector:
dependency: transitive
description:
name: boolean_selector
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0-nullsafety.3"
version: "2.1.0-nullsafety.1"
characters:
dependency: transitive
description:
name: characters
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0-nullsafety.5"
version: "1.1.0-nullsafety.3"
charcode:
dependency: transitive
description:
name: charcode
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0-nullsafety.3"
version: "1.2.0-nullsafety.1"
clock:
dependency: transitive
description:
name: clock
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0-nullsafety.3"
version: "1.1.0-nullsafety.1"
collection:
dependency: transitive
description:
name: collection
url: "https://pub.dartlang.org"
source: hosted
version: "1.15.0-nullsafety.5"
version: "1.15.0-nullsafety.3"
cupertino_icons:
dependency: "direct main"
description:
......@@ -56,7 +56,7 @@ packages:
name: fake_async
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0-nullsafety.3"
version: "1.2.0-nullsafety.1"
flutter:
dependency: "direct main"
description: flutter
......@@ -78,35 +78,28 @@ packages:
path: ".."
relative: true
source: path
version: "7.1.6"
js:
dependency: transitive
description:
name: js
url: "https://pub.dartlang.org"
source: hosted
version: "0.6.3-nullsafety.3"
version: "7.1.7"
matcher:
dependency: transitive
description:
name: matcher
url: "https://pub.dartlang.org"
source: hosted
version: "0.12.10-nullsafety.3"
version: "0.12.10-nullsafety.1"
meta:
dependency: transitive
description:
name: meta
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0-nullsafety.6"
version: "1.3.0-nullsafety.3"
path:
dependency: transitive
description:
name: path
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.0-nullsafety.3"
version: "1.8.0-nullsafety.1"
sky_engine:
dependency: transitive
description: flutter
......@@ -118,56 +111,56 @@ packages:
name: source_span
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.0-nullsafety.4"
version: "1.8.0-nullsafety.2"
stack_trace:
dependency: transitive
description:
name: stack_trace
url: "https://pub.dartlang.org"
source: hosted
version: "1.10.0-nullsafety.6"
version: "1.10.0-nullsafety.1"
stream_channel:
dependency: transitive
description:
name: stream_channel
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0-nullsafety.3"
version: "2.1.0-nullsafety.1"
string_scanner:
dependency: transitive
description:
name: string_scanner
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0-nullsafety.3"
version: "1.1.0-nullsafety.1"
term_glyph:
dependency: transitive
description:
name: term_glyph
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0-nullsafety.3"
version: "1.2.0-nullsafety.1"
test_api:
dependency: transitive
description:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.19-nullsafety.6"
version: "0.2.19-nullsafety.2"
typed_data:
dependency: transitive
description:
name: typed_data
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0-nullsafety.5"
version: "1.3.0-nullsafety.3"
vector_math:
dependency: transitive
description:
name: vector_math
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0-nullsafety.5"
version: "2.1.0-nullsafety.3"
sdks:
dart: ">=2.12.0-0.0 <3.0.0"
dart: ">=2.10.0-110 <2.11.0"
flutter: ">=1.10.0"
......@@ -7,14 +7,14 @@ packages:
name: characters
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0-nullsafety.5"
version: "1.1.0-nullsafety.3"
collection:
dependency: transitive
description:
name: collection
url: "https://pub.dartlang.org"
source: hosted
version: "1.15.0-nullsafety.5"
version: "1.15.0-nullsafety.3"
flutter:
dependency: "direct main"
description: flutter
......@@ -25,20 +25,13 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
js:
dependency: transitive
description:
name: js
url: "https://pub.dartlang.org"
source: hosted
version: "0.6.3-nullsafety.3"
meta:
dependency: transitive
description:
name: meta
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0-nullsafety.6"
version: "1.3.0-nullsafety.3"
sky_engine:
dependency: transitive
description: flutter
......@@ -50,14 +43,14 @@ packages:
name: typed_data
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0-nullsafety.5"
version: "1.3.0-nullsafety.3"
vector_math:
dependency: transitive
description:
name: vector_math
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0-nullsafety.5"
version: "2.1.0-nullsafety.3"
sdks:
dart: ">=2.12.0-0 <3.0.0"
dart: ">=2.10.0-110 <2.11.0"
flutter: ">=1.10.0"
name: fluttertoast
description: Toast Library for Flutter, Easily create toast messages in single line of code
version: 7.1.6
version: 7.1.7
homepage: https://github.com/PonnamKarthik/FlutterToast
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