Skip to content

Commit

Permalink
Pass value into controller
Browse files Browse the repository at this point in the history
  • Loading branch information
petrnymsa committed Nov 3, 2023
1 parent e3715ae commit 30577cb
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
3 changes: 3 additions & 0 deletions glade_forms/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 1.2.1
- **[Fix]**: Value passed to factory constructor is not reflected in TextController.

## 1.2.0
- **[Feat]**: Add `GladeFormListener` widget allowing to listen for model's changes
- **[Feat]**: Add `groupEdit()` method in GladeModel allows to update multiple inputs at once.
Expand Down
6 changes: 4 additions & 2 deletions glade_forms/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,14 @@ For simplicity we will interchange `input` and `GladeInput<T>`.
Every input is *dirty* or *pure* based on whether value was updated (or not, yet).

On each input we can define
- **value** - Current input's value
- **initialValue** - Cached initial value. Used with valueComparator.
- **validator** - Input's value must satisfy validation to be *valid* input.
- **translateError** - If there are validation errors, function for error translations can be provided.
- **inputKey** - For debug purposes and dependencies, each input can have unique name for simple identification.
- **inputKey** - Unique identification of each input. Used inside listeners or in dependencies.
- **dependencies** - Each input can depend on another inputs for validation.
- **stringTovalueConverter** - If input is used by TextField and `T` is not a `String`, value converter should be provided.
- **valueComparator** - Sometimes it is handy to provied `initialValue` which will be never updated after input is mutated. `valueComparator` should be provided to compare `initialValue` and `value` if `T` is not comparable type by default.
- **valueComparator** - Sometimes it is handy to provide `initialValue` which will be never updated after input is mutated. `valueComparator` should be provided to compare `initialValue` and `value` if `T` is not comparable type by default.
- **valueTransform** - transform `T` value into different `T` value. An example of usage can be sanitazation of string input (trim(),...).
- **defaultTranslation** - If error's translations are simple, the default translation settings can be set instead of custom `translateError` method.
- **textEditingController** - It is possible to provide custom instance of controller instead of default one.
Expand Down
4 changes: 2 additions & 2 deletions glade_forms/lib/src/core/glade_input.dart
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,9 @@ class GladeInput<T> extends ChangeNotifier {
_textEditingController = textEditingController ??
(createTextController
? TextEditingController(
text: switch (initialValue) {
text: switch (value) {
final String? x => x,
!= null => stringTovalueConverter?.convertBack(initialValue),
!= null => stringTovalueConverter?.convertBack(value),
_ => null,
},
)
Expand Down
2 changes: 1 addition & 1 deletion glade_forms/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: glade_forms
description: A universal way to define form validators with support of translations.
version: 1.2.0
version: 1.2.1
repository: https://github.com/netglade/glade_forms
issue_tracker: https://github.com/netglade/glade_forms/issues
screenshots:
Expand Down

0 comments on commit 30577cb

Please sign in to comment.