yrom / flutter_method_channel_ex

Alternative Flutter method channel to avoid jank.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

method_channel_ex

Alternative Flutter method channel.

FatJsonMethodChannel

Decode method channel's result in different Isolate (based on package 'dart-executor'), alternative for MethodChannel which using JSONMethodCodec.

StandardMethodChannel

Alternative for MethodChannel which using StandardMethodCodec.

Usage

Add dependency in pubspec.yaml:

dependencies:
  method_channel_ex: 
    git: https://github.com/yrom/flutter_method_channel_ex.git

In flutter:

import 'package:method_channel_ex/method_channel_ex.dart';

var channel = FatJsonMethodChannel("test");
var json = channel.invokeMethod("getAFatJson");

In native (e.g. Android):

MethodChannel(
    flutterView,
    "test",
    JSONMethodCodec.INSTANCE
).setMethodCallHandler { methodCall, result ->
    if (methodCall.method == "getAFatJson") {
        val json = JSONObject()

        for (i in 1..1000) {
            json.put("$i", "abc".repeat(i % 10))
        }
        result.success(json)
    } else {
        result.notImplemented()
    }
}

About

Alternative Flutter method channel to avoid jank.

License:MIT License


Languages

Language:Dart 86.5%Language:Kotlin 9.4%Language:Swift 3.8%Language:Objective-C 0.4%