flutter_solidart 2.7.1
flutter_solidart: ^2.7.1 copied to clipboard
A simple State Management solution for Flutter applications inspired by SolidJS
2.7.0 #
Changes from solidart #
- REFACTOR: Deprecate
maybeOnandonmethods ofResourceState. UsemaybeWhenandwheninstead.
2.6.1 #
- CHORE: Bump
solidartdependency to^2.7.1.
2.6.0 #
- FEAT: Export
SignalandResourceby implementingValueNotifierandReadableSignal,Computedby implementingValueListenable.
2.5.0 #
- REFACTOR: Improve and simplify the
SignalBuilderimplementation (thanks to @medz). - FEAT: Add
assertSignalBuilderWithoutDependenciestoSolidartConfigto manually disable the assertion thrown when aSignalBuilderdoesn't track any reactive value. (By default it's true, so it will raise an assertion).
Changes from solidart #
- REFACTOR: Make auto disposal synchronous.
2.4.1 #
- FIX:
SignalBuildernot working with inherited widgets. This is just a temporary patch, a better solution needs to be found, because inherited widgets tracked inside the builder won't react.
2.4.0 #
- CHORE: Detect if
SignalBuilderdidn't track any reactive value and throw aSignalBuilderWithoutDependenciesError.
Changes from solidart #
- FEAT: Add
runmethod toComputedto manually trigger an update of its value. - FEAT: Add
runmethod toEffectto manually re-run the effect. - CHORE: Detect if
Effectdidn't track any reactive value and throw anEffectWithoutDependenciesErrorexception.
2.3.3 #
- FIX: Bump the
solidartdependency to^2.4.1.
2.3.2 #
- FIX:
Signal.lazywhich caused an exception. - CHORE: Improve
SignalBuildererror handling and rebuilding.
2.3.1 #
- FIX:
SignalBuilderrebuilded twice when a signal changed, added unit test to prevent this from happening again.
2.3.0 #
Changes from solidart #
- FEAT: Add
Debouncerutility class to easily debounce operations anddebounceDelaytoResourceto debounce source changes if they fire very often.
2.2.0 #
Changes from solidart #
- FEAT: Allow extending signal, computed, resource, list-signal, set-signal and map-signal.
2.1.0 #
Changes from solidart #
- FEAT: Add
timeoutparameter toSignal.untilmethod to specify a timeout duration. If the condition is not met within the specified duration, the returned future will complete with aTimeoutException.
2.0.1 #
- CHORE: Update the
solidartdependency to^2.1.0.
Changes from solidart #
- REFACTOR: Update
alien_signalsdependency from^0.2.1to^0.4.3with significant performance improvements (thanks to @medz). - REFACTOR: Replace custom reactive node implementations with
alien.ReactiveNodefor better compatibility and performance (thanks to @medz). - REFACTOR: Simplify signal, computed and effect implementations by leveraging new
alien_signalsAPI (thanks to @medz). - PERFORMANCE: Improve performance by removing redundant tracking operations in the reactive system (thanks to @medz).
- FIX: Add proper cleanup for disposed nodes to prevent memory leaks (thanks to @medz).
- FIX: Fix potential memory leaks in auto-dispose scenarios (thanks to @medz).
- FIX: Clear queued flag when running effects in
ReactiveSystemto ensure proper effect execution (thanks to @medz). - CHORE: Reorder dev_dependencies in pubspec.yaml for improved organization and readability (thanks to @medz).
2.0.0 #
- BREAKING CHANGE: Remove
SolidandProviders, use disco instead. - FEAT: The
SignalBuilderwidget now automatically tracks theSignals used in thebuilderfunction allowing you to react to N signals at the same time. See the migration guide. - BREAKING CHANGE: Removed
DualSignalBuilderandTripleSignalBuilderin favor ofSignalBuilder. - BREAKING CHANGE: Removed
ResourceBuilderin favor ofSignalBuilder. See the migration guide.
Changes from solidart #
- CHORE: Improve the performance by using
alien_signalsfor the reactive system. - FEAT: Expose
untracked. - REFACTOR: Updated the reactive system from scratch, improving the performances.
- BREAKING CHANGE: Remove
setandcallmethods from Signals (Use an extension to have them back). - FEAT: Add
useRefreshingtoResourceto decide whether to update the current state withisRefreshing(defaults to true). If you set it to false, when refreshing, the resource will go directly to the loading state. - FEAT: Add
Signal.lazyto allow the creation of a signal without an initial value. Be aware, the signal will throw an error if you try to read its value before it has been initialized. - CHORE: Remove deprecated
createSignal,createComputed,createEffectandcreateResourcehelpers. - CHORE: Remove
SignalOptionsandResourceOptionsclasses. - FEAT: Add
batchfunction to execute a callback that will not side-effect until its top-most batch is completed. See docs here - CHORE: Add
trackInDevToolstoSignalOptionsandResourceOptionsto disable the DevTools tracking for specific signals and resources, defaults toSolidartConfig.devToolsEnabled.
2.0.0-dev.3 #
- BREAKING CHANGE: Remove
SolidandProviders, use disco instead.
Changes from solidart #
- REFACTOR: Updated the reactive system from scratch, improving the performances.
- BREAKING CHANGE: Remove
setandcallmethods from Signals (Use an extension to have them back). - FEAT: Add
useRefreshingtoResourceto decide whether to update the current state withisRefreshing(defaults to true). If you set it to false, when refreshing, the resource will go directly to the loading state.
2.0.0-dev.2 #
Changes from solidart #
- CHORE: Remove deprecated
createSignal,createComputed,createEffectandcreateResourcehelpers. - CHORE: Remove
SignalOptionsandResourceOptionsclasses.
2.0.0-dev.1 #
- FEAT: The
SignalBuilderwidget now automatically tracks theSignals used in thebuilderfunction allowing you to react to N signals at the same time. See the migration guide. - BREAKING CHANGE: Removed
DualSignalBuilderandTripleSignalBuilderin favor ofSignalBuilder. - BREAKING CHANGE: Removed
ResourceBuilderin favor ofSignalBuilder. See the migration guide. - CHORE: Improved
Solidwidget performance by more than 3000% in finding ancestor providers.
Changes from solidart #
- FEAT: Add
batchfunction to execute a callback that will not side-effect until its top-most batch is completed. See docs here - CHORE: Add
trackInDevToolstoSignalOptionsandResourceOptionsto disable the DevTools tracking for specific signals and resources, defaults toSolidartConfig.devToolsEnabled.
1.7.1 #
- Update dependencies
1.6.1 #
Changes from solidart #
- BUGFIX: The method
didUpdateSignalofSolidartObserverwas not triggered for collections.
1.6.0 #
Changes from solidart #
- FEAT: Create
SolidartConfigwhich you can use to customize theautoDisposeof all the tracking system and andobservers. - BUGFIX: Removed the internal
ResourceUnresolvedstate so you can easily use theResourceStatesealed class.
1.5.0 #
Changes from solidart #
- FEAT: Automatic disposal, see the docs here
1.4.3 #
Changes from solidart #
- BUGFIX: Fix the
updatemethod of aResourcethat triggeredreportObserved.
1.4.2 #
Update solidart version
1.4.1 #
Changes from solidart #
- BUGFIX: Fix the
updateValuemethod of aSignalthat triggeredreportObserved. (thanks to @9dan)
1.4.0 #
- CHORE: Rename
SolidProviderintoProvider. - REFACTOR: Remove
SolidSignalin favor ofProvider.
1.3.0 #
Changes from solidart #
-
FEAT: Add 3 new signals:
ListSignal,SetSignalandMapSignal. Now you can easily be notified of every change of a list, set or map. Before:final list = Signal([1, 2]); // this doesn't work list.add(3); // instead you have to provide a new list instance list.value = [...list, 3];Now:
final list = ListSignal([1, 2]); // this now works as expected list.add(3); -
CHORE: Rename the
firstWheremethod of aReadSignalintountil -
CHORE: Rename the
firstWhereReadymethod of aResourceintountilReady -
CHORE: Rename the
updatemethod of aSignalintoupdateValue -
CHORE: Deprecate
createSignal,createComputed,createEffectandcreateResource
1.2.0 #
- FEAT: Add the method
maybeGet()to theSolidwidget to get a provider. If the provider can't be found, returnsnullinstead of throwing likeget()does
1.1.0 #
Changes from solidart #
- BUGFIX: Fix a bug in the
Resourcewhere the stream subscription was not disposed correctly
1.0.0 #
The core of the library has been rewritten in order to support automatic dependency tracking like SolidJS.
-
The
Showwidget now takes a functions that returns abool. You can easily convert any type tobool, for example:final count = createSignal(0); @override Widget build(BuildContext context) { return Show( when: () => count() > 5, builder: (context) => const Text('Count is greater than 5'), fallback: (context) => const Text('Count is lower than 6'), ); } -
Converting a
ValueNotifierinto aSignalnow uses theequalscomparator to keep the consistency. -
Rename
resourceparameter ofResourceWidgetBuilderintoresourceState. (thanks to @manuel-plavsic) -
FEAT Allow multiple providers of the same type by specifying an
identifier.Provider declaration: #
SolidProvider<NumberProvider>( create: () => const NumberProvider(1), id: 1, ), SolidProvider<NumberProvider>( create: () => const NumberProvider(10), id: 2, ),Access a specific provider #
final numberProvider1 = context.get<NumberProvider>(1); final numberProvider2 = context.get<NumberProvider>(2); -
BREAKING CHANGE Removed the
signalsmap fromSolid, now to provide signals to descendants useSolidSignalinside providers:Before:
Solid( signals: { SignalId.themeMode: () => createSignal<ThemeMode>(ThemeMode.light), }, ),Now:
Solid( providers: [ SolidSignal<Signal<ThemeMode>>(create: () => createSignal(ThemeMode.light)), ], ), -
FEAT You can access a specific
Signalwithout specifing anidentifier, for example:// to get the signal context.get<Signal<ThemeMode>>(); // to observe the signal's value context.observe<ThemeMode>()NOTICE: If you have multiple signals of the same type, you must specify a different
idfor each one. -
FEAT: Now you can get any instance of (any subclass of) the provider type.
-
FEAT: The
Solidwidget now acceps abuildermethod that provides a descendant context. -
CHORE: The
ResourceBuilderno longer resolves the resource, because now theResourceknows when to resolve automatically.
Changes from solidart #
-
FEAT: Add automatic dependency tracking
-
BREAKING CHANGE: To create derived signals now you should use
createComputedinstead ofsignalName.selectThis allows you to derive from many signals instead of only 1.Before:
final count = createSignal(0); final doubleCount = count.select((value) => value * 2);Now:
final count = createSignal(0); final doubleCount = createComputed(() => count() * 2); -
FEAT: The
createEffectno longer needs asignalsarray, it automatically track each signal.Before:
final effect = createEffect(() { print('The counter is now ${counter.value}'); }, signals: [counter]);Now:
final disposeFn = createEffect((disposeFn) { print('The counter is now ${counter.value}'); }) -
BREAKING CHANGE: The
fireImmediatelyfield on effects has been removed. Now an effect runs immediately by default. -
FEAT: Add
observemethod onSignal. Use it to easily observe the previous and current value instead of creating an effect.final count = createSignal(0); final disposeFn = count.observe((previousValue, value) { print('The counter changed from $previousValue to $value'); }, fireImmediately: true); -
FEAT: Add
firstWheremethod onSignal. It returns a future that completes when the condition evaluates to true and it returns the current signal value.final count = createSignal(0); // wait until the count is greater than 5 final value = await count.firstWhere((value) => value > 5); -
FEAT: Add
firstWhereReadymethod onResource. Now you can wait until the resource is ready.final resource = createResource(..); final data = await resource.firstWhereReady(); -
FEAT: The
Resourcenow acceptsResourceOptions. You can customize thelazyvalue of the resource (defaults to true), if you want your resource to resolve immediately. -
CHORE:
ResourceValuehas been renamed intoResourceState. Now you can get the state of the resource with thestategetter. -
CHORE: Move
refreshingfromResourceWidgetBuilderinto theResourceState. (thanks to @manuel-plavsic) -
FEAT: Add
hasPreviousValuegetter toReadSignal. (thanks to @manuel-plavsic) -
FEAT Before, only the
fetcherreacted to thesource. Now also thestreamreacts to thesourcechanges by subscribing again to the stream. In addition, thestreamparameter of the Resource has been changed fromStreaminto aStream Function()in order to be able to listen to a new stream if it changed. -
FEAT: Add the
selectmethod on theResourceclass. Theselectfunction allows filtering theResource's data by reading only the properties that you care about. The advantage is that you keep handling the loading and error states. -
FEAT: Make the
Resourceto auto-resolve when accessing itsstate. -
CHORE: The
refetchmethod of aResourcehas been renamed torefresh. -
FEAT: You can decide whether to use
createSignal()or directly theSignal()constructor, now the're equivalent. The same applies to all the othercreatefunctions.
1.0.0-dev903 #
- FEAT: The
Solidwidget now acceps abuildermethod that provides a descendant context. - CHORE: The
ResourceBuilderno longer resolves the resource, because now theResourceknows when to resolve automatically.
Changes from solidart #
- FEAT: Add the select method on the Resource class. The select function allows filtering the Resource's data by reading only the properties that you care about. The advantage is that you keep handling the loading and error states.
- FEAT: Make the Resource to auto-resolve when accessing its state
1.0.0-dev902 #
- CHORE: Deprecate the value setter in the
Resourcein favor of the state setter
1.0.0-dev901 #
- FEAT: Now you can get any instance of (any subclass of) the provider type.
1.0.0-dev9 #
- FIX: A small fix of the
Solidwidget now allows to correctly retrieve aComputedsignal
Changes from solidart #
- CHORE:
createComputednow returns aComputedclass instead of aReadSignal.
1.0.0-dev8 #
-
FEAT Allow multiple providers of the same type by specifying an
identifier.Provider declaration: #
SolidProvider<NumberProvider>( create: () => const NumberProvider(1), id: 1, ), SolidProvider<NumberProvider>( create: () => const NumberProvider(10), id: 2, ),Access a specific provider #
final numberProvider1 = context.get<NumberProvider>(1); final numberProvider2 = context.get<NumberProvider>(2); -
BREAKING CHANGE Removed the
signalsmap fromSolid, now to provide signals to descendants useSolidSignalinside providers:Before:
Solid( signals: { SignalId.themeMode: () => createSignal<ThemeMode>(ThemeMode.light), }, ),Now:
Solid( providers: [ SolidSignal<Signal<ThemeMode>>(create: () => createSignal(ThemeMode.light)), ], ), -
FEAT You can access a specific Signal without specifing an
identifier, for example:// to get the signal context.get<Signal<ThemeMode>>(); // to observe the signal's value context.observe<ThemeMode>()NOTICE: If you have multiple signals of the same type, you must specify a different
idfor each one.
1.0.0-dev7 #
Changes from solidart #
- FEAT Before, only the
fetcherreacted to thesource. Now also thestreamreacts to thesourcechanges by subscribing again to the stream. In addition, thestreamparameter of the Resource has been changed fromStreaminto aStream Function()in order to be able to listen to a new stream if it changed
1.0.0-dev6 #
Changes from solidart #
- BUGFIX Refactor the core of the library in order to fix issues with
previousValueandhasPreviousValueofComputedand simplify the logic.
1.0.0-dev5 #
- Rename
resourceparameter ofResourceWidgetBuilderintoresourceState. (thanks to @manuel-plavsic)
Changes from solidart #
- Move
refreshingfromResourceWidgetBuilderinto theResourceState. (thanks to @manuel-plavsic) - Add
hasPreviousValuegetter toReadSignal. (thanks to @manuel-plavsic)
1.0.0-dev4 #
- Converting a
ValueNotifierinto aSignalnow uses theequalscomparator to keep the consistency.
Changes from solidart #
Deprecate value getter in the Resource. Use state instead.
1.0.0-dev3 #
Add SolidSignalOptions and SolidResourceOptions for signals and resources provided through the Solid widget.
With this field you can customize the autoDispose of each Solid signal individually. (Defaults to true).
Changes from solidart #
-
Rename
untilintofirstWhere -
Rename
untilReadyintofirstWhereReady -
FEAT: add
wheremethod toSignal. It returns a newReadSignalwith the values filtered bycondition. Use it to filter the value of another signal, e.g.:final loggedInUser = user.where((value) => value != null);The initial value may be null because a
Signalmust always start with an initial value. The following values will always satisfy the condition. The returnedReadSignalwill automatically dispose when the parent signal disposes.
1.0.0-dev2 #
The Show widget now takes a functions that returns a bool.
You can easily convert any type to bool, for example:
final count = createSignal(0);
@override
Widget build(BuildContext context) {
return Show(
when: () => count() > 5,
builder: (context) => const Text('Count is greater than 5'),
fallback: (context) => const Text('Count is lower than 6'),
);
}
1.0.0-dev1 #
This is a development preview of the 1.0.0 release of solidart. The core of the library has been rewritten in order to support automatic dependency tracking like SolidJS.
-
FEAT: Add automatic dependency tracking
-
BREAKING CHANGE: To create derived signals now you should use
createComputedinstead ofsignalName.selectThis allows you to derive from many signals instead of only 1.Before:
final count = createSignal(0); final doubleCount = count.select((value) => value * 2);Now:
final count = createSignal(0); final doubleCount = createComputed(() => count() * 2); -
FEAT: The
createEffectno longer needs asignalsarray, it automatically track each signal.Before:
final effect = createEffect(() { print('The counter is now ${counter.value}'); }, signals: [counter]);Now:
final disposeFn = createEffect((disposeFn) { print('The counter is now ${counter.value}'); }) -
BREAKING CHANGE: The
createEffectmethod no longer returns anEffect, you cannot pause or resume it anymore. Instead it returns aDisposecallback which you can call when you want to stop it. You can also dispose an effect from the inside of the callback. -
BREAKING CHANGE: The
fireImmediatelyfield on effects has been removed. Now an effect runs immediately by default. -
FEAT: Add
observemethod onSignal. Use it to easily observe the previous and current value instead of creating an effect.final count = createSignal(0); final disposeFn = count.observe((previousValue, value) { print('The counter changed from $previousValue to $value'); }, fireImmediately: true); -
FEAT: Add
untilmethod onSignal. It returns a future that completes when the condition evaluates to true and it returns the current signal value.final count = createSignal(0); // wait until the count is greater than 5 final value = await count.until((value) => value > 5); -
FEAT: Add
untilReadymethod onResource. Now you can wait until the resource is ready.final resource = createResource(..); final data = await resource.untilReady(); -
FEAT: The
Resourcenow acceptsResourceOptions. You can customize thelazyvalue of the resource (defaults to true), if you want your resource to resolve immediately. -
CHORE:
ResourceValuehas been renamed intoResourceState. Now you can get the state of the resource with thestategetter. -
FEAT: Add
toValueNotifier()extension toSignalto easily convert it to aValueNotifier. -
FEAT: Add
toSignal()extension toValueNotifierto easily convert it to aSignal.
0.4.2 #
- BUGFIX: The
Showwidget now can work again with aReadSignal.
0.4.1 #
- CHORE: The
ResourceBuildernow correctly handles a differentResourcewhen the widget is updated.
0.4.0 #
- BUGFIX: Listening to the
sourceof a Resource was not stopped when thesourcedisposed. - BUGFIX: A
Resourcewould not perform the asynchronous operation until someone called thefetchmethod, typically theResourceBuilderwidget. This did not apply to thestreamwhich was listened to when the resource was created. Now the behaviour has been merged and thefetchmethod has been renamed intoresolve. - CHORE: Renamed
ReadableSignalintoReadSignal. - CHORE: Renamed the
readablemethod of aSignalintotoReadSignal()
0.3.3 #
-
Add
updateextension onBuildContext. It's a convenience method to update aSignalvalue.You can use it to update a signal value, e.g:
context.update<int>('counter', (value) => value * 2);This is equal to:
// retrieve the signal final signal = context.get<Signal<int>>('counter'); // update the signal signal.update((value) => value * 2);but shorter when you don't need the signal for anything else.
0.3.2 #
- Add assert to resource
fetchmethod to prevent multiple fetches of the same resource. - Fix
ResourceBuilderthat fetched the resource every time even if the resource was already resolved.
0.3.1 #
- The
selectmethod of a signal now can take a customoptionsparameter to customize its behaviour. - Fixed an invalid assert in the
ResourceBuilderwidget that happens for resources without a fetcher.
0.3.0 #
-
Now Solid can deal also with
SolidProviders. You no longer need an external dependency injector library. I decided to put some boundaries and stop suggesting any external dependency injector library. This choice is due to the fact that external libraries in turn provide state management and the user is more likely to mistakenly use solidart. I simplified the usage of InheritedWidgets with a very nice API:Declare providers #
Solid( providers: [ SolidProvider<NameProvider>( create: () => const NameProvider('Ale'), // the dispose method is fired when the [Solid] widget above is removed from the widget tree. dispose: (provider) => provider.dispose(), ), SolidProvider<NumberProvider>( create: () => const NumberProvider(1), // Do not create the provider lazily, but immediately lazy: false, ), ], child: const SomeChildThatNeedsProviders(), )Retrieve providers #
final nameProvider = context.get<NameProvider>(); final numberProvider = context.get<NumberProvider>();Provide providers to modals (dialogs, bottomsheets) #
return showDialog( context: context, builder: (dialogContext) => Solid.value( // pass a context that has access to providers context: context, // pass the list of provider [Type]s providerTypes: const [NameProvider], child: Dialog( child: Builder(builder: (innerContext) { // retrieve the provider with the innerContext final nameProvider = innerContext.get<NameProvider>(); return SizedBox.square( dimension: 100, child: Center( child: Text('name: ${nameProvider.name}'), ), ); }), ), ), );You cannot provide multiple providers of the same type in the same Solid widget.
0.2.2 #
createResourcenow accepts astreamand can be used to wrap a Stream and correctly handle its state.
0.2.1 #
- Get a signal value with
signalName().
0.2.0+1 #
- Add documentation link inside the pubspec
0.2.0 #
- Documentation improvements
- Refactor Resource, now the
createResourcemethod takes only 1 generic, the type of the future result.// before final resource = createResource<SourceValueType, FetcherValueType>(fetcher: fetcher, source: source); // now final resource = createResource<FetcherValueType>(fetcher: fetcher, source: source); // the FetcherValueType can be inferred by Dart >=2.18.0, so you can omit it
0.1.4 #
- Add official documentation link
- Fix typo in fireImmediately argument name
0.1.3 #
- Now
Solid.valuetakes a list of [signalIds] and a [BuildContext]. You don't need anymore to get the signal first and pass it toSolid.value. - Set the minimum Dart SDK version to
2.18.
0.1.2+1 #
- Update Readme
0.1.2 #
- Add code coverage
0.1.1 #
- Implement Solid.value to be able to pass Signals to modals
0.1.0+4 #
- Add links to examples
0.1.0+3 #
- Specify the type of resource to the ResourceBuilder
0.1.0+2 #
- Decrease minimum Dart version to 2.17.0
0.1.0+1 #
- Fix home page link
0.1.0 #
- Initial version