Last active
January 8, 2019 13:41
-
-
Save ashishrawat2911/5a366ef321fd1fcbee04593d44faea00 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Flutter | |
import UIKit | |
public class SwiftFlutterAlertDemoPlugin: NSObject, FlutterPlugin { | |
public static func register(with registrar: FlutterPluginRegistrar) { | |
let channel = FlutterMethodChannel(name: "flutter_alert_demo", binaryMessenger: registrar.messenger()) | |
let instance = SwiftFlutterAlertDemoPlugin() | |
registrar.addMethodCallDelegate(instance, channel: channel) | |
} | |
public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) { | |
if (call.method == "getPlatformVersion") { | |
result("iOS " + UIDevice.current.systemVersion) | |
} | |
else if (call.method == "showAlertDialog") { | |
DispatchQueue.main.async { | |
let alert = UIAlertController(title: "Alert", message: "Hi, My name is flutter", preferredStyle: .alert); | |
alert.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.default, handler: nil)) | |
UIApplication.shared.keyWindow?.rootViewController?.present(alert, animated: true, completion: nil); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment