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
77560d80
Commit
77560d80
authored
Apr 18, 2019
by
Karthik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
v3.0.4
parent
e58dde0b
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
165 additions
and
152 deletions
+165
-152
CHANGELOG.md
+41
-37
README.md
+14
-16
android/build.gradle
+3
-0
android/gradle/wrapper/gradle-wrapper.properties
+2
-1
android/libs/flutter.jar
+0
-0
android/src/main/java/io/github/ponnamkarthik/toast/fluttertoast/FluttertoastPlugin.java
+86
-93
android/src/main/res/layout/toast_custom.xml
+16
-0
example/lib/main.dart
+2
-2
pubspec.yaml
+1
-3
No files found.
CHANGELOG.md
View file @
77560d80
## [3.0.4]
-
Android Color fix
## [3.0.3]
## [3.0.3]
*
fixed Android Toast.LENGTH_
*
-
fixed Android Toast.LENGTH
\_\
*
## [3.0.2]
## [3.0.2]
*
fixed #70 #71
-
fixed #70 #71
## [3.0.1]
## [3.0.1]
*
Release build failed fix
-
Release build failed fix
*
Multiline text android fix
-
Multiline text android fix
## [3.0.0]
## [3.0.0]
*
Migrated to AndroidX
-
Migrated to AndroidX
## [2.2.12]
## [2.2.12]
*
Incomplete Text Fix
-
Incomplete Text Fix
## [2.2.11]
## [2.2.11]
*
Incomplete Text Fix
-
Incomplete Text Fix
## [2.2.10]
## [2.2.10]
*
iOS build Failed fix
-
iOS build Failed fix
## [2.2.9]
## [2.2.9]
*
iOS build Failed fix
-
iOS build Failed fix
## [2.2.8]
## [2.2.8]
*
`Fluttertoast.cancel()`
added
-
`Fluttertoast.cancel()`
added
*
FlutterToast Implementation revert back to previous
-
FlutterToast Implementation revert back to previous
## [2.2.7]
## [2.2.7]
*
FontSize Can be changed
-
FontSize Can be changed
*
FlutterToast Implementation Changed to
`FlutterToast.instance`
-
FlutterToast Implementation Changed to
`FlutterToast.instance`
## [2.2.6]
## [2.2.6]
*
removed androidx
-
removed androidx
## [2.2.5]
## [2.2.5]
*
Cannot build because of dependency w/ v28 #47
-
Cannot build because of dependency w/ v28 #47
## [2.2.4]
## [2.2.4]
*
androidX crash fix #45
-
androidX crash fix #45
## [2.2.3]
## [2.2.3]
*
iOS Crash fix #41 & #39
-
iOS Crash fix #41 & #39
## [2.2.1]
## [2.2.1]
*
default toast style fix #38
-
default toast style fix #38
## [2.2.0]
## [2.2.0]
*
Background color fixed #29
-
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
## [2.1.4]
## [2.1.4]
*
Merged PR #32
-
Merged PR #32
## [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]
*
Background color does not fill the whole Toast fixed
-
Background color does not fill the whole Toast fixed
## [2.1.0]
## [2.1.0]
*
build error fixed
-
build error fixed
## [2.0.9]
## [2.0.9]
*
fix error in flutter 0.9.7
-
fix error in flutter 0.9.7
## [2.0.8]
## [2.0.8]
*
Build failed with an exception fixed
-
Build failed with an exception fixed
*
The plugin calls the build of the previous widget fixed
-
The plugin calls the build of the previous widget fixed
*
Screenshots added
-
Screenshots added
## [2.0.7]
## [2.0.7]
*
Text background fix for android
-
Text background fix for android
## [2.0.6]
## [2.0.6]
*
iOS Release build error fixed
-
iOS Release build error fixed
## [2.0.3]
## [2.0.3]
*
iOs run time error fixed
-
iOs run time error fixed
## [2.0.2]
## [2.0.2]
*
iOs build error fixed
-
iOs build error fixed
## [2.0.1]
## [2.0.1]
*
Ios Support added
-
Ios Support added
*
option for setting toast gravity (top, center, bottom)
-
option for setting toast gravity (top, center, bottom)
## [1.0.1]
## [1.0.1]
*
Initial Open Sources
-
Initial Open Sources
*
show Toast in Android
-
show Toast in Android
README.md
View file @
77560d80
# [fluttertoast](https://pub.dartlang.org/packages/fluttertoast)
# [fluttertoast](https://pub.dartlang.org/packages/fluttertoast)
Android and iOS Toast Library for Flutter
Android and iOS Toast Library for Flutter
> Supported Platforms
> Supported Platforms
> * Android
>
> * IOS
> - Android
> - IOS
If you dont want to use androidx then use
`fluttertoast`
version
`2.2.11`
If you dont want to use androidx then use
`fluttertoast`
version
`2.2.11`
...
@@ -13,7 +13,7 @@ If you dont want to use androidx then use `fluttertoast` version `2.2.11`
...
@@ -13,7 +13,7 @@ If you dont want to use androidx then use `fluttertoast` version `2.2.11`
```
yaml
```
yaml
# add this line to your dependencies
# add this line to your dependencies
fluttertoast
:
^3.0.
3
fluttertoast
:
^3.0.
4
```
```
```
dart
```
dart
...
@@ -32,16 +32,15 @@ Fluttertoast.showToast(
...
@@ -32,16 +32,15 @@ Fluttertoast.showToast(
);
);
```
```
property | description
| property | description |
--------|------------
| --------------- | ------------------------------------------------------------------ |
msg | String (Not Null)(required)
| msg | String (Not Null)(required) |
toastLength| Toast.LENGTH_SHORT or Toast.LENGTH_LONG (optional)
| toastLength | Toast.LENGTH_SHORT or Toast.LENGTH_LONG (optional) |
gravity | ToastGravity.TOP (or) ToastGravity.CENTER (or) ToastGravity.BOTTOM
| gravity | ToastGravity.TOP (or) ToastGravity.CENTER (or) ToastGravity.BOTTOM |
timeInSecForIos | int (only for ios)
| timeInSecForIos | int (only for ios) |
bgcolor | Colors.red
| bgcolor | Colors.red |
textcolor| Colors.white
| textcolor | Colors.white |
fontSize | 16.0 (float)
| fontSize | 16.0 (float) |
### To cancel all the toasts call
### To cancel all the toasts call
...
@@ -56,5 +55,4 @@ Fluttertoast.cancel()
...
@@ -56,5 +55,4 @@ Fluttertoast.cancel()
<img
src=
"https://raw.githubusercontent.com/PonnamKarthik/FlutterToast/master/screenshot/3.png"
width=
"320px"
/>
<img
src=
"https://raw.githubusercontent.com/PonnamKarthik/FlutterToast/master/screenshot/3.png"
width=
"320px"
/>
<img
src=
"https://raw.githubusercontent.com/PonnamKarthik/FlutterToast/master/screenshot/4.png"
width=
"320px"
/>
<img
src=
"https://raw.githubusercontent.com/PonnamKarthik/FlutterToast/master/screenshot/4.png"
width=
"320px"
/>
## If you need any features suggest
## If you need any features suggest
android/build.gradle
View file @
77560d80
...
@@ -32,3 +32,6 @@ android {
...
@@ -32,3 +32,6 @@ android {
disable
'InvalidPackage'
disable
'InvalidPackage'
}
}
}
}
dependencies
{
// implementation fileTree(dir: 'libs', include: ['*.jar'])
}
android/gradle/wrapper/gradle-wrapper.properties
View file @
77560d80
#Thu Apr 18 06:25:50 IST 2019
distributionBase
=
GRADLE_USER_HOME
distributionBase
=
GRADLE_USER_HOME
distributionPath
=
wrapper/dists
distributionPath
=
wrapper/dists
distributionUrl
=
https
\:
//services.gradle.org/distributions/gradle-4.6-all.zip
zipStoreBase
=
GRADLE_USER_HOME
zipStoreBase
=
GRADLE_USER_HOME
zipStorePath
=
wrapper/dists
zipStorePath
=
wrapper/dists
distributionUrl
=
https
\:
//services.gradle.org/distributions/gradle-5.1.1-all.zip
android/libs/flutter.jar
0 → 100644
View file @
77560d80
File added
android/src/main/java/io/github/ponnamkarthik/toast/fluttertoast/FluttertoastPlugin.java
View file @
77560d80
...
@@ -4,10 +4,8 @@ import android.content.Context;
...
@@ -4,10 +4,8 @@ import android.content.Context;
import
android.graphics.PorterDuff
;
import
android.graphics.PorterDuff
;
import
android.graphics.drawable.Drawable
;
import
android.graphics.drawable.Drawable
;
import
android.os.Build
;
import
android.os.Build
;
import
android.os.Handler
;
import
android.util.Log
;
import
android.view.Gravity
;
import
android.view.Gravity
;
import
android.view.
MotionEvent
;
import
android.view.
LayoutInflater
;
import
android.view.View
;
import
android.view.View
;
import
android.widget.TextView
;
import
android.widget.TextView
;
import
android.widget.Toast
;
import
android.widget.Toast
;
...
@@ -21,10 +19,10 @@ import io.flutter.plugin.common.PluginRegistry.Registrar;
...
@@ -21,10 +19,10 @@ import io.flutter.plugin.common.PluginRegistry.Registrar;
/** FluttertoastPlugin */
/** FluttertoastPlugin */
public
class
FluttertoastPlugin
implements
MethodCallHandler
{
public
class
FluttertoastPlugin
implements
MethodCallHandler
{
Context
ctx
;
private
Context
ctx
;
Toast
toast
;
private
Toast
toast
;
FluttertoastPlugin
(
Context
context
)
{
private
FluttertoastPlugin
(
Context
context
)
{
ctx
=
context
;
ctx
=
context
;
}
}
...
@@ -36,102 +34,97 @@ public class FluttertoastPlugin implements MethodCallHandler {
...
@@ -36,102 +34,97 @@ public class FluttertoastPlugin implements MethodCallHandler {
@Override
@Override
public
void
onMethodCall
(
MethodCall
call
,
final
Result
result
)
{
public
void
onMethodCall
(
MethodCall
call
,
final
Result
result
)
{
if
(
call
.
method
.
equals
(
"showToast"
))
{
switch
(
call
.
method
)
{
String
msg
=
call
.
argument
(
"msg"
).
toString
();
case
"showToast"
:
String
length
=
call
.
argument
(
"length"
).
toString
();
String
msg
=
call
.
argument
(
"msg"
).
toString
();
String
gravity
=
call
.
argument
(
"gravity"
).
toString
();
String
length
=
call
.
argument
(
"length"
).
toString
();
Number
bgcolor
=
call
.
argument
(
"bgcolor"
);
String
gravity
=
call
.
argument
(
"gravity"
).
toString
();
Number
textcolor
=
call
.
argument
(
"textcolor"
);
Number
bgcolor
=
call
.
argument
(
"bgcolor"
);
Number
textSize
=
call
.
argument
(
"fontSize"
);
Number
textcolor
=
call
.
argument
(
"textcolor"
);
Number
textSize
=
call
.
argument
(
"fontSize"
);
if
(
length
.
equals
(
"long"
))
{
toast
=
Toast
.
makeText
(
ctx
,
msg
,
Toast
.
LENGTH_LONG
);
}
else
{
LayoutInflater
inflater
=
(
LayoutInflater
)
ctx
.
getSystemService
(
Context
.
LAYOUT_INFLATER_SERVICE
);
toast
=
Toast
.
makeText
(
ctx
,
msg
,
Toast
.
LENGTH_SHORT
);
View
layout
=
inflater
.
inflate
(
R
.
layout
.
toast_custom
,
null
);
}
TextView
text
=
layout
.
findViewById
(
R
.
id
.
text
);
toast
.
setText
(
msg
);
toast
=
new
Toast
(
ctx
);
Boolean
sent
=
false
;
// final Handler handler = new Handler();
// final Runnable run = new Runnable() {
if
(
length
.
equals
(
"long"
))
{
//
toast
.
setDuration
(
Toast
.
LENGTH_LONG
);
// @Override
}
else
{
// public void run() {
toast
.
setDuration
(
Toast
.
LENGTH_SHORT
);
// try {
}
// result.success(false);
//
text
.
setText
(
msg
);
// } catch (Exception e){
// e.printStackTrace();
toast
.
setView
(
layout
);
// }
// }
switch
(
gravity
)
{
// };
case
"top"
:
toast
.
setGravity
(
Gravity
.
TOP
,
0
,
100
);
break
;
switch
(
gravity
)
{
case
"center"
:
case
"top"
:
toast
.
setGravity
(
Gravity
.
CENTER
,
0
,
0
);
toast
.
setGravity
(
Gravity
.
TOP
,
0
,
100
);
break
;
break
;
default
:
case
"center"
:
toast
.
setGravity
(
Gravity
.
BOTTOM
,
0
,
100
);
toast
.
setGravity
(
Gravity
.
CENTER
,
0
,
0
);
}
break
;
default
:
if
(
textSize
!=
null
)
toast
.
setGravity
(
Gravity
.
BOTTOM
,
0
,
100
);
text
.
setTextSize
(
textSize
.
floatValue
());
}
final
TextView
text
=
toast
.
getView
().
findViewById
(
android
.
R
.
id
.
message
);
Drawable
shapeDrawable
;
if
(
textSize
!=
null
)
text
.
setTextSize
(
textSize
.
floatValue
());
if
(
bgcolor
!=
null
)
{
Drawable
shapeDrawable
;
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
LOLLIPOP
)
{
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
LOLLIPOP
)
{
shapeDrawable
=
ctx
.
getResources
().
getDrawable
(
R
.
drawable
.
toast_bg
,
ctx
.
getTheme
());
shapeDrawable
=
ctx
.
getResources
().
getDrawable
(
R
.
drawable
.
toast_bg
,
ctx
.
getTheme
());
}
else
{
}
else
{
shapeDrawable
=
ctx
.
getResources
().
getDrawable
(
R
.
drawable
.
toast_bg
);
shapeDrawable
=
ctx
.
getResources
().
getDrawable
(
R
.
drawable
.
toast_bg
);
}
}
if
(
shapeDrawable
!=
null
)
{
if
(
bgcolor
!=
null
)
{
shapeDrawable
.
setColorFilter
(
bgcolor
.
intValue
(),
PorterDuff
.
Mode
.
SRC_IN
);
shapeDrawable
.
setColorFilter
(
bgcolor
.
intValue
(),
PorterDuff
.
Mode
.
SRC_IN
);
if
(
Build
.
VERSION
.
SDK_INT
<=
27
)
{
toast
.
getView
().
setBackground
(
shapeDrawable
);
}
else
{
toast
.
getView
().
setBackground
(
null
);
text
.
setBackground
(
shapeDrawable
);
}
}
}
}
// text.setOnTouchListener(new View.OnTouchListener() {
layout
.
setBackground
(
shapeDrawable
);
// @Override
// public boolean onTouch(View v, MotionEvent event) {
// if(bgcolor != null) {
// handler.removeCallbacks(run);
// Drawable shapeDrawable;
// text.setOnTouchListener(null);
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
// toast.cancel();
// shapeDrawable = ctx.getResources().getDrawable(R.drawable.toast_bg,ctx.getTheme());
// try {
// } else {
// result.success(true);
// shapeDrawable = ctx.getResources().getDrawable(R.drawable.toast_bg);
// } catch (Exception e){
// e.printStackTrace();
// }
// }
//
//
// return false;
// if (shapeDrawable != null) {
// shapeDrawable.setColorFilter(bgcolor.intValue(), PorterDuff.Mode.SRC_IN);
// if (Build.VERSION.SDK_INT <= 27) {
// toast.getView().setBackground(shapeDrawable);
// } else {
// toast.getView().setBackground(null);
// text.setBackground(shapeDrawable);
// }
// }
// }
// }
// });
if
(
textcolor
!=
null
)
{
if
(
textcolor
!=
null
)
{
text
.
setTextColor
(
textcolor
.
intValue
());
text
.
setTextColor
(
textcolor
.
intValue
());
}
}
toast
.
show
();
toast
.
show
();
result
.
success
(
true
);
result
.
success
(
true
);
// handler.postDelayed(run,toast.getDuration()*1000);
break
;
case
"cancel"
:
}
else
if
(
call
.
method
.
equals
(
"cancel"
)){
if
(
toast
!=
null
)
if
(
toast
!=
null
)
toast
.
cancel
();
toast
.
cancel
();
result
.
success
(
true
);
result
.
success
(
true
);
break
;
}
else
{
default
:
result
.
notImplemented
();
result
.
notImplemented
();
break
;
}
}
}
}
}
}
android/src/main/res/layout/toast_custom.xml
0 → 100644
View file @
77560d80
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:id=
"@+id/custom_toast_container"
android:orientation=
"horizontal"
android:layout_width=
"fill_parent"
android:layout_height=
"fill_parent"
android:padding=
"8dp"
android:background=
"#DAAA"
>
<TextView
android:id=
"@+id/text"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:textColor=
"#FFF"
/>
</LinearLayout>
\ No newline at end of file
example/lib/main.dart
View file @
77560d80
...
@@ -99,8 +99,8 @@ class _MyAppState extends State<MyApp> {
...
@@ -99,8 +99,8 @@ class _MyAppState extends State<MyApp> {
new
Padding
(
new
Padding
(
padding:
const
EdgeInsets
.
all
(
10.0
),
padding:
const
EdgeInsets
.
all
(
10.0
),
child:
new
RaisedButton
(
child:
new
RaisedButton
(
child:
new
Text
(
'Cancel Toasts'
),
child:
new
Text
(
'Cancel Toasts'
),
onPressed:
cancelToast
,
onPressed:
cancelToast
,
),
),
),
),
],
],
...
...
pubspec.yaml
View file @
77560d80
name
:
fluttertoast
name
:
fluttertoast
description
:
Toast Library for FLutter
description
:
Toast Library for FLutter
version
:
3.0.
3
version
:
3.0.
4
author
:
Karthik Ponnam <ponnamkarthik3@gmail.com>
author
:
Karthik Ponnam <ponnamkarthik3@gmail.com>
homepage
:
https://github.com/PonnamKarthik/FlutterToast
homepage
:
https://github.com/PonnamKarthik/FlutterToast
...
@@ -20,7 +20,6 @@ flutter:
...
@@ -20,7 +20,6 @@ flutter:
plugin
:
plugin
:
androidPackage
:
io.github.ponnamkarthik.toast.fluttertoast
androidPackage
:
io.github.ponnamkarthik.toast.fluttertoast
pluginClass
:
FluttertoastPlugin
pluginClass
:
FluttertoastPlugin
# To add assets to your plugin package, add an assets section, like this:
# To add assets to your plugin package, add an assets section, like this:
# assets:
# assets:
# - images/a_dot_burr.jpeg
# - images/a_dot_burr.jpeg
...
@@ -31,7 +30,6 @@ flutter:
...
@@ -31,7 +30,6 @@ flutter:
#
#
# An image asset can refer to one or more resolution-specific "variants", see
# An image asset can refer to one or more resolution-specific "variants", see
# https://flutter.io/assets-and-images/#resolution-aware.
# https://flutter.io/assets-and-images/#resolution-aware.
# To add custom fonts to your plugin package, add a fonts section here,
# To add custom fonts to your plugin package, add a fonts section here,
# in this "flutter" section. Each entry in this list should have a
# in this "flutter" section. Each entry in this list should have a
# "family" key with the font family name, and a "fonts" key with a
# "family" key with the font family name, and a "fonts" key with a
...
...
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