Skip to content

Commit 9f666c0

Browse files
committed
feat : example for custom picker view
1 parent 2df184d commit 9f666c0

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

example/lib/main.dart

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import 'package:flutter/cupertino.dart';
12
import 'package:flutter/material.dart';
23
import 'package:flutter_form_builder/flutter_form_builder.dart';
34

@@ -153,6 +154,36 @@ class MyHomePage extends StatelessWidget {
153154
labelText: 'Pick Photos (only from gallery)'),
154155
availableImageSources: const [ImageSourceOption.gallery],
155156
),
157+
FormBuilderImagePicker(
158+
decoration: const InputDecoration(
159+
labelText: 'Pick Photos (with custom view)'),
160+
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'),
172+
),
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+
),
186+
),
156187
ElevatedButton(
157188
child: const Text('Submit'),
158189
onPressed: () {

0 commit comments

Comments
 (0)