klutter_ui 1.1.0 copy "klutter_ui: ^1.1.0" to clipboard
klutter_ui: ^1.1.0 copied to clipboard

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

GitHub license pub codecov CodeScene Code Health

buijs software logo

Flutter Widgets to be used in conjunction with the klutter plugin. Full support for:

MethodChannel #

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"))

EventChannel #

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")),
1
likes
160
points
92
downloads

Publisher

verified publisherbuijs.dev

Weekly Downloads

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

Homepage
Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on klutter_ui