Skip to content

Commit 06450ec

Browse files
committed
static analysis improvements
1 parent d1defab commit 06450ec

28 files changed

+401
-338
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## [6.0.0-nullsafety.1] - 24-Mar-2021
2+
* Static analysis improvements
3+
* Documentation improvements
4+
15
## [6.0.0-nullsafety.0] - 24-Mar-2021
26
* Started working on null-safety
37

example/lib/home_page.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ class HomePage extends StatelessWidget {
2323
builder: (context) {
2424
return CodePage(
2525
title: 'Complete Form',
26-
child: CompleteForm(),
2726
sourceFilePath: 'lib/sources/complete_form.dart',
27+
child: CompleteForm(),
2828
);
2929
},
3030
),
@@ -41,8 +41,8 @@ class HomePage extends StatelessWidget {
4141
builder: (context) {
4242
return CodePage(
4343
title: 'Signup Form',
44-
child: SignupForm(),
4544
sourceFilePath: 'lib/sources/signup_form.dart',
45+
child: SignupForm(),
4646
);
4747
},
4848
),

example/lib/sources/complete_form.dart

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
import 'package:flutter/cupertino.dart';
22
import 'package:flutter/material.dart';
33
import 'package:flutter_form_builder/flutter_form_builder.dart';
4-
import 'package:intl/intl.dart';
5-
6-
import '../data.dart';
74

85
class CompleteForm extends StatefulWidget {
96
@override
@@ -116,8 +113,9 @@ class CompleteFormState extends State<CompleteForm> {
116113
),
117114
onChanged: (val) {
118115
setState(() {
119-
_ageHasError =
120-
!(_formKey.currentState?.fields['age']?.validate() ?? false);
116+
_ageHasError = !(_formKey.currentState?.fields['age']
117+
?.validate() ??
118+
false);
121119
});
122120
},
123121
// valueTransformer: (text) => num.tryParse(text),
@@ -153,8 +151,10 @@ class CompleteFormState extends State<CompleteForm> {
153151
onChanged: (val) {
154152
print(val);
155153
setState(() {
156-
_genderHasError =
157-
!(_formKey.currentState?.fields['gender']?.validate() ?? false);
154+
_genderHasError = !(_formKey
155+
.currentState?.fields['gender']
156+
?.validate() ??
157+
false);
158158
});
159159
},
160160
),
@@ -226,10 +226,6 @@ class CompleteFormState extends State<CompleteForm> {
226226
Expanded(
227227
child: MaterialButton(
228228
color: Theme.of(context).accentColor,
229-
child: const Text(
230-
'Submit',
231-
style: TextStyle(color: Colors.white),
232-
),
233229
onPressed: () {
234230
if (_formKey.currentState?.saveAndValidate() ?? false) {
235231
print(_formKey.currentState?.value);
@@ -238,19 +234,23 @@ class CompleteFormState extends State<CompleteForm> {
238234
print('validation failed');
239235
}
240236
},
237+
child: const Text(
238+
'Submit',
239+
style: TextStyle(color: Colors.white),
240+
),
241241
),
242242
),
243243
const SizedBox(width: 20),
244244
Expanded(
245-
child: OutlineButton(
246-
color: Theme.of(context).accentColor,
245+
child: OutlinedButton(
246+
onPressed: () {
247+
_formKey.currentState?.reset();
248+
},
249+
// color: Theme.of(context).accentColor,
247250
child: Text(
248251
'Reset',
249252
style: TextStyle(color: Theme.of(context).accentColor),
250253
),
251-
onPressed: () {
252-
_formKey.currentState?.reset();
253-
},
254254
),
255255
),
256256
],

example/lib/sources/signup_form.dart

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ class _SignupFormState extends State<SignupForm> {
5555
labelText: 'Confirm Password',
5656
suffixIcon: (_formKey.currentState != null &&
5757
!(_formKey.currentState?.fields['confirm_password']
58-
?.isValid ?? false))
58+
?.isValid ??
59+
false))
5960
? const Icon(Icons.error, color: Colors.red)
6061
: const Icon(Icons.check, color: Colors.green),
6162
),
@@ -103,10 +104,6 @@ class _SignupFormState extends State<SignupForm> {
103104
const SizedBox(height: 10),
104105
MaterialButton(
105106
color: Theme.of(context).accentColor,
106-
child: Text(
107-
'Signup',
108-
style: TextStyle(color: Colors.white),
109-
),
110107
onPressed: () {
111108
if (_formKey.currentState?.saveAndValidate() ?? false) {
112109
print('Valid');
@@ -115,6 +112,7 @@ class _SignupFormState extends State<SignupForm> {
115112
}
116113
print(_formKey.currentState?.value);
117114
},
115+
child: Text('Signup', style: TextStyle(color: Colors.white)),
118116
)
119117
],
120118
),

example/pubspec.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ dependencies:
1515
cupertino_icons: any
1616

1717
dev_dependencies:
18+
pedantic: ^1.11.0
1819
flutter_test:
1920
sdk: flutter
2021

lib/l10n/messages_all.dart

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,8 @@ MessageLookupByLibrary? _findExact(String localeName) {
6262
/// User programs should call this before using [localeName] for messages.
6363
Future<bool> initializeMessages(String localeName) async {
6464
var availableLocale = Intl.verifiedLocale(
65-
localeName,
66-
(locale) => _deferredLibraries[locale] != null,
67-
onFailure: (_) => null);
65+
localeName, (locale) => _deferredLibraries[locale] != null,
66+
onFailure: (_) => null);
6867
if (availableLocale == null) {
6968
return new Future.value(false);
7069
}
@@ -84,8 +83,8 @@ bool _messagesExistFor(String locale) {
8483
}
8584

8685
MessageLookupByLibrary? _findGeneratedMessagesFor(String locale) {
87-
var actualLocale = Intl.verifiedLocale(locale, _messagesExistFor,
88-
onFailure: (_) => null);
86+
var actualLocale =
87+
Intl.verifiedLocale(locale, _messagesExistFor, onFailure: (_) => null);
8988
if (actualLocale == null) return null;
9089
return _findExact(actualLocale);
9190
}

lib/l10n/messages_en.dart

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,25 +21,35 @@ class MessageLookup extends MessageLookupByLibrary {
2121

2222
static m0(max) => "Value must be less than or equal to ${max}";
2323

24-
static m1(maxLength) => "Value must have a length less than or equal to ${maxLength}";
24+
static m1(maxLength) =>
25+
"Value must have a length less than or equal to ${maxLength}";
2526

2627
static m2(min) => "Value must be greater than or equal to ${min}.";
2728

28-
static m3(minLength) => "Value must have a length greater than or equal to ${minLength}";
29+
static m3(minLength) =>
30+
"Value must have a length greater than or equal to ${minLength}";
2931

3032
final messages = _notInlinedMessages(_notInlinedMessages);
31-
static _notInlinedMessages(_) => <String, Function> {
32-
"creditCardErrorText" : MessageLookupByLibrary.simpleMessage("This field requires a valid credit card number."),
33-
"dateStringErrorText" : MessageLookupByLibrary.simpleMessage("This field requires a valid date string."),
34-
"emailErrorText" : MessageLookupByLibrary.simpleMessage("This field requires a valid email address."),
35-
"ipErrorText" : MessageLookupByLibrary.simpleMessage("This field requires a valid IP."),
36-
"matchErrorText" : MessageLookupByLibrary.simpleMessage("Value does not match pattern."),
37-
"maxErrorText" : m0,
38-
"maxLengthErrorText" : m1,
39-
"minErrorText" : m2,
40-
"minLengthErrorText" : m3,
41-
"numericErrorText" : MessageLookupByLibrary.simpleMessage("Value must be numeric."),
42-
"requiredErrorText" : MessageLookupByLibrary.simpleMessage("This field cannot be empty."),
43-
"urlErrorText" : MessageLookupByLibrary.simpleMessage("This field requires a valid URL address.")
44-
};
33+
static _notInlinedMessages(_) => <String, Function>{
34+
"creditCardErrorText": MessageLookupByLibrary.simpleMessage(
35+
"This field requires a valid credit card number."),
36+
"dateStringErrorText": MessageLookupByLibrary.simpleMessage(
37+
"This field requires a valid date string."),
38+
"emailErrorText": MessageLookupByLibrary.simpleMessage(
39+
"This field requires a valid email address."),
40+
"ipErrorText": MessageLookupByLibrary.simpleMessage(
41+
"This field requires a valid IP."),
42+
"matchErrorText": MessageLookupByLibrary.simpleMessage(
43+
"Value does not match pattern."),
44+
"maxErrorText": m0,
45+
"maxLengthErrorText": m1,
46+
"minErrorText": m2,
47+
"minLengthErrorText": m3,
48+
"numericErrorText":
49+
MessageLookupByLibrary.simpleMessage("Value must be numeric."),
50+
"requiredErrorText":
51+
MessageLookupByLibrary.simpleMessage("This field cannot be empty."),
52+
"urlErrorText": MessageLookupByLibrary.simpleMessage(
53+
"This field requires a valid URL address.")
54+
};
4555
}

lib/l10n/messages_es.dart

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,25 +21,35 @@ class MessageLookup extends MessageLookupByLibrary {
2121

2222
static m0(max) => "El valor debe ser menor o igual que ${max}.";
2323

24-
static m1(maxLength) => "El valor debe tener una longitud menor o igual a ${maxLength}";
24+
static m1(maxLength) =>
25+
"El valor debe tener una longitud menor o igual a ${maxLength}";
2526

2627
static m2(min) => "El valor debe ser mayor o igual que ${min}.";
2728

28-
static m3(minLength) => "El valor debe tener una longitud mayor o igual a ${minLength}";
29+
static m3(minLength) =>
30+
"El valor debe tener una longitud mayor o igual a ${minLength}";
2931

3032
final messages = _notInlinedMessages(_notInlinedMessages);
31-
static _notInlinedMessages(_) => <String, Function> {
32-
"creditCardErrorText" : MessageLookupByLibrary.simpleMessage("Este campo requiere un número de tarjeta de crédito válido."),
33-
"dateStringErrorText" : MessageLookupByLibrary.simpleMessage("Este campo requiere una cadena de fecha válida."),
34-
"emailErrorText" : MessageLookupByLibrary.simpleMessage("Este campo requiere una dirección de correo electrónico válida."),
35-
"ipErrorText" : MessageLookupByLibrary.simpleMessage("Este campo requiere una IP válida."),
36-
"matchErrorText" : MessageLookupByLibrary.simpleMessage("El valor no coincide con el patrón requerido."),
37-
"maxErrorText" : m0,
38-
"maxLengthErrorText" : m1,
39-
"minErrorText" : m2,
40-
"minLengthErrorText" : m3,
41-
"numericErrorText" : MessageLookupByLibrary.simpleMessage("El valor debe ser numérico."),
42-
"requiredErrorText" : MessageLookupByLibrary.simpleMessage("Este campo no puede estar vacío."),
43-
"urlErrorText" : MessageLookupByLibrary.simpleMessage("Este campo requiere una dirección URL válida.")
44-
};
33+
static _notInlinedMessages(_) => <String, Function>{
34+
"creditCardErrorText": MessageLookupByLibrary.simpleMessage(
35+
"Este campo requiere un número de tarjeta de crédito válido."),
36+
"dateStringErrorText": MessageLookupByLibrary.simpleMessage(
37+
"Este campo requiere una cadena de fecha válida."),
38+
"emailErrorText": MessageLookupByLibrary.simpleMessage(
39+
"Este campo requiere una dirección de correo electrónico válida."),
40+
"ipErrorText": MessageLookupByLibrary.simpleMessage(
41+
"Este campo requiere una IP válida."),
42+
"matchErrorText": MessageLookupByLibrary.simpleMessage(
43+
"El valor no coincide con el patrón requerido."),
44+
"maxErrorText": m0,
45+
"maxLengthErrorText": m1,
46+
"minErrorText": m2,
47+
"minLengthErrorText": m3,
48+
"numericErrorText":
49+
MessageLookupByLibrary.simpleMessage("El valor debe ser numérico."),
50+
"requiredErrorText": MessageLookupByLibrary.simpleMessage(
51+
"Este campo no puede estar vacío."),
52+
"urlErrorText": MessageLookupByLibrary.simpleMessage(
53+
"Este campo requiere una dirección URL válida.")
54+
};
4555
}

lib/l10n/messages_fr.dart

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,25 +21,35 @@ class MessageLookup extends MessageLookupByLibrary {
2121

2222
static m0(max) => "La valeur doit être inférieure ou égale à ${max}";
2323

24-
static m1(maxLength) => "La valeur doit avoir une longueur inférieure ou égale à ${maxLength}";
24+
static m1(maxLength) =>
25+
"La valeur doit avoir une longueur inférieure ou égale à ${maxLength}";
2526

2627
static m2(min) => "La valeur doit être supérieure ou égale à ${min}.";
2728

28-
static m3(minLength) => "La valeur doit avoir une longueur supérieure ou égale à ${minLength}";
29+
static m3(minLength) =>
30+
"La valeur doit avoir une longueur supérieure ou égale à ${minLength}";
2931

3032
final messages = _notInlinedMessages(_notInlinedMessages);
31-
static _notInlinedMessages(_) => <String, Function> {
32-
"creditCardErrorText" : MessageLookupByLibrary.simpleMessage("Ce champ nécessite un numéro de carte de crédit valide."),
33-
"dateStringErrorText" : MessageLookupByLibrary.simpleMessage("Ce champ nécessite une chaîne de date valide."),
34-
"emailErrorText" : MessageLookupByLibrary.simpleMessage("Ce champ nécessite une adresse e-mail valide."),
35-
"ipErrorText" : MessageLookupByLibrary.simpleMessage("Ce champ nécessite une adresse IP valide."),
36-
"matchErrorText" : MessageLookupByLibrary.simpleMessage("La valeur ne correspond pas au modèle."),
37-
"maxErrorText" : m0,
38-
"maxLengthErrorText" : m1,
39-
"minErrorText" : m2,
40-
"minLengthErrorText" : m3,
41-
"numericErrorText" : MessageLookupByLibrary.simpleMessage("La valeur doit être numérique."),
42-
"requiredErrorText" : MessageLookupByLibrary.simpleMessage("Ce champ ne peut pas être vide."),
43-
"urlErrorText" : MessageLookupByLibrary.simpleMessage("Ce champ nécessite une adresse URL valide.")
44-
};
33+
static _notInlinedMessages(_) => <String, Function>{
34+
"creditCardErrorText": MessageLookupByLibrary.simpleMessage(
35+
"Ce champ nécessite un numéro de carte de crédit valide."),
36+
"dateStringErrorText": MessageLookupByLibrary.simpleMessage(
37+
"Ce champ nécessite une chaîne de date valide."),
38+
"emailErrorText": MessageLookupByLibrary.simpleMessage(
39+
"Ce champ nécessite une adresse e-mail valide."),
40+
"ipErrorText": MessageLookupByLibrary.simpleMessage(
41+
"Ce champ nécessite une adresse IP valide."),
42+
"matchErrorText": MessageLookupByLibrary.simpleMessage(
43+
"La valeur ne correspond pas au modèle."),
44+
"maxErrorText": m0,
45+
"maxLengthErrorText": m1,
46+
"minErrorText": m2,
47+
"minLengthErrorText": m3,
48+
"numericErrorText": MessageLookupByLibrary.simpleMessage(
49+
"La valeur doit être numérique."),
50+
"requiredErrorText": MessageLookupByLibrary.simpleMessage(
51+
"Ce champ ne peut pas être vide."),
52+
"urlErrorText": MessageLookupByLibrary.simpleMessage(
53+
"Ce champ nécessite une adresse URL valide.")
54+
};
4555
}

lib/l10n/messages_it.dart

Lines changed: 33 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -19,31 +19,44 @@ typedef String MessageIfAbsent(String messageStr, List<dynamic> args);
1919
class MessageLookup extends MessageLookupByLibrary {
2020
String get localeName => 'it';
2121

22-
static m4(value) => "Il valore di questo campo deve essere uguale a ${value}.";
22+
static m4(value) =>
23+
"Il valore di questo campo deve essere uguale a ${value}.";
2324

2425
static m0(max) => "Il valore inserito deve essere minore o uguale a ${max}";
2526

26-
static m1(maxLength) => "Il valore inserito deve avere una lunghezza minore o uguale a ${maxLength}";
27+
static m1(maxLength) =>
28+
"Il valore inserito deve avere una lunghezza minore o uguale a ${maxLength}";
2729

28-
static m2(min) => "Il valore inserito deve essere maggiore o uguale a ${min}.";
30+
static m2(min) =>
31+
"Il valore inserito deve essere maggiore o uguale a ${min}.";
2932

30-
static m3(minLength) => "Il valore inserito deve avere una lunghezza maggiore o uguale a ${minLength}";
33+
static m3(minLength) =>
34+
"Il valore inserito deve avere una lunghezza maggiore o uguale a ${minLength}";
3135

3236
final messages = _notInlinedMessages(_notInlinedMessages);
33-
static _notInlinedMessages(_) => <String, Function> {
34-
"creditCardErrorText" : MessageLookupByLibrary.simpleMessage("Questo campo richiede un numero di carta di credito valido."),
35-
"dateStringErrorText" : MessageLookupByLibrary.simpleMessage("Questo campo richiede una data valida."),
36-
"emailErrorText" : MessageLookupByLibrary.simpleMessage("Questo campo richiede un indirizzo email valido."),
37-
"equalErrorText" : m4,
38-
"integerErrorText" : MessageLookupByLibrary.simpleMessage("Il valore deve essere un integer."),
39-
"ipErrorText" : MessageLookupByLibrary.simpleMessage("Questo campo richiede un indirizzo IP valido."),
40-
"matchErrorText" : MessageLookupByLibrary.simpleMessage("Il valore non corrisponde al formato richiesto."),
41-
"maxErrorText" : m0,
42-
"maxLengthErrorText" : m1,
43-
"minErrorText" : m2,
44-
"minLengthErrorText" : m3,
45-
"numericErrorText" : MessageLookupByLibrary.simpleMessage("Il valore deve essere numerico."),
46-
"requiredErrorText" : MessageLookupByLibrary.simpleMessage("Questo campo non può essere vuoto."),
47-
"urlErrorText" : MessageLookupByLibrary.simpleMessage("Questo campo richiede una URL valida.")
48-
};
37+
static _notInlinedMessages(_) => <String, Function>{
38+
"creditCardErrorText": MessageLookupByLibrary.simpleMessage(
39+
"Questo campo richiede un numero di carta di credito valido."),
40+
"dateStringErrorText": MessageLookupByLibrary.simpleMessage(
41+
"Questo campo richiede una data valida."),
42+
"emailErrorText": MessageLookupByLibrary.simpleMessage(
43+
"Questo campo richiede un indirizzo email valido."),
44+
"equalErrorText": m4,
45+
"integerErrorText": MessageLookupByLibrary.simpleMessage(
46+
"Il valore deve essere un integer."),
47+
"ipErrorText": MessageLookupByLibrary.simpleMessage(
48+
"Questo campo richiede un indirizzo IP valido."),
49+
"matchErrorText": MessageLookupByLibrary.simpleMessage(
50+
"Il valore non corrisponde al formato richiesto."),
51+
"maxErrorText": m0,
52+
"maxLengthErrorText": m1,
53+
"minErrorText": m2,
54+
"minLengthErrorText": m3,
55+
"numericErrorText": MessageLookupByLibrary.simpleMessage(
56+
"Il valore deve essere numerico."),
57+
"requiredErrorText": MessageLookupByLibrary.simpleMessage(
58+
"Questo campo non può essere vuoto."),
59+
"urlErrorText": MessageLookupByLibrary.simpleMessage(
60+
"Questo campo richiede una URL valida.")
61+
};
4962
}

0 commit comments

Comments
 (0)