Commit 6763e42f by Karthik Ponnam

Android Default bg when textSize & textColor are set

parent b66584c6
......@@ -38,7 +38,7 @@ internal class MethodCallHandlerImpl(var context: Context) : MethodCallHandler {
} else {
Toast.LENGTH_SHORT
}
if (bgcolor != null || textcolor != null || textSize != null) {
if (bgcolor != null) {
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
......@@ -63,6 +63,13 @@ internal class MethodCallHandlerImpl(var context: Context) : MethodCallHandler {
mToast.view = layout
} else {
mToast = Toast.makeText(context, mMessage, mDuration)
val textView: TextView = mToast.view.findViewById(android.R.id.message)
if(textSize != null) {
textView.textSize = textSize.toFloat()
}
if (textcolor != null) {
textView.setTextColor(textcolor.toInt())
}
}
when (mGravity) {
Gravity.CENTER -> {
......
......@@ -6,6 +6,7 @@ class ToastNoContext extends StatelessWidget {
Fluttertoast.showToast(
msg: "This is Long Toast",
toastLength: Toast.LENGTH_LONG,
fontSize: 18.0,
);
}
......@@ -28,15 +29,26 @@ class ToastNoContext extends StatelessWidget {
}
void showShortToast() {
Fluttertoast.showToast(msg: "This is Short Toast", toastLength: Toast.LENGTH_SHORT, timeInSecForIosWeb: 1);
Fluttertoast.showToast(
msg: "This is Short Toast",
toastLength: Toast.LENGTH_SHORT,
timeInSecForIosWeb: 1);
}
void showTopShortToast() {
Fluttertoast.showToast(msg: "This is Top Short Toast", toastLength: Toast.LENGTH_SHORT, gravity: ToastGravity.TOP, timeInSecForIosWeb: 1);
Fluttertoast.showToast(
msg: "This is Top Short Toast",
toastLength: Toast.LENGTH_SHORT,
gravity: ToastGravity.TOP,
timeInSecForIosWeb: 1);
}
void showCenterShortToast() {
Fluttertoast.showToast(msg: "This is Center Short Toast", toastLength: Toast.LENGTH_SHORT, gravity: ToastGravity.CENTER, timeInSecForIosWeb: 1);
Fluttertoast.showToast(
msg: "This is Center Short Toast",
toastLength: Toast.LENGTH_SHORT,
gravity: ToastGravity.CENTER,
timeInSecForIosWeb: 1);
}
void cancelToast() {
......@@ -55,27 +67,39 @@ class ToastNoContext extends StatelessWidget {
children: <Widget>[
new Padding(
padding: const EdgeInsets.all(10.0),
child: new RaisedButton(child: new Text('Show Long Toast'), onPressed: showLongToast),
child: new RaisedButton(
child: new Text('Show Long Toast'),
onPressed: showLongToast),
),
new Padding(
padding: const EdgeInsets.all(10.0),
child: new RaisedButton(child: new Text('Show Short Toast'), onPressed: showShortToast),
child: new RaisedButton(
child: new Text('Show Short Toast'),
onPressed: showShortToast),
),
new Padding(
padding: const EdgeInsets.all(10.0),
child: new RaisedButton(child: new Text('Show Center Short Toast'), onPressed: showCenterShortToast),
child: new RaisedButton(
child: new Text('Show Center Short Toast'),
onPressed: showCenterShortToast),
),
new Padding(
padding: const EdgeInsets.all(10.0),
child: new RaisedButton(child: new Text('Show Top Short Toast'), onPressed: showTopShortToast),
child: new RaisedButton(
child: new Text('Show Top Short Toast'),
onPressed: showTopShortToast),
),
new Padding(
padding: const EdgeInsets.all(10.0),
child: new RaisedButton(child: new Text('Show Colored Toast'), onPressed: showColoredToast),
child: new RaisedButton(
child: new Text('Show Colored Toast'),
onPressed: showColoredToast),
),
new Padding(
padding: const EdgeInsets.all(10.0),
child: new RaisedButton(child: new Text('Show Web Colored Toast'), onPressed: showWebColoredToast),
child: new RaisedButton(
child: new Text('Show Web Colored Toast'),
onPressed: showWebColoredToast),
),
new Padding(
padding: const EdgeInsets.all(10.0),
......
......@@ -25,6 +25,3 @@ flutter:
web:
pluginClass: FluttertoastWebPlugin
fileName: fluttertoast_web.dart
assets:
- assets/
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