Skip to content

Commit

Permalink
Update Flutter dependencies
Browse files Browse the repository at this point in the history
- Update Reactive Forms version to 17.0
- Update Flutter version >=3.16.0
- Update Dart version >=3.2.4 <4.0.0
- Replace deprecated WillPopScope with PopScope
- Fix the use super parameters
  • Loading branch information
joanpablo committed Mar 29, 2024
1 parent 2c5b405 commit 552a7ac
Show file tree
Hide file tree
Showing 42 changed files with 140 additions and 251 deletions.
3 changes: 1 addition & 2 deletions example/lib/sample_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ class SampleScreen extends StatelessWidget {
final Widget body;
final Widget? title;

const SampleScreen({Key? key, required this.body, this.title})
: super(key: key);
const SampleScreen({super.key, required this.body, this.title});

@override
Widget build(BuildContext context) {
Expand Down
4 changes: 2 additions & 2 deletions example/lib/samples/add_dynamic_controls_sample.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ class ViewModelProvider extends InheritedWidget {

ViewModelProvider({
required this.viewModel,
required Widget child,
}) : super(child: child);
required super.child,
});

static NewContactViewModel? of(BuildContext context) =>
context.findAncestorWidgetOfExactType<ViewModelProvider>()?.viewModel;
Expand Down
14 changes: 5 additions & 9 deletions example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,34 +18,30 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
version: 1.0.0+1

environment:
sdk: ">=2.17.0 <3.0.0"
flutter: ">=3.0.0"
sdk: ">=3.2.4 <4.0.0"
flutter: ">=3.16.0"

dependencies:
flutter:
sdk: flutter
intl: ^0.18.0
intl: ^0.19.0
reactive_forms:
path: ../
#reactive_forms_widgets: ^0.3.1

# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^1.0.5
cupertino_icons: ^1.0.6
#reactive_dropdown_search: ^0.9.0
#reactive_touch_spin: ^0.6.0
#reactive_segmented_control: ^0.4.0
#reactive_date_time_picker: ^0.4.0

dev_dependencies:
lints: ^2.0.0
flutter_lints: ^3.0.2
flutter_test:
sdk: flutter

dependency_overrides:
reactive_forms:
path: ../

# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec

Expand Down
51 changes: 17 additions & 34 deletions lib/src/models/models.dart
Original file line number Diff line number Diff line change
Expand Up @@ -833,18 +833,12 @@ class FormControl<T> extends AbstractControl<T> {
///
FormControl({
T? value,
List<Validator<dynamic>> validators = const [],
List<AsyncValidator<dynamic>> asyncValidators = const [],
int asyncValidatorsDebounceTime = 250,
bool touched = false,
bool disabled = false,
}) : super(
validators: validators,
asyncValidators: asyncValidators,
asyncValidatorsDebounceTime: asyncValidatorsDebounceTime,
disabled: disabled,
touched: touched,
) {
super.validators,
super.asyncValidators,
super.asyncValidatorsDebounceTime,
super.touched,
super.disabled,
}) {
if (value != null) {
this.value = value;
} else {
Expand Down Expand Up @@ -1039,16 +1033,11 @@ class FormControl<T> extends AbstractControl<T> {
/// that emits events each time you add or remove a control to the collection.
abstract class FormControlCollection<T> extends AbstractControl<T> {
FormControlCollection({
List<Validator<dynamic>> validators = const [],
List<AsyncValidator<dynamic>> asyncValidators = const [],
int asyncValidatorsDebounceTime = 250,
bool disabled = false,
}) : super(
validators: validators,
asyncValidators: asyncValidators,
asyncValidatorsDebounceTime: asyncValidatorsDebounceTime,
disabled: disabled,
);
super.validators,
super.asyncValidators,
super.asyncValidatorsDebounceTime,
super.disabled,
});

final _collectionChanges =
StreamController<List<AbstractControl<Object?>>>.broadcast();
Expand Down Expand Up @@ -1156,17 +1145,14 @@ class FormGroup extends FormControlCollection<Map<String, Object?>> {
/// See also [AbstractControl.validators]
FormGroup(
Map<String, AbstractControl<dynamic>> controls, {
List<Validator<dynamic>> validators = const [],
List<AsyncValidator<dynamic>> asyncValidators = const [],
int asyncValidatorsDebounceTime = 250,
super.validators,
super.asyncValidators,
super.asyncValidatorsDebounceTime,
bool disabled = false,
}) : assert(
!controls.keys.any((name) => name.contains(_controlNameDelimiter)),
'Control name should not contain dot($_controlNameDelimiter)'),
super(
validators: validators,
asyncValidators: asyncValidators,
asyncValidatorsDebounceTime: asyncValidatorsDebounceTime,
disabled: disabled,
) {
addAll(controls);
Expand Down Expand Up @@ -1670,14 +1656,11 @@ class FormArray<T> extends FormControlCollection<List<T?>> {
/// See also [AbstractControl.validators]
FormArray(
List<AbstractControl<T>> controls, {
List<Validator<dynamic>> validators = const [],
List<AsyncValidator<dynamic>> asyncValidators = const [],
int asyncValidatorsDebounceTime = 250,
super.validators,
super.asyncValidators,
super.asyncValidatorsDebounceTime,
bool disabled = false,
}) : super(
validators: validators,
asyncValidators: asyncValidators,
asyncValidatorsDebounceTime: asyncValidatorsDebounceTime,
disabled: disabled,
) {
addAll(controls);
Expand Down
4 changes: 2 additions & 2 deletions lib/src/widgets/inherited_streamer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import 'dart:async';
import 'package:flutter/material.dart';

abstract class InheritedStreamer<T> extends InheritedWidget {
const InheritedStreamer(this.stream, Widget child, {Key? key})
: super(key: key, child: child);
const InheritedStreamer(this.stream, Widget child, {super.key})
: super(child: child);

final Stream<T> stream;

Expand Down
12 changes: 4 additions & 8 deletions lib/src/widgets/reactive_checkbox.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ class ReactiveCheckbox extends ReactiveFocusableFormField<bool, bool> {
/// For documentation about the various parameters, see the [Checkbox] class
/// and the [Checkbox] constructor.
ReactiveCheckbox({
Key? key,
String? formControlName,
FormControl<bool>? formControl,
super.key,
super.formControlName,
super.formControl,
bool tristate = false,
Color? activeColor,
Color? checkColor,
Expand All @@ -36,16 +36,12 @@ class ReactiveCheckbox extends ReactiveFocusableFormField<bool, bool> {
MaterialStateProperty<Color?>? fillColor,
MaterialStateProperty<Color?>? overlayColor,
double? splashRadius,
FocusNode? focusNode,
super.focusNode,
OutlinedBorder? shape,
BorderSide? side,
ReactiveFormFieldCallback<bool>? onChanged,
ShowErrorsFunction<bool>? showErrors,
}) : super(
key: key,
formControl: formControl,
formControlName: formControlName,
focusNode: focusNode,
showErrors: showErrors ??
(control) =>
control.invalid && (control.dirty || control.touched),
Expand Down
12 changes: 4 additions & 8 deletions lib/src/widgets/reactive_checkbox_list_tile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ class ReactiveCheckboxListTile extends ReactiveFocusableFormField<bool, bool> {
/// For documentation about the various parameters, see the [CheckboxListTile]
/// class and the [CheckboxListTile] constructor.
ReactiveCheckboxListTile({
Key? key,
String? formControlName,
FormControl<bool>? formControl,
super.key,
super.formControlName,
super.formControl,
Color? activeColor,
Color? checkColor,
Widget? title,
Expand All @@ -40,7 +40,7 @@ class ReactiveCheckboxListTile extends ReactiveFocusableFormField<bool, bool> {
Color? tileColor,
ShapeBorder? shape,
VisualDensity? visualDensity,
FocusNode? focusNode,
super.focusNode,
bool? enableFeedback,
OutlinedBorder? checkboxShape,
BorderSide? side,
Expand All @@ -54,10 +54,6 @@ class ReactiveCheckboxListTile extends ReactiveFocusableFormField<bool, bool> {
ValueChanged<bool>? onFocusChange,
ShowErrorsFunction<bool>? showErrors,
}) : super(
key: key,
formControl: formControl,
formControlName: formControlName,
focusNode: focusNode,
showErrors: showErrors ??
(control) =>
control.invalid && (control.dirty || control.touched),
Expand Down
9 changes: 3 additions & 6 deletions lib/src/widgets/reactive_date_picker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ class ReactiveDatePicker<T> extends ReactiveFormField<T, DateTime> {
/// For documentation about the various parameters, see the [showTimePicker]
/// function parameters.
ReactiveDatePicker({
Key? key,
String? formControlName,
FormControl<T>? formControl,
super.key,
super.formControlName,
super.formControl,
required ReactiveDatePickerBuilder<T> builder,
required DateTime firstDate,
required DateTime lastDate,
Expand All @@ -82,9 +82,6 @@ class ReactiveDatePicker<T> extends ReactiveFormField<T, DateTime> {
TextInputType? keyboardType,
Offset? anchorPoint,
}) : super(
key: key,
formControl: formControl,
formControlName: formControlName,
builder: (ReactiveFormFieldState<T, DateTime> field) {
return builder(
field.context,
Expand Down
18 changes: 6 additions & 12 deletions lib/src/widgets/reactive_dropdown_field.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ class ReactiveDropdownField<T> extends ReactiveFocusableFormField<T, T> {
/// For more information about all various parameters,
/// see [DropdownButtonFormField] constructor.
ReactiveDropdownField({
Key? key,
String? formControlName,
FormControl<T>? formControl,
FocusNode? focusNode,
super.key,
super.formControlName,
super.formControl,
super.focusNode,
required List<DropdownMenuItem<T>> items,
Map<String, ValidationMessageFunction>? validationMessages,
ShowErrorsFunction<T>? showErrors,
super.validationMessages,
super.showErrors,
DropdownButtonBuilder? selectedItemBuilder,
Widget? hint,
InputDecoration decoration = const InputDecoration(),
Expand All @@ -58,12 +58,6 @@ class ReactiveDropdownField<T> extends ReactiveFocusableFormField<T, T> {
ReactiveFormFieldCallback<T>? onChanged,
}) : assert(itemHeight == null || itemHeight > 0),
super(
key: key,
formControl: formControl,
formControlName: formControlName,
validationMessages: validationMessages,
showErrors: showErrors,
focusNode: focusNode,
builder: (ReactiveFormFieldState<T, T> field) {
final effectiveDecoration = decoration.applyDefaults(
Theme.of(field.context).inputDecorationTheme,
Expand Down
13 changes: 7 additions & 6 deletions lib/src/widgets/reactive_form.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import 'package:flutter/material.dart';
import 'package:reactive_forms/reactive_forms.dart';
import 'package:reactive_forms/src/widgets/form_control_inherited_notifier.dart';
import 'package:reactive_forms/src/widgets/reactive_form_pop_scope.dart';

/// This class is responsible for create a [FormControlInheritedStreamer] for
/// exposing a [FormGroup] to all descendants widgets.
Expand All @@ -29,12 +28,12 @@ class ReactiveForm extends StatelessWidget {
///
/// The [formGroup] and [child] arguments are required.
const ReactiveForm({
Key? key,
super.key,
required this.formGroup,
required this.child,
this.canPop,
this.onPopInvoked,
}) : super(key: key);
});

/// Returns the nearest model up its widget tree.
///
Expand Down Expand Up @@ -64,9 +63,11 @@ class ReactiveForm extends StatelessWidget {
control: formGroup,
stream: formGroup.statusChanged,
child: canPop != null || onPopInvoked != null
? ReactiveFormPopScope(
canPop: canPop,
onPopInvoked: onPopInvoked,
? PopScope(
canPop: canPop != null ? canPop!(formGroup) : true,
onPopInvoked: onPopInvoked != null
? (didPop) => onPopInvoked!(formGroup, didPop)
: null,
child: child,
)
: child,
Expand Down
5 changes: 2 additions & 3 deletions lib/src/widgets/reactive_form_array.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,15 @@ class ReactiveFormArray<T> extends StatefulWidget {
/// subtree does not depend on the value of the [FormArray] that is bind
/// with this widget.
const ReactiveFormArray({
Key? key,
super.key,
required this.builder,
this.formArrayName,
this.formArray,
this.child,
}) : assert(
(formArrayName != null && formArray == null) ||
(formArrayName == null && formArray != null),
'Must provide a formArrayName or a formArray, but not both at the same time.'),
super(key: key);
'Must provide a formArrayName or a formArray, but not both at the same time.');

@override
ReactiveFormArrayState<T> createState() => ReactiveFormArrayState<T>();
Expand Down
4 changes: 2 additions & 2 deletions lib/src/widgets/reactive_form_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@ class ReactiveFormBuilder extends StatefulWidget {
/// }
/// ```
const ReactiveFormBuilder({
Key? key,
super.key,
required this.form,
required this.builder,
this.canPop,
this.onPopInvoked,
this.child,
}) : super(key: key);
});

@override
ReactiveFormBuilderState createState() => ReactiveFormBuilderState();
Expand Down
6 changes: 3 additions & 3 deletions lib/src/widgets/reactive_form_config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ class ReactiveFormConfig extends InheritedWidget {
/// );
/// ```
const ReactiveFormConfig({
required Widget child,
required super.child,
required this.validationMessages,
Key? key,
}) : super(child: child, key: key);
super.key,
});

@override
bool updateShouldNotify(covariant ReactiveFormConfig oldWidget) {
Expand Down
4 changes: 2 additions & 2 deletions lib/src/widgets/reactive_form_consumer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ class ReactiveFormConsumer extends StatelessWidget {
/// subtree does not depend on the value of the [FormGroup] that is bind
/// with this widget.
const ReactiveFormConsumer({
Key? key,
super.key,
required this.builder,
this.child,
}) : super(key: key);
});

@override
Widget build(BuildContext context) {
Expand Down
5 changes: 2 additions & 3 deletions lib/src/widgets/reactive_form_field.dart
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class ReactiveFormField<ModelDataType, ViewDataType> extends StatefulWidget {
///
/// The [builder] arguments are required.
ReactiveFormField({
Key? key,
super.key,
this.formControl,
this.formControlName,
this.valueAccessor,
Expand All @@ -73,8 +73,7 @@ class ReactiveFormField<ModelDataType, ViewDataType> extends StatefulWidget {
(formControlName != null && formControl == null) ||
(formControlName == null && formControl != null),
'Must provide a formControlName or a formControl, but not both at the same time.'),
_builder = builder,
super(key: key);
_builder = builder;

@override
ReactiveFormFieldState<ModelDataType, ViewDataType> createState() =>
Expand Down
Loading

0 comments on commit 552a7ac

Please sign in to comment.