@@ -201,10 +201,18 @@ class _HomePageState extends State<HomePage> {
201
201
202
202
const toolbarIconSize = 18.0 ;
203
203
final embedButtons = FlutterQuillEmbeds .buttons (
204
+ showCameraButton: false ,
205
+ showFormulaButton: false ,
206
+ showVideoButton: false ,
207
+ showImageButton: true ,
208
+
204
209
// provide a callback to enable picking images from device.
205
210
// if omit, "image" button only allows adding images from url.
206
211
// same goes for videos.
207
- // onImagePickCallback: _onImagePickCallback,
212
+ onImagePickCallback: _onImagePickCallback,
213
+ mediaPickSettingSelector: (context) {
214
+ return Future .value (MediaPickSetting .Gallery );
215
+ },
208
216
// uncomment to provide a custom "pick from" dialog.
209
217
// mediaPickSettingSelector: _selectMediaPickSetting,
210
218
// uncomment to provide a custom "pick from" dialog.
@@ -249,6 +257,7 @@ class _HomePageState extends State<HomePage> {
249
257
iconSize: toolbarIconSize,
250
258
controller: _controller! ,
251
259
),
260
+
252
261
for (final builder in embedButtons) builder (_controller! , toolbarIconSize, null , null ),
253
262
],
254
263
);
@@ -264,17 +273,6 @@ class _HomePageState extends State<HomePage> {
264
273
afterButtonPressed: _focusNode.requestFocus,
265
274
);
266
275
}
267
- if (_isDesktop ()) {
268
- toolbar = QuillToolbar .basic (
269
- controller: _controller! ,
270
- embedButtons: FlutterQuillEmbeds .buttons (
271
- onImagePickCallback: _onImagePickCallback,
272
- filePickImpl: openFileSystemPickerForDesktop,
273
- ),
274
- showAlignmentButtons: true ,
275
- afterButtonPressed: _focusNode.requestFocus,
276
- );
277
- }
278
276
279
277
return SafeArea (
280
278
child: Column (
@@ -300,17 +298,6 @@ class _HomePageState extends State<HomePage> {
300
298
);
301
299
}
302
300
303
- bool _isDesktop () => ! kIsWeb && ! Platform .isAndroid && ! Platform .isIOS;
304
-
305
- Future <String ?> openFileSystemPickerForDesktop (BuildContext context) async {
306
- return await FilesystemPicker .open (
307
- context: context,
308
- rootDirectory: await getApplicationDocumentsDirectory (),
309
- fsType: FilesystemType .file,
310
- fileTileSelectMode: FileTileSelectMode .wholeTile,
311
- );
312
- }
313
-
314
301
// Renders the image picked by imagePicker from local file storage
315
302
// You can also upload the picked image to any server (eg : AWS s3
316
303
// or Firebase) and then return the uploaded image URL.
@@ -357,29 +344,6 @@ class _HomePageState extends State<HomePage> {
357
344
),
358
345
);
359
346
360
- // ignore: unused_element
361
- Future <MediaPickSetting ?> _selectCameraPickSetting (BuildContext context) => showDialog <MediaPickSetting >(
362
- context: context,
363
- builder: (ctx) => AlertDialog (
364
- contentPadding: EdgeInsets .zero,
365
- content: Column (
366
- mainAxisSize: MainAxisSize .min,
367
- children: [
368
- TextButton .icon (
369
- icon: const Icon (Icons .camera),
370
- label: const Text ('Capture a photo' ),
371
- onPressed: () => Navigator .pop (ctx, MediaPickSetting .Camera ),
372
- ),
373
- TextButton .icon (
374
- icon: const Icon (Icons .video_call),
375
- label: const Text ('Capture a video' ),
376
- onPressed: () => Navigator .pop (ctx, MediaPickSetting .Video ),
377
- )
378
- ],
379
- ),
380
- ),
381
- );
382
-
383
347
Future <String > _onImagePaste (Uint8List imageBytes) async {
384
348
// Saves the image to applications directory
385
349
final appDocDir = await getApplicationDocumentsDirectory ();
0 commit comments