From 91854a7e0e2fca45ddedb99e2b0a7c1597ad1fc6 Mon Sep 17 00:00:00 2001 From: Matej Valenta Date: Mon, 18 Nov 2024 17:35:59 +0100 Subject: [PATCH 1/3] fix: add key to public constructor of GladeModelProvider --- glade_forms/lib/src/widgets/glade_model_provider.dart | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/glade_forms/lib/src/widgets/glade_model_provider.dart b/glade_forms/lib/src/widgets/glade_model_provider.dart index 19c2198..6217156 100644 --- a/glade_forms/lib/src/widgets/glade_model_provider.dart +++ b/glade_forms/lib/src/widgets/glade_model_provider.dart @@ -10,8 +10,8 @@ class GladeModelProvider extends StatelessWidget { final M? value; final Widget child; - factory GladeModelProvider({required CreateModelFunction create, required Widget child}) => - GladeModelProvider._(create: create, child: child); + factory GladeModelProvider({required CreateModelFunction create, required Widget child, Key? key}) => + GladeModelProvider._(create: create, key: key, child: child); const GladeModelProvider._({ required this.child, @@ -20,8 +20,8 @@ class GladeModelProvider extends StatelessWidget { super.key, }); - factory GladeModelProvider.value({required M value, required Widget child}) => - GladeModelProvider._(value: value, child: child); + factory GladeModelProvider.value({required M value, required Widget child, Key? key}) => + GladeModelProvider._(value: value, key: key, child: child); @override Widget build(BuildContext context) { From e9e4d456cc550a2fdc7095c02acd35778ae781e0 Mon Sep 17 00:00:00 2001 From: Matej Valenta Date: Wed, 20 Nov 2024 21:44:31 +0100 Subject: [PATCH 2/3] chore: update dcm --- .github/workflows/ci.yaml | 1 + dcm_global.yaml | 1 + 2 files changed, 2 insertions(+) create mode 100644 dcm_global.yaml diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 058c374..e47f8d8 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -24,6 +24,7 @@ jobs: uses: CQLabs/setup-dcm@v1 with: github_token: ${{ secrets.GITHUB_TOKEN }} + version: 1.24.2 - uses: bluefireteam/melos-action@v2 diff --git a/dcm_global.yaml b/dcm_global.yaml new file mode 100644 index 0000000..8f4b791 --- /dev/null +++ b/dcm_global.yaml @@ -0,0 +1 @@ +version: "1.24.2" From 953864bcda151682e2d27a2ac7b297b520fd28d3 Mon Sep 17 00:00:00 2001 From: Matej Valenta Date: Wed, 20 Nov 2024 22:00:20 +0100 Subject: [PATCH 3/3] chore: fix DCM on GladeInput --- glade_forms/README.md | 2 +- glade_forms/lib/src/core/glade_input.dart | 34 +++++++++++------------ 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/glade_forms/README.md b/glade_forms/README.md index 90184cd..1fe4089 100644 --- a/glade_forms/README.md +++ b/glade_forms/README.md @@ -128,7 +128,7 @@ On each input we can define - **validator** - Input's value must satisfy validation to be *valid* input. - **translateError** - If there are validation errors, this function is use to translate those errors. - **dependencies** (WIP) - Each input can depend on another inputs for listening changes. - - **stringTovalueConverter** - If input is used by TextField and `T` is not a `String`, value converter should be provided. + - **stringToValueConverter** - If input is used by TextField and `T` is not a `String`, value converter should be provided. - **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. Note that GladeForms handle deep equality of collections and assumes that complex types are comparable by values. - **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. diff --git a/glade_forms/lib/src/core/glade_input.dart b/glade_forms/lib/src/core/glade_input.dart index 675c2c0..3646048 100644 --- a/glade_forms/lib/src/core/glade_input.dart +++ b/glade_forms/lib/src/core/glade_input.dart @@ -35,14 +35,14 @@ class GladeInput { final ValidatorInstance validatorInstance; @protected - final StringToTypeConverter? stringTovalueConverter; + final StringToTypeConverter? stringToValueConverter; // ignore: prefer-correct-callback-field-name, ok name final InputDependenciesFactory dependenciesFactory; /// An input's identification. /// - /// Used within listener changes and dependency related funcions such as validation. + /// Used within listener changes and dependency related functions such as validation. final String inputKey; // ignore: prefer-correct-callback-field-name, ok name @@ -120,7 +120,7 @@ class GladeInput { bool get hasConversionError => __conversionError != null; /// String representattion of [value]. - String get stringValue => stringTovalueConverter?.convertBack(value) ?? value.toString(); + String get stringValue => stringToValueConverter?.convertBack(value) ?? value.toString(); bool get _valueIsSameAsInitialValue { if (identical(value, initialValue)) return true; @@ -153,7 +153,7 @@ class GladeInput { required this.valueComparator, required String? inputKey, required this.translateError, - required this.stringTovalueConverter, + required this.stringToValueConverter, required InputDependenciesFactory? dependenciesFactory, required this.defaultTranslations, required this.onChange, @@ -178,7 +178,7 @@ class GladeInput { ? TextEditingController( text: switch (value) { final String? x => x, - != null => stringTovalueConverter?.convertBack(value), + != null => stringToValueConverter?.convertBack(value), _ => null, }, ) @@ -234,7 +234,7 @@ class GladeInput { translateError: translateError, valueComparator: valueComparator, inputKey: inputKey, - stringTovalueConverter: valueConverter, + stringToValueConverter: valueConverter, dependenciesFactory: dependencies, onChange: onChange, onDependencyChange: onDependencyChange, @@ -358,7 +358,7 @@ class GladeInput { valueComparator: valueComparator, inputKey: inputKey, dependenciesFactory: dependencies, - stringTovalueConverter: GladeTypeConverters.intConverter, + stringToValueConverter: GladeTypeConverters.intConverter, onChange: onChange, onDependencyChange: onDependencyChange, textEditingController: textEditingController, @@ -439,7 +439,7 @@ class GladeInput { textEditingController: textEditingController, useTextEditingController: useTextEditingController, valueComparator: valueComparator, - stringTovalueConverter: null, + stringToValueConverter: null, valueTransform: valueTransform, trackUnchanged: trackUnchanged, ); @@ -457,7 +457,7 @@ class GladeInput { // ignore: avoid-non-null-assertion, it is not null if (hasConversionError) return _translateConversionError(__conversionError!); - return validatorResult.isInvalid ? _translate() ?? '' : ''; + return validatorResult.isInvalid ? (_translate() ?? '') : ''; } /// Shorthand validator for TextFieldForm inputs. @@ -466,10 +466,10 @@ class GladeInput { /// If there are multiple errors they are concenated into one string with [delimiter]. String? textFormFieldInputValidatorCustom(String? value, {String delimiter = '.'}) { assert( - TypeHelper.typesEqual() || TypeHelper.typesEqual() || stringTovalueConverter != null, + TypeHelper.typesEqual() || TypeHelper.typesEqual() || stringToValueConverter != null, 'For non-string values [converter] must be provided. TInput type: $T', ); - final converter = stringTovalueConverter ?? _defaultConverter; + final converter = stringToValueConverter ?? _defaultConverter; try { final convertedValue = converter.convert(value); @@ -497,11 +497,11 @@ class GladeInput { void updateValueWithString(String? strValue, {bool shouldTriggerOnChange = true}) { assert( - TypeHelper.typesEqual() || TypeHelper.typesEqual() || stringTovalueConverter != null, + TypeHelper.typesEqual() || TypeHelper.typesEqual() || stringToValueConverter != null, 'For non-string values [converter] must be provided. TInput type: ${T.runtimeType}', ); - final converter = stringTovalueConverter ?? _defaultConverter; + final converter = stringToValueConverter ?? _defaultConverter; try { if (_useTextEditingController) { @@ -589,7 +589,7 @@ class GladeInput { String? inputKey, ValueComparator? valueComparator, ValidatorInstance? validatorInstance, - StringToTypeConverter? stringTovalueConverter, + StringToTypeConverter? stringToValueConverter, InputDependenciesFactory? dependenciesFactory, T? initialValue, ErrorTranslator? translateError, @@ -608,7 +608,7 @@ class GladeInput { value: value ?? this.value, valueComparator: valueComparator ?? this.valueComparator, validatorInstance: validatorInstance ?? this.validatorInstance, - stringTovalueConverter: stringTovalueConverter ?? this.stringTovalueConverter, + stringToValueConverter: stringToValueConverter ?? this.stringToValueConverter, dependenciesFactory: dependenciesFactory ?? this.dependenciesFactory, inputKey: inputKey ?? this.inputKey, initialValue: initialValue ?? this.initialValue, @@ -629,7 +629,7 @@ class GladeInput { } void _syncValueWithController(T value, {required bool shouldTriggerOnChange}) { - final converter = stringTovalueConverter ?? _defaultConverter; + final converter = stringToValueConverter ?? _defaultConverter; try { _controllerTriggersOnChange = shouldTriggerOnChange; @@ -647,7 +647,7 @@ class GladeInput { // If using text controller - sync its value void _onTextControllerChange() { - final converter = stringTovalueConverter ?? _defaultConverter; + final converter = stringToValueConverter ?? _defaultConverter; try { final convertedValue = converter.convert(controller?.text);