Last active
August 26, 2020 08:42
-
-
Save vreamer/acc15439fac9e2d6940ce2fb20482ffa 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
import 'package:direct_reply_notification/data-service.dart'; | |
import 'package:flutter/services.dart'; | |
class FlutterMethodChannel { | |
static const channelName = 'channel'; | |
MethodChannel methodChannel; | |
static final FlutterMethodChannel instance = FlutterMethodChannel._init(); | |
FlutterMethodChannel._init(); | |
void configureChannel() { | |
methodChannel = MethodChannel(channelName); | |
methodChannel.setMethodCallHandler(this.methodHandler); // set method handler | |
} | |
Future<void> methodHandler(MethodCall call) async { | |
final String idea = call.arguments; | |
switch (call.method) { | |
case "showNewIdea": // this method name needs to be the same from invokeMethod in Android | |
DataService.instance.addIdea(idea); // you can handle the data here. In this example, we will simply update the view via a data service | |
break; | |
default: | |
print('no method handler for method ${call.method}'); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment