Restrict expression parsing to formatString, and simplify DataModel#733
Merged
gspencergoog merged 1 commit intoflutter:feature/v0.9-migrationfrom Feb 19, 2026
Merged
Conversation
4892583 to
960fbc3
Compare
- Fix infinite loop in `_notifySubscribers` when handling relative paths. - Ensure `subscribeStream` disposes of underlying `ValueNotifier`. - Dispose source notifiers in `_ToStringNotifier`, `_ToBoolNotifier`, `_ToNumberNotifier`. - Fix `image_test.dart` to properly mock `HttpClient` and use `errorBuilder` in `Image` widget. - Update `audio_player_test.dart` to match current implementation. - Apply minor formatting fixes in `travel_app`. - Pass absolutePath to _checkType for more accurate error reporting. - Refactor catalog widgets to use BoundValue/BoundString for lifecycle safety - Replaced explicit `subscribeTo*` calls with `Bound*` widgets across `genui` and `travel_app` catalog widgets. - Introduced `BoundObject` in `widget_utilities.dart` to handle generic object binding. - Removed `subscribeTo*` extension methods from `widget_utilities.dart` to prevent misuse and memory leaks. - Fixed `choice_picker.dart` to use `BoundObject` instead of abstract `BoundValue`. - `DataModel` is now an `abstract interface class`. - `InMemoryDataModel` provides the concrete implementation. - `DataPath` is required for `update`, `subscribe`, and `getValue` operations. - `DataModel.bindExternalState` now returns a disposal function for easier cleanup. - `ExpressionParser` updated to return `Stream<String>` consistently for string interpolation. - Added `DataModelTypeException` for runtime type mismatches in `getValue`. - Updated `travel_app` and tests to reflect these API changes. - Renamed `DataContext.evaluate` to `resolve` and ensured it always returns `Stream<Object?>`. - Removed implicit expression parsing from `DataModel.getValue` and `subscribe`. They now only accept paths. - Moved `ExpressionParser` logic to `lib/src/functions/format_string.dart` and restricted its usage to `FormatStringFunction`. - Updated `WidgetUtilities` to use `resolve` via `resolveContext` and handle stream subscriptions correctly. - Updated `Button`, `TextField`, and `ValidationHelper` to await `resolve` results. - Updated `travel_app` and `genui` tests to reflect these changes. - Fixed `DataModel` to handle empty argument lists in function calls to prevent stalled streams. - Fixed async error handling in `Surface` and associated tests.
e246c92 to
c107f49
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refactor
evaluatetoresolveand restrict expression parsing.Also, this change refactors the
DataModelAPI to be an abstract interface, withInMemoryDataModelas the default implementation. It enforces the use ofDataPathfor all path-based operations, improving type safety and reducing string parsing overhead.Key changes:
DataModelis now anabstract interface class.InMemoryDataModelprovides the concrete implementation.DataPathis required forupdate,subscribe, andgetValueoperations.DataModel.bindExternalStatenow returns a disposal function for easier cleanup.ExpressionParserupdated to returnStream<String>consistently for string interpolation.DataModelTypeExceptionfor runtime type mismatches ingetValue.travel_appand tests to reflect these API changes.DataContext.evaluatetoresolveand ensured it always returnsStream<Object?>.DataModel.getValueandsubscribe. They now only accept paths.ExpressionParserlogic tolib/src/functions/format_string.dartand restricted its usage toFormatStringFunction.WidgetUtilitiesto useresolveviaresolveContextand handle stream subscriptions correctly.Button,TextField, andValidationHelperto awaitresolveresults.travel_appandgenuitests to reflect these changes.DataModelto handle empty argument lists in function calls to prevent stalled streams.Surfaceand associated tests.