flutter_synk 0.1.0-dev.1
flutter_synk: ^0.1.0-dev.1 copied to clipboard
Flutter widgets that make it easy to work with Synk. Built to be used along side Synk.
Flutter Synk #
Flutter widgets that bridge Synk's offline-first, conflict-free data structures with the Flutter UI layer.
Installation #
Add the dependency to your pubspec.yaml:
flutter pub add flutter_synk
Core Concepts #
Flutter Synk provides two primary components to integrate collaborative data into your app:
- SynkProvider manages the injection of a
SynkDocinto the widget tree. - SynkBuilder listens to any Synk type's stream and rebuilds on every transaction.
Widgets #
SynkProvider #
An InheritedWidget that makes a SynkDoc available to all widgets in its subtree. Place it near the root of your application to establish the collaborative context.
import 'package:flutter_synk/flutter_synk.dart';
import 'package:synk/synk.dart';
final doc = SynkDoc();
SynkProvider(
doc: doc,
child: MyApp(),
)
Access the document anywhere below it using the static helper:
final doc = SynkProvider.docOf(context);
SynkBuilder<T> #
A reactive widget that rebuilds its subtree in response to changes emitted by a Synk type (e.g., SynkValue, SynkMap, SynkList).
Unlike a standard StreamBuilder, SynkBuilder is transaction-aware. It processes stream events such that it triggers exactly one rebuild per completed transaction—never more—ensuring UI consistency and performance during complex collaborative updates.
final title = SynkValue<String>(doc, 'title');
SynkBuilder<String?>(
stream: title.stream,
initialData: title.value,
builder: (context, value) {
return Text(value ?? 'Untitled');
},
)
License #
Released under the MIT License. Contributions, bug reports, and PRs are welcome.