public static void ConfigureFlutnetBridge(FlutterEngine flutterEngine) { try { #if DEBUG _bridge = new FlutnetBridge(flutterEngine, AppContext, FlutnetBridgeMode.PlatformChannel); #else _bridge = new FlutnetBridge(flutterEngine, AppContext); #endif } catch (Exception e) { if (CurrentActivity != null) { AlertDialog.Builder builder = new AlertDialog.Builder(CurrentActivity); builder.SetTitle("Error"); builder.SetMessage(e.Message); builder.SetCancelable(false); builder.SetPositiveButton("OK", (sender, args) => { }); AlertDialog dialog = builder.Create(); dialog.Show(); } else { throw; } } }
public override void CleanUpFlutterEngine(FlutterEngine flutterEngine) { base.CleanUpFlutterEngine(flutterEngine); if (App.Initialized) App.CleanUpFlutnetBridge(); }
static FlutterEngine CreateDefaultEngine() { var engine = new FlutterEngine("io.flutter", null); engine.Run(null); return(engine); }
/// <summary> /// Initializes a new instance of the <see cref="FlutnetBridge"/> class /// specifying how platform code and Flutter code communicate. /// </summary> public FlutnetBridge(FlutterEngine engine, FlutnetBridgeMode mode) { // Create the named channel for communicating with Flutter module using asynchronous method calls // NOTE: This channel is used to RECEIVE messages/requests FROM Flutter _methodChannelIncoming = FlutterMethodChannel.Create("flutnetbridge.incoming", engine.BinaryMessenger); _methodChannelIncoming.SetMethodCallHandler(HandleMethodCall); // Create a second named channel for diagnostic use only. // This channel is used, for example, to test if Flutter module is running // embedded into a native Xamarin app or as a standalone app _methodChannelTest = FlutterMethodChannel.Create("flutnetbridge.support", engine.BinaryMessenger); _methodChannelTest.SetMethodCallHandler(HandleMethodCallTest); // Create the named channel for communicating with Flutter module using event streams // NOTE: This channel is used to SEND messages/notifications TO Flutter // An event channel is a specialized platform channel intended for the use case of exposing platform events to Flutter as a Dart stream. // The Flutter SDK currently has no support for the symmetrical case of exposing Dart streams to platform code, though that could be built, if the need arises. // see: https://medium.com/flutter/flutter-platform-channels-ce7f540a104e _streamHandler = new StreamHandler(this); _eventChannel = FlutterEventChannel.Create("flutnetbridge.outgoing", engine.BinaryMessenger); _eventChannel.SetStreamHandler(_streamHandler); Mode = mode; FlutnetRuntime.OnPlatformEvent += FlutnetRuntimeOnPlatformEvent; if (Mode == FlutnetBridgeMode.WebSocket) { _socketService = new FlutnetWebSocketService(); } }
public override void ConfigureFlutterEngine(FlutterEngine flutterEngine) { base.ConfigureFlutterEngine(flutterEngine); if (App.Initialized) { App.ConfigureFlutnetBridge(this.FlutterEngine); } }
public bool FinishedLaunching(UIApplication application, NSDictionary launchOptions) { FlutterEngine = new FlutterEngine("My Flutter Engine"); FlutterEngine.Run(); // Override point for customization after application launch. // If not required for your application you can safely delete this method return(true); }
public override void ConfigureFlutterEngine(FlutterEngine flutterEngine) { base.ConfigureFlutterEngine(flutterEngine); // Connect Flutter plugins (uncomment only if Flutter module uses plugins) //Flutnet.Interop.Plugins.GeneratedPluginRegistrant.RegisterWith(flutterEngine); if (App.Initialized) App.ConfigureFlutnetBridge(this.FlutterEngine); }
partial void UIButton197_TouchUpInside(UIButton sender) { Console.WriteLine("Tapped!"); var flutterEngine = new FlutterEngine(""); flutterEngine.Run(); GeneratedPluginRegistrant.RegisterWithRegistry(flutterEngine); var vc = new FlutterViewController(flutterEngine, null, null); PresentViewController(vc, true, null); }
public override void ConfigureFlutterEngine(FlutterEngine flutterEngine) { base.ConfigureFlutterEngine(flutterEngine); FlutnetRuntime.RegisterPlatformService(new ThermometerServiceDroid((UsbManager)GetSystemService(UsbService), Context), "thermometer_service"); // Connect Flutter plugins (uncomment only if Flutter module uses plugins) //Flutnet.Interop.Plugins.GeneratedPluginRegistrant.RegisterWith(flutterEngine); if (App.Initialized) { App.ConfigureFlutnetBridge(this.FlutterEngine); } }
private void EnsureFlutterEngineCreated(string engineId) { if (!FlutterEngineCache.Instance.Contains(engineId)) { var flutterEngine = new FlutterEngine(this); GeneratedPluginRegistrant.RegisterWith(flutterEngine); flutterEngine.DartExecutor.ExecuteDartEntrypoint( DartExecutor.DartEntrypoint.CreateDefault() ); FlutterEngineCache.Instance.Put(engineId, flutterEngine); } }
public override void ViewDidLoad() { base.ViewDidLoad(); var flutterEngine = new FlutterEngine(""); flutterEngine.Run(); GeneratedPluginRegistrant.RegisterWithRegistry(flutterEngine); var vc = new FlutterViewController(flutterEngine, null, null); AddChildViewController(vc); View.AddSubview(vc.View); vc.View.Frame = new CoreGraphics.CGRect( View.Frame.Location.X, View.Frame.Location.Y, View.Frame.Size.Width, View.Frame.Size.Height / 2); vc.DidMoveToParentViewController(this); }
private void FabOnClick(object sender, EventArgs eventArgs) { if (flutterEngine == null) { flutterEngine = new FlutterEngine(this); flutterEngine.DartExecutor.ExecuteDartEntrypoint( DartEntrypoint.CreateDefault() ); FlutterEngineCache.Instance.Put("my_engine", flutterEngine); var channel = new MethodChannel(flutterEngine.DartExecutor.BinaryMessenger, "diversido.io/main"); channel.SetMethodCallHandler(this); } StartActivity(FlutterActivity.WithCachedEngine("my_engine").Build(this)); }
/// <summary> /// Initializes a new instance of the <see cref="FlutnetBridge"/> class. /// </summary> public FlutnetBridge(FlutterEngine engine) : this(engine, FlutnetBridgeMode.PlatformChannel) { }
/// <summary> /// Initializes a new instance of the <see cref="FlutnetBridge"/> class. /// </summary> public FlutnetBridge(FlutterEngine engine, Android.Content.Context context) : this(engine, context, FlutnetBridgeMode.PlatformChannel) { }