Skip to content

Commit 72310bd

Browse files
style: format to new dart style
1 parent 060f6cf commit 72310bd

File tree

1 file changed

+70
-70
lines changed

1 file changed

+70
-70
lines changed

example/lib/main.dart

Lines changed: 70 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@ class MyApp extends StatelessWidget {
1515
Widget build(BuildContext context) {
1616
return MaterialApp(
1717
title: 'Flutter Demo',
18-
theme: ThemeData(
19-
primarySwatch: Colors.blue,
20-
),
18+
theme: ThemeData(primarySwatch: Colors.blue),
2119
home: MyHomePage(),
2220
);
2321
}
@@ -27,10 +25,7 @@ class ApiImage {
2725
final String imageUrl;
2826
final String id;
2927

30-
ApiImage({
31-
required this.imageUrl,
32-
required this.id,
33-
});
28+
ApiImage({required this.imageUrl, required this.id});
3429
}
3530

3631
class MyHomePage extends StatelessWidget {
@@ -41,9 +36,7 @@ class MyHomePage extends StatelessWidget {
4136
@override
4237
Widget build(BuildContext context) {
4338
return Scaffold(
44-
appBar: AppBar(
45-
title: const Text('FormBuilderImagePicker Example'),
46-
),
39+
appBar: AppBar(title: const Text('FormBuilderImagePicker Example')),
4740
body: Padding(
4841
padding: const EdgeInsets.all(8.0),
4942
child: Center(
@@ -56,8 +49,8 @@ class MyHomePage extends StatelessWidget {
5649
children: <Widget>[
5750
FormBuilderImagePicker(
5851
name: 'photos',
59-
displayCustomType: (obj) =>
60-
obj is ApiImage ? obj.imageUrl : obj,
52+
displayCustomType:
53+
(obj) => obj is ApiImage ? obj.imageUrl : obj,
6154
decoration: const InputDecoration(labelText: 'Pick Photos'),
6255
maxImages: 5,
6356
previewAutoSizeWidth: true,
@@ -76,8 +69,8 @@ class MyHomePage extends StatelessWidget {
7669
const SizedBox(height: 15),
7770
FormBuilderImagePicker(
7871
name: 'singlePhotoWithDecoration',
79-
displayCustomType: (obj) =>
80-
obj is ApiImage ? obj.imageUrl : obj,
72+
displayCustomType:
73+
(obj) => obj is ApiImage ? obj.imageUrl : obj,
8174
decoration: const InputDecoration(
8275
labelText: 'Pick Single Photo With Decoration Visible',
8376
),
@@ -90,11 +83,12 @@ class MyHomePage extends StatelessWidget {
9083
),
9184
const SizedBox(height: 15),
9285
const Text(
93-
'Single Photo with no decoration, and previewAutoSizeWidth=true'),
86+
'Single Photo with no decoration, and previewAutoSizeWidth=true',
87+
),
9488
FormBuilderImagePicker(
9589
name: 'singlePhoto',
96-
displayCustomType: (obj) =>
97-
obj is ApiImage ? obj.imageUrl : obj,
90+
displayCustomType:
91+
(obj) => obj is ApiImage ? obj.imageUrl : obj,
9892
// decoration: const InputDecoration(
9993
// labelText: 'Pick Photos',
10094
// ),
@@ -111,18 +105,15 @@ class MyHomePage extends StatelessWidget {
111105
),
112106
FormBuilderImagePicker(
113107
name: 'singleAvatarPhoto',
114-
displayCustomType: (obj) =>
115-
obj is ApiImage ? obj.imageUrl : obj,
116-
decoration: const InputDecoration(
117-
labelText: 'Pick Photos',
118-
),
119-
transformImageWidget: (context, displayImage) => Card(
120-
shape: const CircleBorder(),
121-
clipBehavior: Clip.antiAlias,
122-
child: SizedBox.expand(
123-
child: displayImage,
124-
),
125-
),
108+
displayCustomType:
109+
(obj) => obj is ApiImage ? obj.imageUrl : obj,
110+
decoration: const InputDecoration(labelText: 'Pick Photos'),
111+
transformImageWidget:
112+
(context, displayImage) => Card(
113+
shape: const CircleBorder(),
114+
clipBehavior: Clip.antiAlias,
115+
child: SizedBox.expand(child: displayImage),
116+
),
126117
showDecoration: false,
127118
maxImages: 1,
128119
previewAutoSizeWidth: false,
@@ -144,62 +135,71 @@ class MyHomePage extends StatelessWidget {
144135
FormBuilderImagePicker(
145136
name: 'onlyCamera',
146137
decoration: const InputDecoration(
147-
labelText: 'Pick Photos (only from camera)'),
138+
labelText: 'Pick Photos (only from camera)',
139+
),
148140
availableImageSources: const [ImageSourceOption.camera],
149141
),
150142
const SizedBox(height: 15),
151143
FormBuilderImagePicker(
152144
name: 'onlyGallery',
153145
decoration: const InputDecoration(
154-
labelText: 'Pick Photos (only from gallery)'),
146+
labelText: 'Pick Photos (only from gallery)',
147+
),
155148
availableImageSources: const [ImageSourceOption.gallery],
156149
),
157150
FormBuilderImagePicker(
158151
decoration: const InputDecoration(
159-
labelText: 'Pick Photos (with custom view)'),
152+
labelText: 'Pick Photos (with custom view)',
153+
),
160154
name: 'CupertinoActionSheet',
161-
optionsBuilder: (cameraPicker, galleryPicker) =>
162-
CupertinoActionSheet(
163-
title: const Text('Image'),
164-
message: const Text('Pick an image from given options'),
165-
actions: [
166-
CupertinoActionSheetAction(
167-
isDefaultAction: true,
168-
onPressed: () {
169-
cameraPicker();
170-
},
171-
child: const Text('Camera'),
155+
optionsBuilder:
156+
(cameraPicker, galleryPicker) => CupertinoActionSheet(
157+
title: const Text('Image'),
158+
message: const Text(
159+
'Pick an image from given options',
160+
),
161+
actions: [
162+
CupertinoActionSheetAction(
163+
isDefaultAction: true,
164+
onPressed: () {
165+
cameraPicker();
166+
},
167+
child: const Text('Camera'),
168+
),
169+
CupertinoActionSheetAction(
170+
isDefaultAction: true,
171+
onPressed: () {
172+
galleryPicker();
173+
},
174+
child: const Text('Gallery'),
175+
),
176+
],
177+
),
178+
onTap:
179+
(child) => showCupertinoModalPopup(
180+
context: context,
181+
builder: (context) => child,
172182
),
173-
CupertinoActionSheetAction(
174-
isDefaultAction: true,
175-
onPressed: () {
176-
galleryPicker();
177-
},
178-
child: const Text('Gallery'),
179-
)
180-
],
181-
),
182-
onTap: (child) => showCupertinoModalPopup(
183-
context: context,
184-
builder: (context) => child,
185-
),
186183
),
187184
FormBuilderImagePicker(
188185
name: 'customPreview',
189186
maxImages: null,
190-
previewBuilder: (context, images, addButton) =>
191-
ConstrainedBox(
192-
constraints: const BoxConstraints(
193-
minHeight: 130,
194-
maxHeight: 500,
195-
),
196-
child: GridView.extent(
197-
maxCrossAxisExtent: 130,
198-
mainAxisSpacing: 4,
199-
crossAxisSpacing: 4,
200-
children: [...images, if (addButton != null) addButton],
201-
),
202-
),
187+
previewBuilder:
188+
(context, images, addButton) => ConstrainedBox(
189+
constraints: const BoxConstraints(
190+
minHeight: 130,
191+
maxHeight: 500,
192+
),
193+
child: GridView.extent(
194+
maxCrossAxisExtent: 130,
195+
mainAxisSpacing: 4,
196+
crossAxisSpacing: 4,
197+
children: [
198+
...images,
199+
if (addButton != null) addButton,
200+
],
201+
),
202+
),
203203
),
204204
ElevatedButton(
205205
child: const Text('Submit'),
@@ -214,7 +214,7 @@ class MyHomePage extends StatelessWidget {
214214
onPressed: () {
215215
_formKey.currentState?.reset();
216216
},
217-
)
217+
),
218218
],
219219
),
220220
),

0 commit comments

Comments
 (0)