Skip to content

Commit 8ec777e

Browse files
run dart format
1 parent e4c77a0 commit 8ec777e

File tree

44 files changed

+1871
-1421
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+1871
-1421
lines changed

example/lib/basic_examples.dart

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ class BasicExamplesPage extends StatelessWidget {
1111
Widget build(BuildContext context) {
1212
return Scaffold(
1313
appBar: AppBar(
14-
title: const Text('Basic Examples (one validator per example)')),
14+
title: const Text('Basic Examples (one validator per example)'),
15+
),
1516
body: Padding(
1617
padding: const EdgeInsets.all(8),
1718
child: SingleChildScrollView(
@@ -31,14 +32,15 @@ class BasicExamplesPage extends StatelessWidget {
3132
),
3233
TextFormField(
3334
decoration: const InputDecoration(
34-
labelText:
35-
'Type "I want to delete" to confirm the action.'),
35+
labelText: 'Type "I want to delete" to confirm the action.',
36+
),
3637
autovalidateMode: AutovalidateMode.onUserInteraction,
3738
validator: Validators.equal('I want to delete'),
3839
),
3940
TextFormField(
4041
decoration: const InputDecoration(
41-
labelText: 'Username (should not be "RESERVED")'),
42+
labelText: 'Username (should not be "RESERVED")',
43+
),
4244
autovalidateMode: AutovalidateMode.onUserInteraction,
4345
validator: Validators.notEqual('RESERVED'),
4446
),
@@ -50,14 +52,16 @@ class BasicExamplesPage extends StatelessWidget {
5052
),
5153
),
5254
TextFormField(
53-
decoration:
54-
const InputDecoration(labelText: 'Input must not be null'),
55+
decoration: const InputDecoration(
56+
labelText: 'Input must not be null',
57+
),
5558
autovalidateMode: AutovalidateMode.onUserInteraction,
5659
validator: (String? input) {
5760
final String? isRequiredMsg = Validators.required()(input);
58-
return isRequiredMsg
59-
?.toUpperCase()
60-
.replaceFirst('OVERRIDE: ', '');
61+
return isRequiredMsg?.toUpperCase().replaceFirst(
62+
'OVERRIDE: ',
63+
'',
64+
);
6165
},
6266
),
6367
],

example/lib/main.dart

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -46,34 +46,32 @@ class _HomePage extends StatelessWidget {
4646
mainAxisAlignment: MainAxisAlignment.center,
4747
children: <Widget>[
4848
ElevatedButton(
49-
onPressed: () => Navigator.of(context).push(
50-
MaterialPageRoute<void>(
51-
builder: (BuildContext context) => BasicExamplesPage(),
52-
),
53-
),
54-
child: Text('Basic Examples')),
55-
SizedBox(
56-
height: 15,
49+
onPressed: () => Navigator.of(context).push(
50+
MaterialPageRoute<void>(
51+
builder: (BuildContext context) => BasicExamplesPage(),
52+
),
53+
),
54+
child: Text('Basic Examples'),
5755
),
56+
SizedBox(height: 15),
5857
ElevatedButton(
59-
onPressed: () => Navigator.of(context).push(
60-
MaterialPageRoute<void>(
61-
builder: (BuildContext context) =>
62-
GenericExamplesPage(),
63-
),
64-
),
65-
child: Text('Generic Examples')),
66-
SizedBox(
67-
height: 15,
58+
onPressed: () => Navigator.of(context).push(
59+
MaterialPageRoute<void>(
60+
builder: (BuildContext context) => GenericExamplesPage(),
61+
),
62+
),
63+
child: Text('Generic Examples'),
6864
),
65+
SizedBox(height: 15),
6966
ElevatedButton(
70-
onPressed: () => Navigator.of(context).push(
71-
MaterialPageRoute<void>(
72-
builder: (BuildContext context) =>
73-
FormsWithValidateGranularly(),
74-
),
75-
),
76-
child: Text('Validate Granularly'))
67+
onPressed: () => Navigator.of(context).push(
68+
MaterialPageRoute<void>(
69+
builder: (BuildContext context) =>
70+
FormsWithValidateGranularly(),
71+
),
72+
),
73+
child: Text('Validate Granularly'),
74+
),
7775
],
7876
),
7977
),

lib/src/validators/collection_validators.dart

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@ import '../../localization/l10n.dart';
22
import 'constants.dart';
33

