[giveResult] added shouldFinish
param and integrated
This commit is contained in:
parent
27029a82f6
commit
004189b425
2 changed files with 7 additions and 3 deletions
|
@ -57,7 +57,7 @@ class ReceiveIntentPlugin : FlutterPlugin, MethodCallHandler, EventChannel.Strea
|
|||
eventSink?.success(latestIntentMap)
|
||||
}
|
||||
|
||||
private fun giveResult(result: Result, resultCode: Int?, data: String?) {
|
||||
private fun giveResult(result: Result, resultCode: Int?, data: String?, shouldFinish: Bool?) {
|
||||
if (resultCode != null) {
|
||||
if (data == null) {
|
||||
activity?.setResult(resultCode)
|
||||
|
@ -65,6 +65,9 @@ class ReceiveIntentPlugin : FlutterPlugin, MethodCallHandler, EventChannel.Strea
|
|||
val json = JSONObject(data)
|
||||
activity?.setResult(resultCode, jsonToIntent(json))
|
||||
}
|
||||
if(shouldFinish ?: false){
|
||||
activity?.finish()
|
||||
}
|
||||
result.success(null)
|
||||
}
|
||||
result.error("InvalidArg", "resultCode can not be null", null)
|
||||
|
@ -87,7 +90,7 @@ class ReceiveIntentPlugin : FlutterPlugin, MethodCallHandler, EventChannel.Strea
|
|||
result.success(initialIntentMap)
|
||||
}
|
||||
"giveResult" -> {
|
||||
giveResult(result, call.argument("resultCode"), call.argument("data"))
|
||||
giveResult(result, call.argument("resultCode"), call.argument("data"), call.argument("shouldFinish"))
|
||||
}
|
||||
else -> {
|
||||
result.notImplemented()
|
||||
|
|
|
@ -69,10 +69,11 @@ class ReceiveIntent {
|
|||
.receiveBroadcastStream()
|
||||
.map<ReceivedIntent?>((event) => ReceivedIntent.fromMap(event as Map?));
|
||||
|
||||
static Future<void> giveResult(int resultCode, {Map? data}) async {
|
||||
static Future<void> giveResult(int resultCode, {Map? data, bool shouldFinish: false}) async {
|
||||
await _methodChannel.invokeMethod('giveResult', <String, dynamic>{
|
||||
"resultCode": resultCode,
|
||||
"data": json.encode(data),
|
||||
"shouldFinish": shouldFinish,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue