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
5df60dca
Commit
5df60dca
authored
Feb 12, 2019
by
Karthik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
migrated to androidX
parent
f6fc0a87
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
61 additions
and
45 deletions
+61
-45
CHANGELOG.md
+4
-0
README.md
+2
-2
android/build.gradle
+3
-3
android/src/main/java/io/github/ponnamkarthik/toast/fluttertoast/FluttertoastPlugin.java
+39
-32
android/src/main/res/drawable/toast_bg.xml
+5
-4
example/android/app/build.gradle
+5
-3
example/android/gradle.properties
+2
-0
pubspec.yaml
+1
-1
No files found.
CHANGELOG.md
View file @
5df60dca
## [3.0.0]
*
Migrated to AndroidX
## [2.2.12]
*
Incomplete Text Fix
...
...
README.md
View file @
5df60dca
...
...
@@ -7,13 +7,13 @@ Android and iOS Toast Library for Flutter
> * Android
> * IOS
If you
r project uses androidx then use
`fluttertoast`
version
`2.2.4`
or
`2.2.5
`
If you
dont want to use androidx then use
`fluttertoast`
version
`2.2.12
`
## How to Use
```
yaml
# add this line to your dependencies
fluttertoast
:
^
2.2.12
fluttertoast
:
^
3.0.0
```
```
dart
...
...
android/build.gradle
View file @
5df60dca
...
...
@@ -26,7 +26,7 @@ android {
defaultConfig
{
minSdkVersion
16
testInstrumentationRunner
"android
.support
.test.runner.AndroidJUnitRunner"
testInstrumentationRunner
"android
x
.test.runner.AndroidJUnitRunner"
}
lintOptions
{
disable
'InvalidPackage'
...
...
@@ -34,6 +34,6 @@ android {
}
dependencies
{
implementation
'com.android.support:appcompat-v7:27.1.
1'
implementation
'
com.android.support:support-compat:27.1.
1'
implementation
'androidx.appcompat:appcompat:1.0.0-beta0
1'
implementation
'
androidx.core:core:1.0.0-beta0
1'
}
android/src/main/java/io/github/ponnamkarthik/toast/fluttertoast/FluttertoastPlugin.java
View file @
5df60dca
...
...
@@ -11,7 +11,7 @@ import android.view.View;
import
android.widget.TextView
;
import
android.widget.Toast
;
import
android
.support.v4
.content.ContextCompat
;
import
android
x.core
.content.ContextCompat
;
import
io.flutter.plugin.common.MethodCall
;
import
io.flutter.plugin.common.MethodChannel
;
import
io.flutter.plugin.common.MethodChannel.MethodCallHandler
;
...
...
@@ -22,6 +22,7 @@ import io.flutter.plugin.common.PluginRegistry.Registrar;
public
class
FluttertoastPlugin
implements
MethodCallHandler
{
Context
ctx
;
Toast
toast
;
FluttertoastPlugin
(
Context
context
)
{
ctx
=
context
;
...
...
@@ -44,7 +45,7 @@ public class FluttertoastPlugin implements MethodCallHandler {
Number
textSize
=
call
.
argument
(
"fontSize"
);
final
Toast
toast
=
Toast
.
makeText
(
ctx
,
msg
,
Toast
.
LENGTH_SHORT
);
toast
=
Toast
.
makeText
(
ctx
,
msg
,
Toast
.
LENGTH_SHORT
);
toast
.
setText
(
msg
);
...
...
@@ -55,19 +56,19 @@ public class FluttertoastPlugin implements MethodCallHandler {
}
Boolean
sent
=
false
;
final
Handler
handler
=
new
Handler
();
final
Runnable
run
=
new
Runnable
()
{
@Override
public
void
run
()
{
try
{
result
.
success
(
false
);
}
catch
(
Exception
e
){
e
.
printStackTrace
();
}
}
};
//
final Handler handler = new Handler();
//
final Runnable run = new Runnable() {
//
//
@Override
//
public void run() {
//
try {
//
result.success(false);
//
//
} catch (Exception e){
//
e.printStackTrace();
//
}
//
}
//
};
switch
(
gravity
)
{
...
...
@@ -82,6 +83,7 @@ public class FluttertoastPlugin implements MethodCallHandler {
}
final
TextView
text
=
toast
.
getView
().
findViewById
(
android
.
R
.
id
.
message
);
if
(
textSize
!=
null
)
text
.
setTextSize
(
textSize
.
floatValue
());
text
.
setMaxLines
(
1
);
...
...
@@ -94,34 +96,39 @@ public class FluttertoastPlugin implements MethodCallHandler {
if
(
Build
.
VERSION
.
SDK_INT
<=
27
)
{
toast
.
getView
().
setBackground
(
shapeDrawable
);
}
else
{
toast
.
getView
().
setBackground
(
null
);
text
.
setBackground
(
shapeDrawable
);
}
}
}
text
.
setOnTouchListener
(
new
View
.
OnTouchListener
()
{
@Override
public
boolean
onTouch
(
View
v
,
MotionEvent
event
)
{
handler
.
removeCallbacks
(
run
);
text
.
setOnTouchListener
(
null
);
toast
.
cancel
();
try
{
result
.
success
(
true
);
}
catch
(
Exception
e
){
e
.
printStackTrace
();
}
return
false
;
}
});
//
text.setOnTouchListener(new View.OnTouchListener() {
//
@Override
//
public boolean onTouch(View v, MotionEvent event) {
//
handler.removeCallbacks(run);
//
text.setOnTouchListener(null);
//
toast.cancel();
//
try {
//
result.success(true);
//
} catch (Exception e){
//
e.printStackTrace();
//
}
//
//
return false;
//
}
//
});
if
(
textcolor
!=
null
)
{
text
.
setTextColor
(
textcolor
.
intValue
());
}
toast
.
show
();
handler
.
postDelayed
(
run
,
toast
.
getDuration
()*
1000
);
result
.
success
(
true
);
// handler.postDelayed(run,toast.getDuration()*1000);
}
else
if
(
call
.
method
.
equals
(
"cancel"
)){
if
(
toast
!=
null
)
toast
.
cancel
();
result
.
success
(
true
);
}
else
{
result
.
notImplemented
();
}
...
...
android/src/main/res/drawable/toast_bg.xml
View file @
5df60dca
...
...
@@ -7,8 +7,8 @@
android:color=
"#000000"
>
</solid>
<padding
android:left=
"1
0
dp"
android:top=
"
8
dp"
android:right=
"1
0
dp"
android:bottom=
"
8
dp"
/>
android:left=
"1
6
dp"
android:top=
"
12
dp"
android:right=
"1
6
dp"
android:bottom=
"
12
dp"
/>
</shape>
\ No newline at end of file
example/android/app/build.gradle
View file @
5df60dca
...
...
@@ -38,7 +38,7 @@ android {
targetSdkVersion
28
versionCode
flutterVersionCode
.
toInteger
()
versionName
flutterVersionName
testInstrumentationRunner
"android
.support
.test.runner.AndroidJUnitRunner"
testInstrumentationRunner
"android
x
.test.runner.AndroidJUnitRunner"
}
buildTypes
{
...
...
@@ -56,6 +56,8 @@ flutter {
dependencies
{
testImplementation
'junit:junit:4.12'
androidTestImplementation
'com.android.support.test:runner:1.0.2'
androidTestImplementation
'com.android.support.test.espresso:espresso-core:3.0.2'
androidTestImplementation
'androidx.test:runner:1.1.2-alpha01'
androidTestImplementation
'androidx.test.espresso:espresso-core:3.1.2-alpha01'
implementation
'androidx.appcompat:appcompat:1.0.2'
implementation
'androidx.legacy:legacy-support-v4:1.0.0'
}
example/android/gradle.properties
View file @
5df60dca
android.enableJetifier
=
true
android.useAndroidX
=
true
org.gradle.jvmargs
=
-Xmx1536M
pubspec.yaml
View file @
5df60dca
name
:
fluttertoast
description
:
Toast Library for FLutter
version
:
2.2.12
version
:
3.0.0
author
:
Karthik Ponnam <ponnamkarthik3@gmail.com>
homepage
:
https://github.com/PonnamKarthik/FlutterToast
...
...
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