GitHub license pub codecov CodeScene Code Health

buijs software logo

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 =

void foo({
  State? state,
  void Function(String)? onSuccess,
  void Function(Exception)? onFailure,
}) =>
      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('');

class Counter extends Subscriber<int> {
    const Counter({
      required Widget Function(int?) builder,
      Key? key,
    }) : super(
      builder: builder,
      channel: _stream,
      topic: "counter",
      key: key,
    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")),


Flutter widgets to be used in conjunction with the klutter plugin.