Commit 6b2987a0 by Karthik

Background color fixed

parent 79302e64
## [2.2.0]
* 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
...@@ -8,7 +12,7 @@ ...@@ -8,7 +12,7 @@
## [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]
......
...@@ -11,7 +11,7 @@ Android Toast Library for Flutter ...@@ -11,7 +11,7 @@ Android Toast Library for Flutter
```yaml ```yaml
# add this line to your dependencies # add this line to your dependencies
fluttertoast: ^2.1.5 fluttertoast: ^2.2.0
``` ```
```dart ```dart
......
...@@ -32,3 +32,7 @@ android { ...@@ -32,3 +32,7 @@ android {
disable 'InvalidPackage' disable 'InvalidPackage'
} }
} }
dependencies {
implementation 'com.android.support:appcompat-v7:27.1.1'
}
package io.github.ponnamkarthik.toast.fluttertoast; package io.github.ponnamkarthik.toast.fluttertoast;
import io.flutter.plugin.common.MethodCall;
import io.flutter.plugin.common.MethodChannel;
import io.flutter.plugin.common.MethodChannel.MethodCallHandler;
import io.flutter.plugin.common.MethodChannel.Result;
import io.flutter.plugin.common.PluginRegistry.Registrar;
import android.content.Context; import android.content.Context;
import android.content.ContextWrapper;
import android.graphics.Color; import android.graphics.Color;
import android.graphics.Paint; import android.graphics.PorterDuff;
import android.graphics.drawable.ShapeDrawable; import android.graphics.drawable.Drawable;
import android.graphics.drawable.shapes.RoundRectShape; import android.os.Build;
import android.support.v4.content.ContextCompat;
import android.view.Gravity; import android.view.Gravity;
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.MethodChannel;
import io.flutter.plugin.common.MethodChannel.MethodCallHandler;
import io.flutter.plugin.common.MethodChannel.Result;
import io.flutter.plugin.common.PluginRegistry.Registrar;
/** FluttertoastPlugin */ /** FluttertoastPlugin */
public class FluttertoastPlugin implements MethodCallHandler { public class FluttertoastPlugin implements MethodCallHandler {
...@@ -67,22 +70,18 @@ public class FluttertoastPlugin implements MethodCallHandler { ...@@ -67,22 +70,18 @@ public class FluttertoastPlugin implements MethodCallHandler {
defaultTextColor = text.getCurrentTextColor(); defaultTextColor = text.getCurrentTextColor();
} }
try { if(bgcolor != null) {
RoundRectShape rectShape = new RoundRectShape(new float[] {100f, 100f, 100f, 100f, 100f, 100f, 100f, 100f}, null, null); Drawable shapeDrawable = ContextCompat.getDrawable(ctx, R.drawable.toast_bg);
ShapeDrawable shapeDrawable = new ShapeDrawable(rectShape); if (shapeDrawable != null) {
shapeDrawable.getPaint().setColor(bgcolor != null ? bgcolor.intValue() : Color.BLACK); shapeDrawable.setColorFilter(bgcolor.intValue(), PorterDuff.Mode.SRC_IN);
shapeDrawable.getPaint().setStyle(Paint.Style.FILL); if (Build.VERSION.SDK_INT <= 27) {
shapeDrawable.getPaint().setAntiAlias(true); toast.getView().setBackground(shapeDrawable);
shapeDrawable.getPaint().setFlags(Paint.ANTI_ALIAS_FLAG); } else {
text.setBackground(shapeDrawable);
if (android.os.Build.VERSION.SDK_INT <= 27) { }
toast.getView().setBackground(shapeDrawable);
} else {
text.setBackground(shapeDrawable);
} }
} catch (Exception e) {
e.printStackTrace();
} }
try { try {
......
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<corners
android:radius="100dp">
</corners>
<solid
android:color="#000000">
</solid>
<padding
android:left="24dp"
android:top="15dp"
android:right="24dp"
android:bottom="15dp" />
</shape>
\ No newline at end of file
name: fluttertoast name: fluttertoast
description: Toast Library for FLutter description: Toast Library for FLutter
version: 2.1.5 version: 2.2.0
author: Karthik Ponnam <ponnamkarthik3@gmail.com> author: Karthik Ponnam <ponnamkarthik3@gmail.com>
homepage: https://github.com/PonnamKarthik/FlutterToast homepage: https://github.com/PonnamKarthik/FlutterToast
......
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