Commit 77560d80 by Karthik

v3.0.4

parent e58dde0b
## [3.0.4]
- Android Color fix
## [3.0.3]
* fixed Android Toast.LENGTH_*
- fixed Android Toast.LENGTH\_\*
## [3.0.2]
* fixed #70 #71
- fixed #70 #71
## [3.0.1]
* Release build failed fix
* Multiline text android fix
- Release build failed fix
- Multiline text android fix
## [3.0.0]
* Migrated to AndroidX
- Migrated to AndroidX
## [2.2.12]
* Incomplete Text Fix
- Incomplete Text Fix
## [2.2.11]
* Incomplete Text Fix
- Incomplete Text Fix
## [2.2.10]
* iOS build Failed fix
- iOS build Failed fix
## [2.2.9]
* iOS build Failed fix
- iOS build Failed fix
## [2.2.8]
* `Fluttertoast.cancel()` added
* FlutterToast Implementation revert back to previous
- `Fluttertoast.cancel()` added
- FlutterToast Implementation revert back to previous
## [2.2.7]
* FontSize Can be changed
* FlutterToast Implementation Changed to `FlutterToast.instance`
- FontSize Can be changed
- FlutterToast Implementation Changed to `FlutterToast.instance`
## [2.2.6]
* removed androidx
- removed androidx
## [2.2.5]
* Cannot build because of dependency w/ v28 #47
- Cannot build because of dependency w/ v28 #47
## [2.2.4]
* androidX crash fix #45
- androidX crash fix #45
## [2.2.3]
* iOS Crash fix #41 & #39
- iOS Crash fix #41 & #39
## [2.2.1]
* default toast style fix #38
- default toast style fix #38
## [2.2.0]
* Background color fixed #29
- Background color fixed #29
## [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]
* Merged PR #32
- Merged PR #32
## [2.1.2]
* iOS Color Fix
* Background color fix in PIE
- iOS Color Fix
- Background color fix in PIE
## [2.1.1]
* Background color does not fill the whole Toast fixed
- Background color does not fill the whole Toast fixed
## [2.1.0]
* build error fixed
- build error fixed
## [2.0.9]
* fix error in flutter 0.9.7
- fix error in flutter 0.9.7
## [2.0.8]
* Build failed with an exception fixed
* The plugin calls the build of the previous widget fixed
* Screenshots added
- Build failed with an exception fixed
- The plugin calls the build of the previous widget fixed
- Screenshots added
## [2.0.7]
* Text background fix for android
- Text background fix for android
## [2.0.6]
* iOS Release build error fixed
- iOS Release build error fixed
## [2.0.3]
* iOs run time error fixed
- iOs run time error fixed
## [2.0.2]
* iOs build error fixed
- iOs build error fixed
## [2.0.1]
* Ios Support added
* option for setting toast gravity (top, center, bottom)
- Ios Support added
- option for setting toast gravity (top, center, bottom)
## [1.0.1]
* Initial Open Sources
* show Toast in Android
- Initial Open Sources
- show Toast in Android
# [fluttertoast](https://pub.dartlang.org/packages/fluttertoast)
Android and iOS Toast Library for Flutter
> Supported Platforms
> * Android
> * IOS
>
> - Android
> - IOS
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
# add this line to your dependencies
fluttertoast: ^3.0.3
fluttertoast: ^3.0.4
```
```dart
......@@ -32,16 +32,15 @@ Fluttertoast.showToast(
);
```
property | description
--------|------------
msg | String (Not Null)(required)
toastLength| Toast.LENGTH_SHORT or Toast.LENGTH_LONG (optional)
gravity | ToastGravity.TOP (or) ToastGravity.CENTER (or) ToastGravity.BOTTOM
timeInSecForIos | int (only for ios)
bgcolor | Colors.red
textcolor| Colors.white
fontSize | 16.0 (float)
| property | description |
| --------------- | ------------------------------------------------------------------ |
| msg | String (Not Null)(required) |
| toastLength | Toast.LENGTH_SHORT or Toast.LENGTH_LONG (optional) |
| gravity | ToastGravity.TOP (or) ToastGravity.CENTER (or) ToastGravity.BOTTOM |
| timeInSecForIos | int (only for ios) |
| bgcolor | Colors.red |
| textcolor | Colors.white |
| fontSize | 16.0 (float) |
### To cancel all the toasts call
......@@ -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/4.png" width="320px" />
## If you need any features suggest
......@@ -32,3 +32,6 @@ android {
disable 'InvalidPackage'
}
}
dependencies {
// implementation fileTree(dir: 'libs', include: ['*.jar'])
}
#Thu Apr 18 06:25:50 IST 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
......@@ -4,10 +4,8 @@ import android.content.Context;
import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Handler;
import android.util.Log;
import android.view.Gravity;
import android.view.MotionEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;
......@@ -21,10 +19,10 @@ import io.flutter.plugin.common.PluginRegistry.Registrar;
/** FluttertoastPlugin */
public class FluttertoastPlugin implements MethodCallHandler {
Context ctx;
Toast toast;
private Context ctx;
private Toast toast;
FluttertoastPlugin(Context context) {
private FluttertoastPlugin(Context context) {
ctx = context;
}
......@@ -36,7 +34,8 @@ public class FluttertoastPlugin implements MethodCallHandler {
@Override
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 length = call.argument("length").toString();
String gravity = call.argument("gravity").toString();
......@@ -44,29 +43,24 @@ public class FluttertoastPlugin implements MethodCallHandler {
Number textcolor = call.argument("textcolor");
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 {
toast = Toast.makeText(ctx, msg, Toast.LENGTH_SHORT);
toast.setDuration(Toast.LENGTH_SHORT);
}
toast.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();
// }
// }
// };
text.setText(msg);
toast.setView(layout);
switch (gravity) {
case "top":
......@@ -79,59 +73,58 @@ public class FluttertoastPlugin implements MethodCallHandler {
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());
if(bgcolor != null) {
Drawable shapeDrawable;
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 {
shapeDrawable = ctx.getResources().getDrawable(R.drawable.toast_bg);
}
if (shapeDrawable != null) {
if (bgcolor != 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);
}
}
}
// text.setOnTouchListener(new View.OnTouchListener() {
// @Override
// public boolean onTouch(View v, MotionEvent event) {
// handler.removeCallbacks(run);
// text.setOnTouchListener(null);
// toast.cancel();
// try {
// result.success(true);
// } catch (Exception e){
// e.printStackTrace();
layout.setBackground(shapeDrawable);
// if(bgcolor != null) {
// Drawable shapeDrawable;
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
// shapeDrawable = ctx.getResources().getDrawable(R.drawable.toast_bg,ctx.getTheme());
// } else {
// shapeDrawable = ctx.getResources().getDrawable(R.drawable.toast_bg);
// }
//
// 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());
}
toast.show();
result.success(true);
// handler.postDelayed(run,toast.getDuration()*1000);
} else if(call.method.equals("cancel")){
if(toast != null)
break;
case "cancel":
if (toast != null)
toast.cancel();
result.success(true);
} else {
break;
default:
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
description: Toast Library for FLutter
version: 3.0.3
version: 3.0.4
author: Karthik Ponnam <ponnamkarthik3@gmail.com>
homepage: https://github.com/PonnamKarthik/FlutterToast
......@@ -20,7 +20,6 @@ flutter:
plugin:
androidPackage: io.github.ponnamkarthik.toast.fluttertoast
pluginClass: FluttertoastPlugin
# To add assets to your plugin package, add an assets section, like this:
# assets:
# - images/a_dot_burr.jpeg
......@@ -31,7 +30,6 @@ flutter:
#
# An image asset can refer to one or more resolution-specific "variants", see
# https://flutter.io/assets-and-images/#resolution-aware.
# 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
# "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