Commit 16f0592a by sun

fix ios run error

parent 5c47854f
......@@ -17,7 +17,7 @@ static NSString *const CHANNEL_NAME = @"PonnamKarthik/fluttertoast";
[UIApplication sharedApplication].delegate.window.rootViewController;
FluttertoastPlugin* instance = [[FluttertoastPlugin alloc] init];
[registrar addMethodCallDelegate:instance channel:channel];
}
- (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result {
......@@ -25,28 +25,31 @@ static NSString *const CHANNEL_NAME = @"PonnamKarthik/fluttertoast";
NSString *msg = call.arguments[@"msg"];
NSString *gravity = call.arguments[@"gravity"];
NSString *durationTime = call.arguments[@"time"];
if((durationTime == (id)[NSNull null] || durationTime.length == 0 )) {
int time = 1;
@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
duration: 3
position:CSToastPositionBottom];
duration: time
position:CSToastPositionTop];
} else if([gravity isEqualToString:@"center"]) {
[[UIApplication sharedApplication].delegate.window.rootViewController.view makeToast:msg
duration: time
position:CSToastPositionCenter];
} else {
if([gravity isEqualToString:@"top"]) {
[[UIApplication sharedApplication].delegate.window.rootViewController.view makeToast:msg
duration: [durationTime intValue]
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];
}
[[UIApplication sharedApplication].delegate.window.rootViewController.view makeToast:msg
duration: time
position:CSToastPositionBottom];
}
result(@"done");
} else {
result(FlutterMethodNotImplemented);
......@@ -58,4 +61,4 @@ static NSString *const CHANNEL_NAME = @"PonnamKarthik/fluttertoast";
[[UIApplication sharedApplication].delegate.window.rootViewController.view makeToast:msg];
}
@end
\ No newline at end of file
@end
......@@ -3,8 +3,8 @@
#
Pod::Spec.new do |s|
s.name = 'fluttertoast'
s.version = '0.0.1'
s.summary = 'Toast Library for FLutter'
s.version = '0.0.2'
s.summary = 'Toast Library for Flutter'
s.description = <<-DESC
Toast Library for FLutter
DESC
......
......@@ -24,7 +24,7 @@ class Fluttertoast {
static Future<String> showToast ({
@required String msg,
Toast toastLength,
int timeInSecForIos,
int timeInSecForIos = 1,
ToastGravity gravity
}) async {
String toast = "short";
......
name: fluttertoast
description: Toast Library for FLutter
version: 2.0.2
version: 2.0.3
author: Karthik Ponnam <ponnamkarthik3@gmail.com>
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