Loading...
Loading...
Use FlowR APIs correctly across Dart and Flutter projects. Use when writing or reviewing flowr_dart FlowR/FlowB code, flowr FrViewModel/FrBlocViewModel widgets, FrProvider setup, FrUnion state, stream helpers, or migration after FlowR breaking changes, even when the project has its own file layout.
npx skill4agent add hu-wentao/flowr flowr-usageAGENTS.mdfvmfvm dart testfvm flutter analyzegit status --shortpackage:flowr_dart/flowr_dart.dartpackage:flowr/flowr_mvvm.dartdart:asyncFutureOrStreamStreamSubscriptionflowr/src/...flowr_dart/src/...FlowR<T>class Counter extends FlowR<int> {
Counter() : super(0);
int increment() => put(value + 1);
}updateFutureOr<UserState?> refresh() => update(
(old) async => old.copyWith(user: await api.loadUser()),
onError: (error, stackTrace) => putError(error, stackTrace),
);FlowB<E, S>sealed class CounterEvent {
const CounterEvent();
}
class CounterIncremented extends CounterEvent {
const CounterIncremented();
}
class CounterBloc extends FlowB<CounterEvent, int> {
CounterBloc() : super(0) {
on<CounterIncremented>((event, emit) => emit(state + 1));
}
}FlowR<T>Cubit<T>valuestateFlowB<E, S>Bloc<E, S>add(event)FlowB.putput(value)update(...)newValue == currentValuestreamvaluestatevalueStreamdispose()close()finalconstcopyWithListMapSetupdate((old) => old.copyWith(items: [...old.items, item]));put(old)skpNull(value, 'name')skpIf(condition, 'reason')Stream<T>FlowR.streamFlowB.streamfinal labels = counter.stream.distinctWith((count) => 'count: $count');
final evenValues = counter.stream.where((count) => count.isEven);
final uniqueValues = counter.stream.distinctUnique();distinctBy((event) => event.field)distinctWith((event) => mapped)distinctUnique()ValueStreammapValuewhereValueValueStream<T>FrModelFrViewModel<M>class CounterModel {
final int value;
const CounterModel({this.value = 0});
CounterModel copyWith({int? value}) =>
CounterModel(value: value ?? this.value);
}
class CounterViewModel extends FrViewModel<CounterModel> {
CounterViewModel() : super(const CounterModel());
FutureOr<CounterModel?> increment() =>
update((old) => old.copyWith(value: old.value + 1));
}FrBlocViewModel<E, M>class CounterViewModel
extends FrBlocViewModel<CounterEvent, CounterModel> {
CounterViewModel() : super(const CounterModel()) {
on<CounterIncremented>(
(event, emit) => emit(state.copyWith(value: state.value + 1)),
);
}
}FrProviderFrProvider(
(context) => CounterViewModel(),
child: const CounterPage(),
);FrProvider.diFrProvider.valueFrProvider.multiFrProviderDisposeMxClosableFrView<CounterViewModel, CounterModel>(
builder: (context, snap, child) => Text('${snap.data.value}'),
);FrViewFrListenerFrConsumerFrMultiListenerFrSnap(vm: VM, data: M)FrViewFrListenerFrConsumerFrViewUFrUnionViewModelFrConfig.initialize(
frUnion: FrUnion.of({CounterModel(), UserModel()}),
);FrUnion.of({...})FrUnion.ofTaggedModel({(model, 'tag')})FrUnionViewModel.ofTag(...)FrViewU<M>vm.streamBy<M>(tag: ...)vm.updateBy<M>((old) => next, tag: ...)FrUnionViewModelreferences/fr-mvvm-env.mdreferences/fr-mvvm-locale.mdreferences/fr-mvvm-theme.mdreferences/fr-mvvm-user.mdreferences/migration.mdfvm dart format <paths>fvm dart testfvm flutter testfvm dart analyzefvm flutter analyze