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]
*
Initial Open Sources
...
...
README.md
View file @
6df57b14
# fluttertoast
# [fluttertoast](https://pub.dartlang.org/packages/fluttertoast)
Android Toast Library for Flutter
> Supported Platforms
> * Android
> * IOS
## How to Use
```
yaml
# add this line to your dependencies
fluttertoast
:
^
1
.0.1
fluttertoast
:
^
2
.0.1
```
```
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
```
dart
Toast
.
LENGTH_SHORT
or
property | description
--------|------------
msg | String (Not Null)(required)
toastLength| Toast.LENGTH_SHORT or Toast.LENGTH_LONG (optional)
gravity | ToastGravity.TOP (or) ToastGravity.CENTER (or) ToastGravity.BOTTOM
timeInSecForIos | int (only for ios)
Toast
.
LENGTH_LONG
```
example/lib/main.dart
View file @
6df57b14
...
...
@@ -13,6 +13,7 @@ class _MyAppState extends State<MyApp> {
@override
initState
()
{
super
.
initState
();
}
void
showLongToast
()
{
...
...
@@ -26,20 +27,23 @@ class _MyAppState extends State<MyApp> {
Fluttertoast
.
showToast
(
msg:
"This is Long Toast"
,
toastLength:
Toast
.
LENGTH_SHORT
,
timeInSecForIos:
1
);
}
void
showTopShortToast
()
{
Fluttertoast
.
showToast
(
msg:
"This is Top Long Toast"
,
toastLength:
Toast
.
LENGTH_SHORT
,
gravity:
ToastGravity
.
TOP
gravity:
ToastGravity
.
TOP
,
timeInSecForIos:
1
);
}
void
showCenterShortToast
()
{
Fluttertoast
.
showToast
(
msg:
"This is Center Short Toast"
,
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";
NSString
*
gravity
=
call
.
arguments
[
@"gravity"
];
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"
])
{
[[
UIApplication
sharedApplication
].
delegate
.
window
.
rootViewController
.
view
makeToast
:
msg
duration
:
[
durationTime
intValue
]
...
...
@@ -39,9 +45,9 @@ static NSString *const CHANNEL_NAME = @"PonnamKarthik/fluttertoast";
duration
:
[
durationTime
intValue
]
position
:
CSToastPositionBottom
];
}
}
_result
=
result
;
result
(
@"done"
);
}
else
{
result
(
FlutterMethodNotImplemented
);
}
...
...
lib/fluttertoast.dart
View file @
6df57b14
import
'dart:async'
;
import
'package:flutter/services.dart'
;
import
'package:meta/meta.dart'
;
...
...
@@ -19,12 +21,12 @@ class Fluttertoast {
static
const
MethodChannel
_channel
=
const
MethodChannel
(
'PonnamKarthik/fluttertoast'
);
static
void
showToast
({
static
Future
<
String
>
showToast
({
@required
String
msg
,
Toast
toastLength
,
int
timeInSecForIos
,
ToastGravity
gravity
})
{
})
async
{
String
toast
=
"short"
;
if
(
toastLength
==
Toast
.
LENGTH_LONG
)
{
toast
=
"long"
;
...
...
@@ -45,8 +47,8 @@ class Fluttertoast {
'time'
:
timeInSecForIos
,
'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
description
:
Toast Library for FLutter
version
:
1
.0.1
version
:
2
.0.1
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