Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/buijs-dev/klutter-dart-ui
Flutter widgets for Klutter.
https://github.com/buijs-dev/klutter-dart-ui
eventchannel flutter klutter methodchannel widgets
Last synced: about 1 month ago
JSON representation
Flutter widgets for Klutter.
- Host: GitHub
- URL: https://github.com/buijs-dev/klutter-dart-ui
- Owner: buijs-dev
- License: mit
- Created: 2023-03-23T18:45:52.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-03-17T13:15:36.000Z (10 months ago)
- Last Synced: 2024-11-21T04:13:15.767Z (about 2 months ago)
- Topics: eventchannel, flutter, klutter, methodchannel, widgets
- Language: Dart
- Homepage:
- Size: 579 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
[![](https://img.shields.io/badge/Buijs-Software-blue)](https://pub.dev/publishers/buijs.dev/packages)
[![GitHub license](https://img.shields.io/github/license/buijs-dev/klutter-dart-ui?color=black&logoColor=black)](https://github.com/buijs-dev/klutter-dart-ui/blob/main/LICENSE)
[![pub](https://img.shields.io/pub/v/klutter_ui)](https://pub.dev/packages/klutter_ui)
[![codecov](https://codecov.io/gh/buijs-dev/klutter-dart-ui/branch/main/graph/badge.svg?token=z0HCTKNLn5)](https://codecov.io/gh/buijs-dev/klutter-dart-ui)
[![CodeScene Code Health](https://codescene.io/projects/38075/status-badges/code-health)](https://codescene.io/projects/38075)Flutter Widgets to be used in conjunction with the [klutter plugin](https://github.com/buijs-dev/klutter-dart).
Full support for:- [MethodChannel](#MethodChannel)
- [EventChannel](#EventChannel)## MethodChannel
Example function which invokes method foo on the given channel and returns a String value.```dart
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(
state: state,
event: "foo",
channel: _channel,
onSuccess: onSuccess,
onFailure: onFailure,
);
```Using the function as a tearoff requires just a single line of code:
```dart
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.```dart
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 {
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.
```dart
Counter(builder: (res) => Text("$res")),
```