Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
fluttertoast
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
songyanzhi
fluttertoast
Commits
6763e42f
Commit
6763e42f
authored
Nov 22, 2020
by
Karthik Ponnam
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Android Default bg when textSize & textColor are set
parent
b66584c6
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
13 deletions
+41
-13
android/src/main/kotlin/io/github/ponnamkarthik/toast/fluttertoast/MethodCallHandlerImpl.kt
+8
-1
example/lib/toast_no_context.dart
+33
-9
pubspec.yaml
+0
-3
No files found.
android/src/main/kotlin/io/github/ponnamkarthik/toast/fluttertoast/MethodCallHandlerImpl.kt
View file @
6763e42f
...
...
@@ -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
->
{
...
...
example/lib/toast_no_context.dart
View file @
6763e42f
...
...
@@ -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
),
...
...
pubspec.yaml
View file @
6763e42f
...
...
@@ -25,6 +25,3 @@ flutter:
web
:
pluginClass
:
FluttertoastWebPlugin
fileName
:
fluttertoast_web.dart
assets
:
-
assets/
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment