Commit 6b2987a0 by Karthik

Background color fixed

parent 79302e64
## [2.2.0]
* Background color fixed #29
## [2.1.5]
* Merged PR #36 - Fix Number Cast Error for issue #35
......@@ -8,7 +12,7 @@
## [2.1.2]
*iOS Color Fix
* iOS Color Fix
* Background color fix in PIE
## [2.1.1]
......
......@@ -11,7 +11,7 @@ Android Toast Library for Flutter
```yaml
# add this line to your dependencies
fluttertoast: ^2.1.5
fluttertoast: ^2.2.0
```
```dart
......
......@@ -32,3 +32,7 @@ android {
disable 'InvalidPackage'
}
}
dependencies {
implementation 'com.android.support:appcompat-v7:27.1.1'
}
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.ContextWrapper;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.drawable.ShapeDrawable;
import android.graphics.drawable.shapes.RoundRectShape;
import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.support.v4.content.ContextCompat;
import android.view.Gravity;
import android.widget.TextView;
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 */
public class FluttertoastPlugin implements MethodCallHandler {
......@@ -67,22 +70,18 @@ public class FluttertoastPlugin implements MethodCallHandler {
defaultTextColor = text.getCurrentTextColor();
}
try {
RoundRectShape rectShape = new RoundRectShape(new float[] {100f, 100f, 100f, 100f, 100f, 100f, 100f, 100f}, null, null);
ShapeDrawable shapeDrawable = new ShapeDrawable(rectShape);
shapeDrawable.getPaint().setColor(bgcolor != null ? bgcolor.intValue() : Color.BLACK);
shapeDrawable.getPaint().setStyle(Paint.Style.FILL);
shapeDrawable.getPaint().setAntiAlias(true);
shapeDrawable.getPaint().setFlags(Paint.ANTI_ALIAS_FLAG);
if (android.os.Build.VERSION.SDK_INT <= 27) {
toast.getView().setBackground(shapeDrawable);
} else {
text.setBackground(shapeDrawable);
if(bgcolor != null) {
Drawable shapeDrawable = ContextCompat.getDrawable(ctx, R.drawable.toast_bg);
if (shapeDrawable != null) {
shapeDrawable.setColorFilter(bgcolor.intValue(), PorterDuff.Mode.SRC_IN);
if (Build.VERSION.SDK_INT <= 27) {
toast.getView().setBackground(shapeDrawable);
} else {
text.setBackground(shapeDrawable);
}
}
} catch (Exception e) {
e.printStackTrace();
}
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
description: Toast Library for FLutter
version: 2.1.5
version: 2.2.0
author: Karthik Ponnam <ponnamkarthik3@gmail.com>
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