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 { ...@@ -38,7 +38,7 @@ internal class MethodCallHandlerImpl(var context: Context) : MethodCallHandler {
} else { } else {
Toast.LENGTH_SHORT 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 layout = (context.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater).inflate(R.layout.toast_custom, null)
val text = layout.findViewById<TextView>(R.id.text) val text = layout.findViewById<TextView>(R.id.text)
text.text = mMessage text.text = mMessage
...@@ -63,6 +63,13 @@ internal class MethodCallHandlerImpl(var context: Context) : MethodCallHandler { ...@@ -63,6 +63,13 @@ internal class MethodCallHandlerImpl(var context: Context) : MethodCallHandler {
mToast.view = layout mToast.view = layout
} else { } else {
mToast = Toast.makeText(context, mMessage, mDuration) 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) { when (mGravity) {
Gravity.CENTER -> { Gravity.CENTER -> {
......
...@@ -6,6 +6,7 @@ class ToastNoContext extends StatelessWidget { ...@@ -6,6 +6,7 @@ class ToastNoContext extends StatelessWidget {
Fluttertoast.showToast( Fluttertoast.showToast(
msg: "This is Long Toast", msg: "This is Long Toast",
toastLength: Toast.LENGTH_LONG, toastLength: Toast.LENGTH_LONG,
fontSize: 18.0,
); );
} }
...@@ -28,15 +29,26 @@ class ToastNoContext extends StatelessWidget { ...@@ -28,15 +29,26 @@ class ToastNoContext extends StatelessWidget {
} }
void showShortToast() { 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() { 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() { 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() { void cancelToast() {
...@@ -55,27 +67,39 @@ class ToastNoContext extends StatelessWidget { ...@@ -55,27 +67,39 @@ class ToastNoContext extends StatelessWidget {
children: <Widget>[ children: <Widget>[
new Padding( new Padding(
padding: const EdgeInsets.all(10.0), 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( new Padding(
padding: const EdgeInsets.all(10.0), 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( new Padding(
padding: const EdgeInsets.all(10.0), 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( new Padding(
padding: const EdgeInsets.all(10.0), 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( new Padding(
padding: const EdgeInsets.all(10.0), 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( new Padding(
padding: const EdgeInsets.all(10.0), 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( new Padding(
padding: const EdgeInsets.all(10.0), padding: const EdgeInsets.all(10.0),
......
...@@ -25,6 +25,3 @@ flutter: ...@@ -25,6 +25,3 @@ flutter:
web: web:
pluginClass: FluttertoastWebPlugin pluginClass: FluttertoastWebPlugin
fileName: fluttertoast_web.dart 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