Flutter Widgets to be used in conjunction with the klutter plugin. Full support for:
Example function which invokes method foo on the given channel and returns a String value.
import 'package:flutter/services.dart';
import 'package:flutter/widgets.dart';
import 'package:klutter_ui/klutter_ui.dart';
const MethodChannel _channel =
    MethodChannel('foo.bar.plugin/channel/my_simple_controller');
void foo({
  State? state,
  void Function(String)? onSuccess,
  void Function(Exception)? onFailure,
}) =>
    doEvent<String>(
      state: state,
      event: "foo",
      channel: _channel,
      onSuccess: onSuccess,
      onFailure: onFailure,
    );Using the function as a tearoff requires just a single line of code:
TextButton(onPressed: foo, child: Text("Click"))Example implementation of a Subscriber (statefull widget) which subscribes to a channel and updates it state everytime a new counter value is received.
import 'package:flutter/services.dart';
import 'package:flutter/widgets.dart';
import 'package:klutter_ui/klutter_ui.dart';
const _stream = EventChannel('foo.bar.plugin/channel/counter');
class Counter extends Subscriber<int> {
    const Counter({
      required Widget Function(int?) builder,
      Key? key,
    }) : super(
      builder: builder,
      channel: _stream,
      topic: "counter",
      key: key,
    );
    
    @override
    int decode(dynamic json) => json as int;
}All that is required to use the returned data is to wrap any widget with the Counter widget and then use it's value.
Counter(builder: (res) => Text("$res")),