Skip to content

Commit 8bbfdbf

Browse files
test: add test fixes
1 parent 881d1d7 commit 8bbfdbf

File tree

6 files changed

+246
-1
lines changed

6 files changed

+246
-1
lines changed

.github/workflows/base.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,13 @@ jobs:
4242
- name: Install dependencies
4343
run: flutter pub get
4444
- name: Format code
45-
run: dart format --set-exit-if-changed .
45+
run: dart format --set-exit-if-changed lib/ test/ example/
4646
- name: Analyze static code
4747
run: flutter analyze
4848
- name: Run tests
4949
run: flutter test --coverage
50+
- name: Run fixes tests
51+
run: dart fix --compare-to-golden test_fixes/
5052
- name: Upload coverage to Codecov
5153
uses: codecov/codecov-action@v5
5254
with:

analysis_options.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
11
include: package:flutter_lints/flutter.yaml
2+
3+
analyzer:
4+
exclude:
5+
- "test_fixes/**"

lib/fix_data.yaml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
version: 1
2+
transforms:
3+
- title: 'Remove deprecated maxChips property on FormBuilderFilterChip'
4+
date: 2025-01-15
5+
element:
6+
uris: [ 'flutter_form_builder.dart' ]
7+
constructor: ''
8+
inClass: 'FormBuilderFilterChip'
9+
changes:
10+
- kind: 'removeParameter'
11+
name: 'maxChips'
12+
- title: 'Remove deprecated resetIcon property on FormBuilderDateTimePicker'
13+
date: 2025-01-15
14+
element:
15+
uris: [ 'flutter_form_builder.dart' ]
16+
constructor: ''
17+
inClass: 'FormBuilderDateTimePicker'
18+
changes:
19+
- kind: 'removeParameter'
20+
name: 'resetIcon'
21+
- title: 'Remove deprecated onPopInvoked property on FormBuilder'
22+
date: 2025-01-15
23+
element:
24+
uris: [ 'flutter_form_builder.dart' ]
25+
constructor: ''
26+
inClass: 'FormBuilder'
27+
changes:
28+
- kind: 'removeParameter'
29+
name: 'onPopInvoked'
30+
- title: 'Rename FormBuilderChoiceChip to be plural'
31+
date: 2025-01-15
32+
element:
33+
uris: [ 'flutter_form_builder.dart' ]
34+
class: 'FormBuilderChoiceChip'
35+
changes:
36+
- kind: 'rename'
37+
newName: 'FormBuilderChoiceChips'
38+
- title: 'Rename FormBuilderFilterChip to be plural'
39+
date: 2025-01-15
40+
element:
41+
uris: [ 'flutter_form_builder.dart' ]
42+
class: 'FormBuilderFilterChip'
43+
changes:
44+
- kind: 'rename'
45+
newName: 'FormBuilderFilterChips'

test_fixes/analysis_options.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
include: package:flutter_lints/flutter.yaml

test_fixes/fixes_10.0.0.dart

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
// test_fixes/fix_test.dart
2+
import 'package:flutter/material.dart';
3+
import 'package:flutter_form_builder/flutter_form_builder.dart';
4+
5+
void main() => runApp(const MyApp());
6+
7+
class MyApp extends StatelessWidget {
8+
const MyApp({super.key});
9+
10+
@override
11+
Widget build(BuildContext context) {
12+
return MaterialApp(
13+
title: 'Flutter FormBuilder Example',
14+
debugShowCheckedModeBanner: false,
15+
home: const _ExamplePage(),
16+
);
17+
}
18+
}
19+
20+
class _ExamplePage extends StatefulWidget {
21+
const _ExamplePage();
22+
23+
@override
24+
State<_ExamplePage> createState() => _ExamplePageState();
25+
}
26+
27+
class _ExamplePageState extends State<_ExamplePage> {
28+
final _formKey = GlobalKey<FormBuilderState>();
29+
30+
@override
31+
Widget build(BuildContext context) {
32+
return Scaffold(
33+
appBar: AppBar(title: const Text('Minimal code example')),
34+
body: Padding(
35+
padding: const EdgeInsets.all(16),
36+
child: FormBuilder(
37+
key: _formKey,
38+
onPopInvoked: (p0) {},
39+
child: Column(
40+
children: [
41+
FormBuilderDateTimePicker(
42+
name: 'date',
43+
resetIcon: const Icon(Icons.clear),
44+
),
45+
FormBuilderChoiceChip<String>(
46+
name: 'choice_chip',
47+
options: const [
48+
'Option 1',
49+
'Option 2',
50+
'Option 3',
51+
].map((e) => FormBuilderChipOption(value: e)).toList(),
52+
),
53+
FormBuilderFilterChip(
54+
maxChips: 2,
55+
decoration: const InputDecoration(
56+
labelText: 'The language of my people',
57+
enabled: false,
58+
),
59+
name: 'languages_filter',
60+
selectedColor: Colors.red,
61+
options: const [
62+
FormBuilderChipOption(
63+
value: 'Dart',
64+
avatar: CircleAvatar(child: Text('D')),
65+
),
66+
FormBuilderChipOption(
67+
value: 'Kotlin',
68+
avatar: CircleAvatar(child: Text('K')),
69+
),
70+
FormBuilderChipOption(
71+
value: 'Java',
72+
avatar: CircleAvatar(child: Text('J')),
73+
),
74+
FormBuilderChipOption(
75+
value: 'Swift',
76+
avatar: CircleAvatar(child: Text('S')),
77+
),
78+
FormBuilderChipOption(
79+
value: 'Objective-C',
80+
avatar: CircleAvatar(child: Text('O')),
81+
),
82+
],
83+
),
84+
const SizedBox(height: 10),
85+
ElevatedButton(
86+
onPressed: () {
87+
_formKey.currentState?.saveAndValidate();
88+
debugPrint(_formKey.currentState?.value.toString());
89+
},
90+
child: const Text('Print'),
91+
)
92+
],
93+
),
94+
),
95+
),
96+
);
97+
}
98+
}

test_fixes/fixes_10.0.0.dart.expect

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
// test_fixes/fix_test.dart
2+
import 'package:flutter/material.dart';
3+
import 'package:flutter_form_builder/flutter_form_builder.dart';
4+
5+
void main() => runApp(const MyApp());
6+
7+
class MyApp extends StatelessWidget {
8+
const MyApp({super.key});
9+
10+
@override
11+
Widget build(BuildContext context) {
12+
return MaterialApp(
13+
title: 'Flutter FormBuilder Example',
14+
debugShowCheckedModeBanner: false,
15+
home: const _ExamplePage(),
16+
);
17+
}
18+
}
19+
20+
class _ExamplePage extends StatefulWidget {
21+
const _ExamplePage();
22+
23+
@override
24+
State<_ExamplePage> createState() => _ExamplePageState();
25+
}
26+
27+
class _ExamplePageState extends State<_ExamplePage> {
28+
final _formKey = GlobalKey<FormBuilderState>();
29+
30+
@override
31+
Widget build(BuildContext context) {
32+
return Scaffold(
33+
appBar: AppBar(title: const Text('Minimal code example')),
34+
body: Padding(
35+
padding: const EdgeInsets.all(16),
36+
child: FormBuilder(
37+
key: _formKey,
38+
child: Column(
39+
children: [
40+
FormBuilderDateTimePicker(
41+
name: 'date',
42+
),
43+
FormBuilderChoiceChips<String>(
44+
name: 'choice_chip',
45+
options: const [
46+
'Option 1',
47+
'Option 2',
48+
'Option 3',
49+
].map((e) => FormBuilderChipOption(value: e)).toList(),
50+
),
51+
FormBuilderFilterChips(
52+
decoration: const InputDecoration(
53+
labelText: 'The language of my people',
54+
enabled: false,
55+
),
56+
name: 'languages_filter',
57+
selectedColor: Colors.red,
58+
options: const [
59+
FormBuilderChipOption(
60+
value: 'Dart',
61+
avatar: CircleAvatar(child: Text('D')),
62+
),
63+
FormBuilderChipOption(
64+
value: 'Kotlin',
65+
avatar: CircleAvatar(child: Text('K')),
66+
),
67+
FormBuilderChipOption(
68+
value: 'Java',
69+
avatar: CircleAvatar(child: Text('J')),
70+
),
71+
FormBuilderChipOption(
72+
value: 'Swift',
73+
avatar: CircleAvatar(child: Text('S')),
74+
),
75+
FormBuilderChipOption(
76+
value: 'Objective-C',
77+
avatar: CircleAvatar(child: Text('O')),
78+
),
79+
],
80+
),
81+
const SizedBox(height: 10),
82+
ElevatedButton(
83+
onPressed: () {
84+
_formKey.currentState?.saveAndValidate();
85+
debugPrint(_formKey.currentState?.value.toString());
86+
},
87+
child: const Text('Print'),
88+
)
89+
],
90+
),
91+
),
92+
),
93+
);
94+
}
95+
}

0 commit comments

Comments
 (0)