Last active
January 12, 2019 15:20
-
-
Save ashishrawat2911/b7714ab85e953a7a83ede7e97fbe24de to your computer and use it in GitHub Desktop.
This file contains 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
package adhoc.successive.com.flutteralertdemo; | |
import android.app.Activity; | |
import android.app.Dialog; | |
import io.flutter.plugin.common.MethodCall; | |
import io.flutter.plugin.common.MethodChannel; | |
import io.flutter.plugin.common.MethodChannel.MethodCallHandler; | |
import io.flutter.plugin.common.MethodChannel.Result; | |
import io.flutter.plugin.common.PluginRegistry.Registrar; | |
/** FlutterAlertDemoPlugin */ | |
public class FlutterAlertDemoPlugin implements MethodCallHandler { | |
/** Plugin registration. */ | |
Activity context; | |
MethodChannel methodChannel; | |
public static void registerWith(Registrar registrar) { | |
final MethodChannel channel = new MethodChannel(registrar.messenger(), "flutter_alert_demo"); | |
channel.setMethodCallHandler(new FlutterAlertDemoPlugin(registrar.activity(), channel)); | |
} | |
public FlutterAlertDemoPlugin(Activity activity, MethodChannel methodChannel) { | |
this.context = activity; | |
this.methodChannel = methodChannel; | |
this.methodChannel.setMethodCallHandler(this); | |
} | |
@Override | |
public void onMethodCall(MethodCall call, Result result) { | |
if (call.method.equals("getPlatformVersion")) { | |
result.success("Android " + android.os.Build.VERSION.RELEASE); | |
} | |
else if(call.method.equalsIgnoreCase("showAlertDialog")) { | |
Dialog dialog=new Dialog(context); | |
dialog.setTitle("Hi, My Name is Flutter"); | |
dialog.show(); | |
} | |
else { | |
result.notImplemented(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment