Commit 4d62dde7 by Karthik Ponnam Committed by GitHub

Merge pull request #2 from asmh1989/master

fix ios run error
parents 5c47854f 16f0592a
...@@ -17,7 +17,7 @@ static NSString *const CHANNEL_NAME = @"PonnamKarthik/fluttertoast"; ...@@ -17,7 +17,7 @@ static NSString *const CHANNEL_NAME = @"PonnamKarthik/fluttertoast";
[UIApplication sharedApplication].delegate.window.rootViewController; [UIApplication sharedApplication].delegate.window.rootViewController;
FluttertoastPlugin* instance = [[FluttertoastPlugin alloc] init]; FluttertoastPlugin* instance = [[FluttertoastPlugin alloc] init];
[registrar addMethodCallDelegate:instance channel:channel]; [registrar addMethodCallDelegate:instance channel:channel];
} }
- (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result { - (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result {
...@@ -25,28 +25,31 @@ static NSString *const CHANNEL_NAME = @"PonnamKarthik/fluttertoast"; ...@@ -25,28 +25,31 @@ static NSString *const CHANNEL_NAME = @"PonnamKarthik/fluttertoast";
NSString *msg = call.arguments[@"msg"]; NSString *msg = call.arguments[@"msg"];
NSString *gravity = call.arguments[@"gravity"]; NSString *gravity = call.arguments[@"gravity"];
NSString *durationTime = call.arguments[@"time"]; NSString *durationTime = call.arguments[@"time"];
int time = 1;
if((durationTime == (id)[NSNull null] || durationTime.length == 0 )) { @try{
time = [durationTime intValue];
} @catch(NSException *e){
time = 3;
}
if(time > 10 ) time = 10;
else if(time < 1) time = 1;
if([gravity isEqualToString:@"top"]) {
[[UIApplication sharedApplication].delegate.window.rootViewController.view makeToast:msg [[UIApplication sharedApplication].delegate.window.rootViewController.view makeToast:msg
duration: 3 duration: time
position:CSToastPositionBottom]; position:CSToastPositionTop];
} else if([gravity isEqualToString:@"center"]) {
[[UIApplication sharedApplication].delegate.window.rootViewController.view makeToast:msg
duration: time
position:CSToastPositionCenter];
} else { } else {
if([gravity isEqualToString:@"top"]) { [[UIApplication sharedApplication].delegate.window.rootViewController.view makeToast:msg
[[UIApplication sharedApplication].delegate.window.rootViewController.view makeToast:msg duration: time
duration: [durationTime intValue] position:CSToastPositionBottom];
position:CSToastPositionTop];
} else if([gravity isEqualToString:@"center"]) {
[[UIApplication sharedApplication].delegate.window.rootViewController.view makeToast:msg
duration: [durationTime intValue]
position:CSToastPositionCenter];
} else {
[[UIApplication sharedApplication].delegate.window.rootViewController.view makeToast:msg
duration: [durationTime intValue]
position:CSToastPositionBottom];
}
} }
result(@"done"); result(@"done");
} else { } else {
result(FlutterMethodNotImplemented); result(FlutterMethodNotImplemented);
...@@ -58,4 +61,4 @@ static NSString *const CHANNEL_NAME = @"PonnamKarthik/fluttertoast"; ...@@ -58,4 +61,4 @@ static NSString *const CHANNEL_NAME = @"PonnamKarthik/fluttertoast";
[[UIApplication sharedApplication].delegate.window.rootViewController.view makeToast:msg]; [[UIApplication sharedApplication].delegate.window.rootViewController.view makeToast:msg];
} }
@end @end
\ No newline at end of file
...@@ -3,8 +3,8 @@ ...@@ -3,8 +3,8 @@
# #
Pod::Spec.new do |s| Pod::Spec.new do |s|
s.name = 'fluttertoast' s.name = 'fluttertoast'
s.version = '0.0.1' s.version = '0.0.2'
s.summary = 'Toast Library for FLutter' s.summary = 'Toast Library for Flutter'
s.description = <<-DESC s.description = <<-DESC
Toast Library for FLutter Toast Library for FLutter
DESC DESC
......
...@@ -24,7 +24,7 @@ class Fluttertoast { ...@@ -24,7 +24,7 @@ class Fluttertoast {
static Future<String> showToast ({ static Future<String> showToast ({
@required String msg, @required String msg,
Toast toastLength, Toast toastLength,
int timeInSecForIos, int timeInSecForIos = 1,
ToastGravity gravity ToastGravity gravity
}) async { }) async {
String toast = "short"; String toast = "short";
......
name: fluttertoast name: fluttertoast
description: Toast Library for FLutter description: Toast Library for FLutter
version: 2.0.2 version: 2.0.3
author: Karthik Ponnam <ponnamkarthik3@gmail.com> author: Karthik Ponnam <ponnamkarthik3@gmail.com>
homepage: https://github.com/PonnamKarthik/FlutterToast homepage: https://github.com/PonnamKarthik/FlutterToast
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment