Skip to content

Commit f64b72f

Browse files
committed
chore: fixed static analysis issues in repo - esp in package examples
1 parent e430904 commit f64b72f

File tree

16 files changed

+99
-91
lines changed

16 files changed

+99
-91
lines changed

analysis_options.yaml

Lines changed: 0 additions & 12 deletions
This file was deleted.

packages/flutter_form_builder/example/lib/home_page.dart

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import 'code_page.dart';
77
import 'sources/complete_form.dart';
88

99
class HomePage extends StatelessWidget {
10+
const HomePage({Key? key}) : super(key: key);
11+
1012
@override
1113
Widget build(BuildContext context) {
1214
return Scaffold(
@@ -20,7 +22,7 @@ class HomePage extends StatelessWidget {
2022
Navigator.of(context).push(
2123
MaterialPageRoute(
2224
builder: (context) {
23-
return CodePage(
25+
return const CodePage(
2426
title: 'Complete Form',
2527
sourceFilePath: 'lib/sources/complete_form.dart',
2628
child: CompleteForm(),
@@ -38,7 +40,7 @@ class HomePage extends StatelessWidget {
3840
Navigator.of(context).push(
3941
MaterialPageRoute(
4042
builder: (context) {
41-
return CodePage(
43+
return const CodePage(
4244
title: 'Custom Fields',
4345
sourceFilePath: 'lib/sources/custom_fields.dart',
4446
child: CustomFields(),
@@ -56,7 +58,7 @@ class HomePage extends StatelessWidget {
5658
Navigator.of(context).push(
5759
MaterialPageRoute(
5860
builder: (context) {
59-
return CodePage(
61+
return const CodePage(
6062
title: 'Signup Form',
6163
sourceFilePath: 'lib/sources/signup_form.dart',
6264
child: SignupForm(),

packages/flutter_form_builder/example/lib/main.dart

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,27 @@ import 'package:form_builder_validators/form_builder_validators.dart';
55

66
import 'home_page.dart';
77

8-
void main() => runApp(MyApp());
8+
void main() => runApp(const MyApp());
99

1010
class MyApp extends StatelessWidget {
11+
const MyApp({Key? key}) : super(key: key);
12+
1113
@override
1214
Widget build(BuildContext context) {
1315
return MaterialApp(
1416
title: 'Flutter FormBuilder Demo',
1517
theme: ThemeData(
1618
primarySwatch: Colors.blue,
17-
inputDecorationTheme: InputDecorationTheme(
19+
inputDecorationTheme: const InputDecorationTheme(
1820
labelStyle: TextStyle(color: Colors.blueAccent),
1921
),
2022
),
21-
localizationsDelegates: [
23+
localizationsDelegates: const [
2224
FormBuilderLocalizations.delegate,
2325
GlobalMaterialLocalizations.delegate,
2426
GlobalWidgetsLocalizations.delegate,
2527
],
26-
supportedLocales: [
28+
supportedLocales: const [
2729
Locale('en', ''),
2830
Locale('es', ''),
2931
Locale('fa', ''),
@@ -33,7 +35,7 @@ class MyApp extends StatelessWidget {
3335
Locale('sk', ''),
3436
Locale('pl', ''),
3537
],
36-
home: HomePage(),
38+
home: const HomePage(),
3739
);
3840
}
3941
}

packages/flutter_form_builder/example/lib/sources/complete_form.dart

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import 'package:form_builder_validators/form_builder_validators.dart';
55
import 'package:intl/intl.dart';
66

77
class CompleteForm extends StatefulWidget {
8+
const CompleteForm({Key? key}) : super(key: key);
9+
810
@override
911
CompleteFormState createState() {
1012
return CompleteFormState();
@@ -19,9 +21,10 @@ class CompleteFormState extends State<CompleteForm> {
1921
bool _ageHasError = false;
2022
bool _genderHasError = false;
2123

22-
final ValueChanged _onChanged = (dynamic val) => print(val);
2324
var genderOptions = ['Male', 'Female', 'Other'];
2425

26+
void _onChanged(dynamic val) => debugPrint(val);
27+
2528
@override
2629
Widget build(BuildContext context) {
2730
return Padding(
@@ -50,14 +53,14 @@ class CompleteFormState extends State<CompleteForm> {
5053
decoration: InputDecoration(
5154
labelText: 'Appointment Time',
5255
suffixIcon: IconButton(
53-
icon: Icon(Icons.close),
56+
icon: const Icon(Icons.close),
5457
onPressed: () {
5558
_formKey.currentState!.fields['date']
5659
?.didChange(null);
5760
}),
5861
),
59-
initialTime: TimeOfDay(hour: 8, minute: 0),
60-
locale: Locale.fromSubtags(languageCode: 'fr'),
62+
initialTime: const TimeOfDay(hour: 8, minute: 0),
63+
locale: const Locale.fromSubtags(languageCode: 'fr'),
6164
),
6265
FormBuilderDateRangePicker(
6366
name: 'date_range',
@@ -70,7 +73,7 @@ class CompleteFormState extends State<CompleteForm> {
7073
helperText: 'Helper text',
7174
hintText: 'Hint text',
7275
suffixIcon: IconButton(
73-
icon: Icon(Icons.close),
76+
icon: const Icon(Icons.close),
7477
onPressed: () {
7578
_formKey.currentState!.fields['date_range']
7679
?.didChange(null);
@@ -99,7 +102,7 @@ class CompleteFormState extends State<CompleteForm> {
99102
onChanged: _onChanged,
100103
min: 0.0,
101104
max: 100.0,
102-
initialValue: RangeValues(4, 7),
105+
initialValue: const RangeValues(4, 7),
103106
divisions: 20,
104107
activeColor: Colors.red,
105108
inactiveColor: Colors.pink[100],
@@ -110,7 +113,7 @@ class CompleteFormState extends State<CompleteForm> {
110113
initialValue: false,
111114
onChanged: _onChanged,
112115
title: RichText(
113-
text: TextSpan(
116+
text: const TextSpan(
114117
children: [
115118
TextSpan(
116119
text: 'I have read and agree to the ',
@@ -175,7 +178,7 @@ class CompleteFormState extends State<CompleteForm> {
175178
),
176179
// initialValue: 'Male',
177180
allowClear: true,
178-
hint: Text('Select Gender'),
181+
hint: const Text('Select Gender'),
179182
validator: FormBuilderValidators.compose(
180183
[FormBuilderValidators.required(context)]),
181184
items: genderOptions
@@ -270,10 +273,10 @@ class CompleteFormState extends State<CompleteForm> {
270273
color: Theme.of(context).colorScheme.secondary,
271274
onPressed: () {
272275
if (_formKey.currentState?.saveAndValidate() ?? false) {
273-
print(_formKey.currentState?.value);
276+
debugPrint(_formKey.currentState?.value.toString());
274277
} else {
275-
print(_formKey.currentState?.value);
276-
print('validation failed');
278+
debugPrint(_formKey.currentState?.value.toString());
279+
debugPrint('validation failed');
277280
}
278281
},
279282
child: const Text(

packages/flutter_form_builder/example/lib/sources/custom_fields.dart

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import 'package:flutter/material.dart';
33
import 'package:flutter_form_builder/flutter_form_builder.dart';
44

55
class CustomFields extends StatefulWidget {
6+
const CustomFields({Key? key}) : super(key: key);
7+
68
@override
79
_CustomFieldsState createState() => _CustomFieldsState();
810
}
@@ -21,15 +23,12 @@ class _CustomFieldsState extends State<CustomFields> {
2123
children: <Widget>[
2224
FormBuilderField<String?>(
2325
name: 'name',
24-
onChanged: (val) => print(val),
26+
onChanged: (val) => debugPrint(val.toString()),
2527
builder: (FormFieldState field) {
2628
return Row(
2729
crossAxisAlignment: CrossAxisAlignment.center,
2830
children: [
29-
Expanded(
30-
child: Text('Name'),
31-
flex: 1,
32-
),
31+
const Expanded(child: Text('Name'), flex: 1),
3332
Expanded(
3433
flex: 2,
3534
child: InputDecorator(
@@ -71,11 +70,12 @@ class _CustomFieldsState extends State<CustomFields> {
7170
return InputDecorator(
7271
decoration: InputDecoration(
7372
labelText: "Select option",
74-
contentPadding: EdgeInsets.only(top: 10.0, bottom: 0.0),
73+
contentPadding:
74+
const EdgeInsets.only(top: 10.0, bottom: 0.0),
7575
border: InputBorder.none,
7676
errorText: field.errorText,
7777
),
78-
child: Container(
78+
child: SizedBox(
7979
height: 200,
8080
child: CupertinoPicker(
8181
itemExtent: 30,
@@ -93,25 +93,25 @@ class _CustomFieldsState extends State<CustomFields> {
9393
Expanded(
9494
child: MaterialButton(
9595
color: Theme.of(context).colorScheme.secondary,
96-
child: Text(
96+
child: const Text(
9797
"Submit",
9898
style: TextStyle(color: Colors.white),
9999
),
100100
onPressed: () {
101101
_formKey.currentState!.save();
102102
if (_formKey.currentState!.validate()) {
103-
print(_formKey.currentState!.value);
103+
debugPrint(_formKey.currentState!.value.toString());
104104
} else {
105-
print("validation failed");
105+
debugPrint("validation failed");
106106
}
107107
},
108108
),
109109
),
110-
SizedBox(width: 20),
110+
const SizedBox(width: 20),
111111
Expanded(
112112
child: MaterialButton(
113113
color: Theme.of(context).colorScheme.secondary,
114-
child: Text(
114+
child: const Text(
115115
"Reset",
116116
style: TextStyle(color: Colors.white),
117117
),

packages/flutter_form_builder/example/lib/sources/signup_form.dart

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import 'package:flutter_form_builder/flutter_form_builder.dart';
44
import 'package:form_builder_validators/form_builder_validators.dart';
55

66
class SignupForm extends StatefulWidget {
7+
const SignupForm({Key? key}) : super(key: key);
8+
79
@override
810
_SignupFormState createState() => _SignupFormState();
911
}
@@ -25,7 +27,7 @@ class _SignupFormState extends State<SignupForm> {
2527
children: [
2628
FormBuilderTextField(
2729
name: 'full_name',
28-
decoration: InputDecoration(labelText: 'Full Name'),
30+
decoration: const InputDecoration(labelText: 'Full Name'),
2931
validator: FormBuilderValidators.compose([
3032
FormBuilderValidators.required(context),
3133
]),
@@ -34,7 +36,7 @@ class _SignupFormState extends State<SignupForm> {
3436
FormBuilderTextField(
3537
key: _emailFieldKey,
3638
name: 'email',
37-
decoration: InputDecoration(labelText: 'Email'),
39+
decoration: const InputDecoration(labelText: 'Email'),
3840
validator: FormBuilderValidators.compose([
3941
FormBuilderValidators.required(context),
4042
FormBuilderValidators.email(context),
@@ -43,7 +45,7 @@ class _SignupFormState extends State<SignupForm> {
4345
const SizedBox(height: 10),
4446
FormBuilderTextField(
4547
name: 'password',
46-
decoration: InputDecoration(labelText: 'Password'),
48+
decoration: const InputDecoration(labelText: 'Password'),
4749
obscureText: true,
4850
validator: FormBuilderValidators.compose([
4951
FormBuilderValidators.required(context),
@@ -86,14 +88,14 @@ class _SignupFormState extends State<SignupForm> {
8688
FormBuilderValidators.equal(context, true),
8789
]),
8890
// initialValue: true,
89-
decoration: InputDecoration(labelText: 'Accept Terms?'),
91+
decoration: const InputDecoration(labelText: 'Accept Terms?'),
9092
builder: (FormFieldState<bool?> field) {
9193
return InputDecorator(
9294
decoration: InputDecoration(
9395
errorText: field.errorText,
9496
),
9597
child: SwitchListTile(
96-
title: Text(
98+
title: const Text(
9799
'I have read and accept the terms of service.'),
98100
onChanged: (bool value) {
99101
field.didChange(value);
@@ -116,13 +118,13 @@ class _SignupFormState extends State<SignupForm> {
116118
// _emailFieldKey.currentState?.invalidate('Email already taken.');
117119
}
118120

119-
print('Valid');
121+
debugPrint('Valid');
120122
} else {
121-
print('Invalid');
123+
debugPrint('Invalid');
122124
}
123-
print(_formKey.currentState?.value);
125+
debugPrint(_formKey.currentState?.value.toString());
124126
},
125-
child: Text('Signup', style: TextStyle(color: Colors.white)),
127+
child: const Text('Signup', style: TextStyle(color: Colors.white)),
126128
)
127129
],
128130
),

packages/flutter_form_builder/example/pubspec.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ dependencies:
1818
sdk: flutter
1919

2020
dev_dependencies:
21+
flutter_lints: ^1.0.4
2122
flutter_test:
2223
sdk: flutter
2324

packages/form_builder_extra_fields/example/lib/home_page.dart

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,21 @@ import 'package:form_builder_extra_fields/form_builder_extra_fields.dart';
55
import 'data.dart';
66

77
class MyHomePage extends StatefulWidget {
8+
const MyHomePage({Key key}) : super(key: key);
9+
810
@override
911
_MyHomePageState createState() => _MyHomePageState();
1012
}
1113

1214
class _MyHomePageState extends State<MyHomePage> {
1315
final _formKey = GlobalKey<FormBuilderState>();
14-
final ValueChanged _onChanged = (dynamic val) => print(val);
16+
17+
void _onChanged(dynamic val) => debugPrint(val.toString());
1518

1619
@override
1720
Widget build(BuildContext context) {
1821
return Scaffold(
19-
appBar: AppBar(
20-
title: Text('Extra Fields Example'),
21-
),
22+
appBar: AppBar(title: const Text('Extra Fields Example')),
2223
body: SingleChildScrollView(
2324
child: Padding(
2425
padding: const EdgeInsets.all(8.0),
@@ -97,7 +98,7 @@ class _MyHomePageState extends State<MyHomePage> {
9798
decoration: const InputDecoration(
9899
labelText: 'Cupertino DateTime Picker',
99100
),
100-
locale: Locale.fromSubtags(languageCode: 'en_GB'),
101+
locale: const Locale.fromSubtags(languageCode: 'en_GB'),
101102
),
102103
FormBuilderCupertinoDateTimePicker(
103104
name: 'date',
@@ -106,7 +107,7 @@ class _MyHomePageState extends State<MyHomePage> {
106107
decoration: const InputDecoration(
107108
labelText: 'Cupertino DateTime Picker - Date Only',
108109
),
109-
locale: Locale.fromSubtags(languageCode: 'en_GB'),
110+
locale: const Locale.fromSubtags(languageCode: 'en_GB'),
110111
),
111112
FormBuilderCupertinoDateTimePicker(
112113
name: 'time',
@@ -115,7 +116,7 @@ class _MyHomePageState extends State<MyHomePage> {
115116
decoration: const InputDecoration(
116117
labelText: 'Cupertino DateTime Picker - Time Only',
117118
),
118-
locale: Locale.fromSubtags(languageCode: 'en_GB'),
119+
locale: const Locale.fromSubtags(languageCode: 'en_GB'),
119120
),
120121
FormBuilderTypeAhead<String>(
121122
decoration: const InputDecoration(
@@ -182,10 +183,10 @@ class _MyHomePageState extends State<MyHomePage> {
182183
onPressed: () {
183184
if (_formKey.currentState?.saveAndValidate() ??
184185
false) {
185-
print(_formKey.currentState?.value);
186+
debugPrint(_formKey.currentState?.value.toString());
186187
} else {
187-
print(_formKey.currentState?.value);
188-
print('validation failed');
188+
debugPrint(_formKey.currentState?.value.toString());
189+
debugPrint('validation failed');
189190
}
190191
},
191192
child: const Text(

0 commit comments

Comments
 (0)