Commit 77560d80 by Karthik

v3.0.4

parent e58dde0b
## [3.0.4]
- Android Color fix
## [3.0.3] ## [3.0.3]
* fixed Android Toast.LENGTH_* - fixed Android Toast.LENGTH\_\*
## [3.0.2] ## [3.0.2]
* fixed #70 #71 - fixed #70 #71
## [3.0.1] ## [3.0.1]
* Release build failed fix - Release build failed fix
* Multiline text android fix - Multiline text android fix
## [3.0.0] ## [3.0.0]
* Migrated to AndroidX - Migrated to AndroidX
## [2.2.12] ## [2.2.12]
* Incomplete Text Fix - Incomplete Text Fix
## [2.2.11] ## [2.2.11]
* Incomplete Text Fix - Incomplete Text Fix
## [2.2.10] ## [2.2.10]
* iOS build Failed fix - iOS build Failed fix
## [2.2.9] ## [2.2.9]
* iOS build Failed fix - iOS build Failed fix
## [2.2.8] ## [2.2.8]
* `Fluttertoast.cancel()` added - `Fluttertoast.cancel()` added
* FlutterToast Implementation revert back to previous - FlutterToast Implementation revert back to previous
## [2.2.7] ## [2.2.7]
* FontSize Can be changed - FontSize Can be changed
* FlutterToast Implementation Changed to `FlutterToast.instance` - FlutterToast Implementation Changed to `FlutterToast.instance`
## [2.2.6] ## [2.2.6]
* removed androidx - removed androidx
## [2.2.5] ## [2.2.5]
* Cannot build because of dependency w/ v28 #47 - Cannot build because of dependency w/ v28 #47
## [2.2.4] ## [2.2.4]
* androidX crash fix #45 - androidX crash fix #45
## [2.2.3] ## [2.2.3]
* iOS Crash fix #41 & #39 - iOS Crash fix #41 & #39
## [2.2.1] ## [2.2.1]
* default toast style fix #38 - default toast style fix #38
## [2.2.0] ## [2.2.0]
* Background color fixed #29 - Background color fixed #29
## [2.1.5] ## [2.1.5]
* Merged PR #36 - Fix Number Cast Error for issue #35 - Merged PR #36 - Fix Number Cast Error for issue #35
## [2.1.4] ## [2.1.4]
* Merged PR #32 - Merged PR #32
## [2.1.2] ## [2.1.2]
* iOS Color Fix - iOS Color Fix
* Background color fix in PIE - Background color fix in PIE
## [2.1.1] ## [2.1.1]
* Background color does not fill the whole Toast fixed - Background color does not fill the whole Toast fixed
## [2.1.0] ## [2.1.0]
* build error fixed - build error fixed
## [2.0.9] ## [2.0.9]
* fix error in flutter 0.9.7 - fix error in flutter 0.9.7
## [2.0.8] ## [2.0.8]
* Build failed with an exception fixed - Build failed with an exception fixed
* The plugin calls the build of the previous widget fixed - The plugin calls the build of the previous widget fixed
* Screenshots added - Screenshots added
## [2.0.7] ## [2.0.7]
* Text background fix for android - Text background fix for android
## [2.0.6] ## [2.0.6]
* iOS Release build error fixed - iOS Release build error fixed
## [2.0.3] ## [2.0.3]
* iOs run time error fixed - iOs run time error fixed
## [2.0.2] ## [2.0.2]
* iOs build error fixed - iOs build error fixed
## [2.0.1] ## [2.0.1]
* Ios Support added - Ios Support added
* option for setting toast gravity (top, center, bottom) - option for setting toast gravity (top, center, bottom)
## [1.0.1] ## [1.0.1]
* Initial Open Sources - Initial Open Sources
* show Toast in Android - show Toast in Android
# [fluttertoast](https://pub.dartlang.org/packages/fluttertoast) # [fluttertoast](https://pub.dartlang.org/packages/fluttertoast)
Android and iOS Toast Library for Flutter Android and iOS Toast Library for Flutter
> Supported Platforms > Supported Platforms
> * Android >
> * IOS > - Android
> - IOS
If you dont want to use androidx then use `fluttertoast` version `2.2.11` If you dont want to use androidx then use `fluttertoast` version `2.2.11`
...@@ -13,7 +13,7 @@ If you dont want to use androidx then use `fluttertoast` version `2.2.11` ...@@ -13,7 +13,7 @@ If you dont want to use androidx then use `fluttertoast` version `2.2.11`
```yaml ```yaml
# add this line to your dependencies # add this line to your dependencies
fluttertoast: ^3.0.3 fluttertoast: ^3.0.4
``` ```
```dart ```dart
...@@ -32,16 +32,15 @@ Fluttertoast.showToast( ...@@ -32,16 +32,15 @@ Fluttertoast.showToast(
); );
``` ```
property | description | property | description |
--------|------------ | --------------- | ------------------------------------------------------------------ |
msg | String (Not Null)(required) | msg | String (Not Null)(required) |
toastLength| Toast.LENGTH_SHORT or Toast.LENGTH_LONG (optional) | toastLength | Toast.LENGTH_SHORT or Toast.LENGTH_LONG (optional) |
gravity | ToastGravity.TOP (or) ToastGravity.CENTER (or) ToastGravity.BOTTOM | gravity | ToastGravity.TOP (or) ToastGravity.CENTER (or) ToastGravity.BOTTOM |
timeInSecForIos | int (only for ios) | timeInSecForIos | int (only for ios) |
bgcolor | Colors.red | bgcolor | Colors.red |
textcolor| Colors.white | textcolor | Colors.white |
fontSize | 16.0 (float) | fontSize | 16.0 (float) |
### To cancel all the toasts call ### To cancel all the toasts call
...@@ -56,5 +55,4 @@ Fluttertoast.cancel() ...@@ -56,5 +55,4 @@ Fluttertoast.cancel()
<img src="https://raw.githubusercontent.com/PonnamKarthik/FlutterToast/master/screenshot/3.png" width="320px" /> <img src="https://raw.githubusercontent.com/PonnamKarthik/FlutterToast/master/screenshot/3.png" width="320px" />
<img src="https://raw.githubusercontent.com/PonnamKarthik/FlutterToast/master/screenshot/4.png" width="320px" /> <img src="https://raw.githubusercontent.com/PonnamKarthik/FlutterToast/master/screenshot/4.png" width="320px" />
## If you need any features suggest ## If you need any features suggest
...@@ -32,3 +32,6 @@ android { ...@@ -32,3 +32,6 @@ android {
disable 'InvalidPackage' disable 'InvalidPackage'
} }
} }
dependencies {
// implementation fileTree(dir: 'libs', include: ['*.jar'])
}
#Thu Apr 18 06:25:50 IST 2019
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
...@@ -4,10 +4,8 @@ import android.content.Context; ...@@ -4,10 +4,8 @@ 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.util.Log;
import android.view.Gravity; import android.view.Gravity;
import android.view.MotionEvent; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
...@@ -21,10 +19,10 @@ import io.flutter.plugin.common.PluginRegistry.Registrar; ...@@ -21,10 +19,10 @@ import io.flutter.plugin.common.PluginRegistry.Registrar;
/** FluttertoastPlugin */ /** FluttertoastPlugin */
public class FluttertoastPlugin implements MethodCallHandler { public class FluttertoastPlugin implements MethodCallHandler {
Context ctx; private Context ctx;
Toast toast; private Toast toast;
FluttertoastPlugin(Context context) { private FluttertoastPlugin(Context context) {
ctx = context; ctx = context;
} }
...@@ -36,7 +34,8 @@ public class FluttertoastPlugin implements MethodCallHandler { ...@@ -36,7 +34,8 @@ public class FluttertoastPlugin implements MethodCallHandler {
@Override @Override
public void onMethodCall(MethodCall call, final Result result) { public void onMethodCall(MethodCall call, final Result result) {
if (call.method.equals("showToast")) { switch (call.method) {
case "showToast":
String msg = call.argument("msg").toString(); String msg = call.argument("msg").toString();
String length = call.argument("length").toString(); String length = call.argument("length").toString();
String gravity = call.argument("gravity").toString(); String gravity = call.argument("gravity").toString();
...@@ -44,29 +43,24 @@ public class FluttertoastPlugin implements MethodCallHandler { ...@@ -44,29 +43,24 @@ public class FluttertoastPlugin implements MethodCallHandler {
Number textcolor = call.argument("textcolor"); Number textcolor = call.argument("textcolor");
Number textSize = call.argument("fontSize"); Number textSize = call.argument("fontSize");
if(length.equals("long")) {
toast = Toast.makeText(ctx, msg, Toast.LENGTH_LONG); LayoutInflater inflater = (LayoutInflater) ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View layout = inflater.inflate(R.layout.toast_custom, null);
TextView text = layout.findViewById(R.id.text);
toast = new Toast(ctx);
if (length.equals("long")) {
toast.setDuration(Toast.LENGTH_LONG);
} else { } else {
toast = Toast.makeText(ctx, msg, Toast.LENGTH_SHORT); toast.setDuration(Toast.LENGTH_SHORT);
} }
toast.setText(msg); text.setText(msg);
Boolean sent = false;
// final Handler handler = new Handler();
// final Runnable run = new Runnable() {
//
// @Override
// public void run() {
// try {
// result.success(false);
//
// } catch (Exception e){
// e.printStackTrace();
// }
// }
// };
toast.setView(layout);
switch (gravity) { switch (gravity) {
case "top": case "top":
...@@ -79,59 +73,58 @@ public class FluttertoastPlugin implements MethodCallHandler { ...@@ -79,59 +73,58 @@ public class FluttertoastPlugin implements MethodCallHandler {
toast.setGravity(Gravity.BOTTOM, 0, 100); toast.setGravity(Gravity.BOTTOM, 0, 100);
} }
final TextView text = toast.getView().findViewById(android.R.id.message); if (textSize != null)
if(textSize != null)
text.setTextSize(textSize.floatValue()); text.setTextSize(textSize.floatValue());
if(bgcolor != null) {
Drawable shapeDrawable; Drawable shapeDrawable;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
shapeDrawable = ctx.getResources().getDrawable(R.drawable.toast_bg,ctx.getTheme()); shapeDrawable = ctx.getResources().getDrawable(R.drawable.toast_bg, ctx.getTheme());
} else { } else {
shapeDrawable = ctx.getResources().getDrawable(R.drawable.toast_bg); shapeDrawable = ctx.getResources().getDrawable(R.drawable.toast_bg);
} }
if (shapeDrawable != null) { if (bgcolor != null) {
shapeDrawable.setColorFilter(bgcolor.intValue(), PorterDuff.Mode.SRC_IN); shapeDrawable.setColorFilter(bgcolor.intValue(), PorterDuff.Mode.SRC_IN);
if (Build.VERSION.SDK_INT <= 27) {
toast.getView().setBackground(shapeDrawable);
} else {
toast.getView().setBackground(null);
text.setBackground(shapeDrawable);
} }
}
} layout.setBackground(shapeDrawable);
// text.setOnTouchListener(new View.OnTouchListener() {
// @Override // if(bgcolor != null) {
// public boolean onTouch(View v, MotionEvent event) { // Drawable shapeDrawable;
// handler.removeCallbacks(run); // if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
// text.setOnTouchListener(null); // shapeDrawable = ctx.getResources().getDrawable(R.drawable.toast_bg,ctx.getTheme());
// toast.cancel(); // } else {
// try { // shapeDrawable = ctx.getResources().getDrawable(R.drawable.toast_bg);
// result.success(true);
// } catch (Exception e){
// e.printStackTrace();
// } // }
// //
// return false; // if (shapeDrawable != null) {
// shapeDrawable.setColorFilter(bgcolor.intValue(), PorterDuff.Mode.SRC_IN);
// if (Build.VERSION.SDK_INT <= 27) {
// toast.getView().setBackground(shapeDrawable);
// } else {
// toast.getView().setBackground(null);
// text.setBackground(shapeDrawable);
// }
// }
// } // }
// });
if(textcolor != null) { if (textcolor != null) {
text.setTextColor(textcolor.intValue()); text.setTextColor(textcolor.intValue());
} }
toast.show(); toast.show();
result.success(true); result.success(true);
// handler.postDelayed(run,toast.getDuration()*1000);
} else if(call.method.equals("cancel")){ break;
if(toast != null) case "cancel":
if (toast != null)
toast.cancel(); toast.cancel();
result.success(true); result.success(true);
} else { break;
default:
result.notImplemented(); result.notImplemented();
break;
} }
} }
} }
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/custom_toast_container"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="8dp"
android:background="#DAAA"
>
<TextView android:id="@+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#FFF"
/>
</LinearLayout>
\ No newline at end of file
name: fluttertoast name: fluttertoast
description: Toast Library for FLutter description: Toast Library for FLutter
version: 3.0.3 version: 3.0.4
author: Karthik Ponnam <ponnamkarthik3@gmail.com> author: Karthik Ponnam <ponnamkarthik3@gmail.com>
homepage: https://github.com/PonnamKarthik/FlutterToast homepage: https://github.com/PonnamKarthik/FlutterToast
...@@ -20,7 +20,6 @@ flutter: ...@@ -20,7 +20,6 @@ flutter:
plugin: plugin:
androidPackage: io.github.ponnamkarthik.toast.fluttertoast androidPackage: io.github.ponnamkarthik.toast.fluttertoast
pluginClass: FluttertoastPlugin pluginClass: FluttertoastPlugin
# To add assets to your plugin package, add an assets section, like this: # To add assets to your plugin package, add an assets section, like this:
# assets: # assets:
# - images/a_dot_burr.jpeg # - images/a_dot_burr.jpeg
...@@ -31,7 +30,6 @@ flutter: ...@@ -31,7 +30,6 @@ flutter:
# #
# An image asset can refer to one or more resolution-specific "variants", see # An image asset can refer to one or more resolution-specific "variants", see
# https://flutter.io/assets-and-images/#resolution-aware. # https://flutter.io/assets-and-images/#resolution-aware.
# To add custom fonts to your plugin package, add a fonts section here, # To add custom fonts to your plugin package, add a fonts section here,
# in this "flutter" section. Each entry in this list should have a # in this "flutter" section. Each entry in this list should have a
# "family" key with the font family name, and a "fonts" key with a # "family" key with the font family name, and a "fonts" key with a
......
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