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
6df57b14
Commit
6df57b14
authored
Apr 21, 2018
by
Ponnam Karthik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added iOS Support
parent
ecfaee70
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
46 additions
and
20 deletions
+46
-20
CHANGELOG.md
+5
-0
README.md
+19
-11
example/lib/main.dart
+6
-2
ios/Classes/FluttertoastPlugin.m
+8
-2
lib/fluttertoast.dart
+7
-4
pubspec.yaml
+1
-1
No files found.
CHANGELOG.md
View file @
6df57b14
## [2.0.1]
*
Ios Support added
*
option for setting toast gravity (top, center, bottom)
## [1.0.1]
## [1.0.1]
*
Initial Open Sources
*
Initial Open Sources
...
...
README.md
View file @
6df57b14
# fluttertoast
# [fluttertoast](https://pub.dartlang.org/packages/fluttertoast)
Android Toast Library for Flutter
Android Toast Library for Flutter
> Supported Platforms
> * Android
> * IOS
## How to Use
## How to Use
```
yaml
```
yaml
# add this line to your dependencies
# add this line to your dependencies
fluttertoast
:
^
1
.0.1
fluttertoast
:
^
2
.0.1
```
```
```
dart
```
dart
Fluttertoast
.
showToast
(
"Toast Text"
,
<
Toast
Length
>);
Fluttertoast
.
showToast
(
msg:
"This is Center Short Toast"
,
toastLength:
Toast
.
LENGTH_SHORT
,
gravity:
ToastGravity
.
CENTER
,
timeInSecForIos:
1
);
```
```
Toast Length can be
property | description
--------|------------
```
dart
msg | String (Not Null)(required)
Toast
.
LENGTH_SHORT
toastLength| Toast.LENGTH_SHORT or Toast.LENGTH_LONG (optional)
gravity | ToastGravity.TOP (or) ToastGravity.CENTER (or) ToastGravity.BOTTOM
or
timeInSecForIos | int (only for ios)
Toast
.
LENGTH_LONG
```
example/lib/main.dart
View file @
6df57b14
...
@@ -13,6 +13,7 @@ class _MyAppState extends State<MyApp> {
...
@@ -13,6 +13,7 @@ class _MyAppState extends State<MyApp> {
@override
@override
initState
()
{
initState
()
{
super
.
initState
();
super
.
initState
();
}
}
void
showLongToast
()
{
void
showLongToast
()
{
...
@@ -26,20 +27,23 @@ class _MyAppState extends State<MyApp> {
...
@@ -26,20 +27,23 @@ class _MyAppState extends State<MyApp> {
Fluttertoast
.
showToast
(
Fluttertoast
.
showToast
(
msg:
"This is Long Toast"
,
msg:
"This is Long Toast"
,
toastLength:
Toast
.
LENGTH_SHORT
,
toastLength:
Toast
.
LENGTH_SHORT
,
timeInSecForIos:
1
);
);
}
}
void
showTopShortToast
()
{
void
showTopShortToast
()
{
Fluttertoast
.
showToast
(
Fluttertoast
.
showToast
(
msg:
"This is Top Long Toast"
,
msg:
"This is Top Long Toast"
,
toastLength:
Toast
.
LENGTH_SHORT
,
toastLength:
Toast
.
LENGTH_SHORT
,
gravity:
ToastGravity
.
TOP
gravity:
ToastGravity
.
TOP
,
timeInSecForIos:
1
);
);
}
}
void
showCenterShortToast
()
{
void
showCenterShortToast
()
{
Fluttertoast
.
showToast
(
Fluttertoast
.
showToast
(
msg:
"This is Center Short Toast"
,
msg:
"This is Center Short Toast"
,
toastLength:
Toast
.
LENGTH_SHORT
,
toastLength:
Toast
.
LENGTH_SHORT
,
gravity:
ToastGravity
.
CENTER
gravity:
ToastGravity
.
CENTER
,
timeInSecForIos:
1
);
);
}
}
...
...
ios/Classes/FluttertoastPlugin.m
View file @
6df57b14
...
@@ -26,6 +26,12 @@ static NSString *const CHANNEL_NAME = @"PonnamKarthik/fluttertoast";
...
@@ -26,6 +26,12 @@ static NSString *const CHANNEL_NAME = @"PonnamKarthik/fluttertoast";
NSString
*
gravity
=
call
.
arguments
[
@"gravity"
];
NSString
*
gravity
=
call
.
arguments
[
@"gravity"
];
NSString
*
durationTime
=
call
.
arguments
[
@"time"
];
NSString
*
durationTime
=
call
.
arguments
[
@"time"
];
if
((
durationTime
==
(
id
)[
NSNull
null
]
||
durationTime
.
length
==
0
))
{
[[
UIApplication
sharedApplication
].
delegate
.
window
.
rootViewController
.
view
makeToast
:
msg
duration
:
3
position
:
CSToastPositionBottom
];
}
else
{
if
([
gravity
isEqualToString
:
@"top"
])
{
if
([
gravity
isEqualToString
:
@"top"
])
{
[[
UIApplication
sharedApplication
].
delegate
.
window
.
rootViewController
.
view
makeToast
:
msg
[[
UIApplication
sharedApplication
].
delegate
.
window
.
rootViewController
.
view
makeToast
:
msg
duration
:
[
durationTime
intValue
]
duration
:
[
durationTime
intValue
]
...
@@ -39,9 +45,9 @@ static NSString *const CHANNEL_NAME = @"PonnamKarthik/fluttertoast";
...
@@ -39,9 +45,9 @@ static NSString *const CHANNEL_NAME = @"PonnamKarthik/fluttertoast";
duration
:
[
durationTime
intValue
]
duration
:
[
durationTime
intValue
]
position
:
CSToastPositionBottom
];
position
:
CSToastPositionBottom
];
}
}
}
result
(
@"done"
);
_result
=
result
;
}
else
{
}
else
{
result
(
FlutterMethodNotImplemented
);
result
(
FlutterMethodNotImplemented
);
}
}
...
...
lib/fluttertoast.dart
View file @
6df57b14
import
'dart:async'
;
import
'package:flutter/services.dart'
;
import
'package:flutter/services.dart'
;
import
'package:meta/meta.dart'
;
import
'package:meta/meta.dart'
;
...
@@ -19,12 +21,12 @@ class Fluttertoast {
...
@@ -19,12 +21,12 @@ class Fluttertoast {
static
const
MethodChannel
_channel
=
static
const
MethodChannel
_channel
=
const
MethodChannel
(
'PonnamKarthik/fluttertoast'
);
const
MethodChannel
(
'PonnamKarthik/fluttertoast'
);
static
void
showToast
({
static
Future
<
String
>
showToast
({
@required
String
msg
,
@required
String
msg
,
Toast
toastLength
,
Toast
toastLength
,
int
timeInSecForIos
,
int
timeInSecForIos
,
ToastGravity
gravity
ToastGravity
gravity
})
{
})
async
{
String
toast
=
"short"
;
String
toast
=
"short"
;
if
(
toastLength
==
Toast
.
LENGTH_LONG
)
{
if
(
toastLength
==
Toast
.
LENGTH_LONG
)
{
toast
=
"long"
;
toast
=
"long"
;
...
@@ -45,8 +47,8 @@ class Fluttertoast {
...
@@ -45,8 +47,8 @@ class Fluttertoast {
'time'
:
timeInSecForIos
,
'time'
:
timeInSecForIos
,
'gravity'
:
gravityToast
'gravity'
:
gravityToast
};
};
_channel
.
invokeMethod
(
'showToast'
,
params
);
String
res
=
await
_channel
.
invokeMethod
(
'showToast'
,
params
);
return
res
;
}
}
}
}
\ No newline at end of file
pubspec.yaml
View file @
6df57b14
name
:
fluttertoast
name
:
fluttertoast
description
:
Toast Library for FLutter
description
:
Toast Library for FLutter
version
:
1
.0.1
version
:
2
.0.1
author
:
Karthik Ponnam <ponnamkarthik3@gmail.com>
author
:
Karthik Ponnam <ponnamkarthik3@gmail.com>
homepage
:
https://github.com/PonnamKarthik/FlutterToast
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