44
/// {@macro validator_min_length}
5-
Validator<T> minLength<T extends Object>(int min,
6-
{String Function(T input, int min)? minLengthMsg}) {
5+
Validator<T> minLength<T extends Object>(
6+
int min, {
7+
String Function(T input, int min)? minLengthMsg,
8+
}) {
79
if (min < 0) {
810
throw ArgumentError.value(min, 'min', 'This argument may not be negative');
911
}
@@ -24,14 +26,16 @@ Validator<T> minLength<T extends Object>(int min,
2426
}
2527
return valueLength < min
2628
? minLengthMsg?.call(input, min) ??
27-
FormBuilderLocalizations.current.minLengthErrorText(min)
29+
FormBuilderLocalizations.current.minLengthErrorText(min)
2830
: null;
2931
};
3032
}
3133

3234
/// {@macro validator_max_length}
33-
Validator<T> maxLength<T extends Object>(int max,
34-
{String Function(T input, int max)? maxLengthMsg}) {
35+
Validator<T> maxLength<T extends Object>(
36+
int max, {
37+
String Function(T input, int max)? maxLengthMsg,
38+
}) {
3539
if (max < 0) {
3640
throw ArgumentError.value(max, 'max', 'This argument may not be negative');
3741
}
@@ -54,7 +58,7 @@ Validator<T> maxLength<T extends Object>(int max,
5458

5559
return valueLength > max
5660
? maxLengthMsg?.call(input, max) ??
57-
FormBuilderLocalizations.current.maxLengthErrorText(max)
61+
FormBuilderLocalizations.current.maxLengthErrorText(max)
5862
: null;
5963
};
6064
}
@@ -64,7 +68,7 @@ Validator<T> betweenLength<T extends Object>(
6468
int min,
6569
int max, {
6670
String Function(T input, {required int min, required int max})?
67-
betweenLengthMsg,
71+
betweenLengthMsg,
6872
}) {
6973
if (min < 0) {
7074
throw ArgumentError.value(min, 'min', 'This argument may not be negative');
@@ -94,17 +98,22 @@ Validator<T> betweenLength<T extends Object>(
9498
}
9599
return (valueLength < min || valueLength > max)
96100
? betweenLengthMsg?.call(input, min: min, max: max) ??
97-
FormBuilderLocalizations.current.betweenLengthErrorText(min, max)
101+
FormBuilderLocalizations.current.betweenLengthErrorText(min, max)
98102
: null;
99103
};
100104
}
101105

102106
/// {@macro validator_equal_length}
103-
Validator<T> equalLength<T extends Object>(int expectedLength,
104-
{String Function(T input, int expectedLength)? equalLengthMsg}) {
107+
Validator<T> equalLength<T extends Object>(
108+
int expectedLength, {
109+
String Function(T input, int expectedLength)? equalLengthMsg,
110+
}) {
105111
if (expectedLength < 0) {
106112
throw ArgumentError.value(
107-
expectedLength, 'expectedLength', 'This argument may not be negative');
113+
expectedLength,
114+
'expectedLength',
115+
'This argument may not be negative',
116+
);
108117
}
109118

110119
return (T input) {
@@ -126,8 +135,9 @@ Validator<T> equalLength<T extends Object>(int expectedLength,
126135

127136
return valueLength != expectedLength
128137
? equalLengthMsg?.call(input, expectedLength) ??
129-
FormBuilderLocalizations.current
130-
.equalLengthErrorText(expectedLength)
138+
FormBuilderLocalizations.current.equalLengthErrorText(
139+
expectedLength,
140+
)
131141
: null;
132142
};
133143
}

lib/src/validators/core_validators/compose_validators.dart

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@ Validator<T> and<T extends Object>(
1212
}) {
1313
if (validators.isEmpty) {
1414
throw ArgumentError.value(
15-
'[]', 'validators', 'The list of validators must not be empty');
15+
'[]',
16+
'validators',
17+
'The list of validators must not be empty',
18+
);
1619
}
1720
final List<Validator<T>> immutableValidators =
1821
List<Validator<T>>.unmodifiable(validators);
@@ -44,7 +47,10 @@ Validator<T> or<T extends Object>(
4447
}) {
4548
if (validators.isEmpty) {
4649
throw ArgumentError.value(
47-
'[]', 'validators', 'The list of validators must not be empty');
50+
'[]',
51+
'validators',
52+
'The list of validators must not be empty',
53+
);
4854
}
4955
final List<Validator<T>> immutableValidators =
5056
List<Validator<T>>.unmodifiable(validators);

lib/src/validators/core_validators/conditional_validators.dart

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,16 @@ import '../constants.dart';
22

33
/// {@macro validator_validate_if}
44
Validator<T> validateIf<T extends Object?>(
5-
bool Function(T value) condition, Validator<T> v) {
5+
bool Function(T value) condition,
6+
Validator<T> v,
7+
) {
68
return (T value) => condition(value) ? v(value) : null;
79
}
810

911
/// {@macro validator_skip_if}
1012
Validator<T> skipIf<T extends Object?>(
11-
bool Function(T value) condition, Validator<T> v) {
13+
bool Function(T value) condition,
14+
Validator<T> v,
15+
) {
1216
return (T value) => condition(value) ? null : v(value);
1317
}

lib/src/validators/core_validators/debug_print_validator.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@ import 'package:flutter/widgets.dart';
33
import '../constants.dart';
44

55
/// {@macro validator_debug_print_validator}
6-
Validator<T> debugPrintValidator<T extends Object?>(
7-
{Validator<T>? next, String Function(T)? logOnInput}) {
6+
Validator<T> debugPrintValidator<T extends Object?>({
7+
Validator<T>? next,
8+
String Function(T)? logOnInput,
9+
}) {
810
return (T value) {
911
debugPrint(logOnInput?.call(value) ?? value.toString());
1012
return next?.call(value);

lib/src/validators/core_validators/equality_validators.dart

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@ Validator<T> equal<T extends Object?>(
1010
return referenceValue == input
1111
? null
1212
: equalMsg?.call(input, referenceValue) ??
13-
FormBuilderLocalizations.current
14-
.equalErrorText(referenceValue.toString());
13+
FormBuilderLocalizations.current.equalErrorText(
14+
referenceValue.toString(),
15+
);
1516
};
1617
}
1718

@@ -24,7 +25,8 @@ Validator<T> notEqual<T extends Object?>(
2425
return referenceValue != input
2526
? null
2627
: notEqualMsg?.call(input, referenceValue) ??
27-
FormBuilderLocalizations.current
28-
.notEqualErrorText(referenceValue.toString());
28+
FormBuilderLocalizations.current.notEqualErrorText(
29+
referenceValue.toString(),
30+
);
2931
};
3032
}

lib/src/validators/core_validators/required_validators.dart

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ Validator<T?> required<T extends Object>([
77
String? requiredMsg,
88
]) {
99
String? finalValidator(T? value) {
10-
final (bool isValid, T? transformedValue) =
11-
_isRequiredValidateAndConvert(value);
10+
final (bool isValid, T? transformedValue) = _isRequiredValidateAndConvert(
11+
value,
12+
);
1213
if (!isValid) {
1314
return requiredMsg ?? FormBuilderLocalizations.current.requiredErrorText;
1415
}
@@ -20,7 +21,9 @@ Validator<T?> required<T extends Object>([
2021

2122
/// {@macro validator_validate_with_default}
2223
Validator<T?> validateWithDefault<T extends Object>(
23-
T defaultValue, Validator<T> next) {
24+
T defaultValue,
25+
Validator<T> next,
26+
) {
2427
return (T? value) => next(value ?? defaultValue);
2528
}
2629

@@ -30,8 +33,9 @@ Validator<T?> optional<T extends Object>([
3033
String Function(T input, String nextErrorMsg)? optionalMsg,
3134
]) {
3235
return (T? input) {
33-
final (bool isValid, T? transformedValue) =
34-
_isRequiredValidateAndConvert(input);
36+
final (bool isValid, T? transformedValue) = _isRequiredValidateAndConvert(
37+
input,
38+
);
3539
if (!isValid) {
3640
// field not provided
3741
return null;

lib/src/validators/core_validators/transform_validator.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@ Validator<IN> transformAndValidate<IN extends Object?, OUT extends Object?>(
1717
(transformedResultTypeDescription == null
1818
? FormBuilderLocalizations.current.transformAndValidateErrorTextV1
1919
: FormBuilderLocalizations.current
20-
.transformAndValidateErrorTextV2(
21-
transformedResultTypeDescription));
20+
.transformAndValidateErrorTextV2(
21+
transformedResultTypeDescription,
22+
));
2223
}
2324
};
2425
}

0 commit comments

Comments
 (0)