@@ -201,10 +201,18 @@ class _HomePageState extends State<HomePage> {
201201
202202 const toolbarIconSize = 18.0 ;
203203 final embedButtons = FlutterQuillEmbeds .buttons (
204+ showCameraButton: false ,
205+ showFormulaButton: false ,
206+ showVideoButton: false ,
207+ showImageButton: true ,
208+
204209 // provide a callback to enable picking images from device.
205210 // if omit, "image" button only allows adding images from url.
206211 // same goes for videos.
207- // onImagePickCallback: _onImagePickCallback,
212+ onImagePickCallback: _onImagePickCallback,
213+ mediaPickSettingSelector: (context) {
214+ return Future .value (MediaPickSetting .Gallery );
215+ },
208216 // uncomment to provide a custom "pick from" dialog.
209217 // mediaPickSettingSelector: _selectMediaPickSetting,
210218 // uncomment to provide a custom "pick from" dialog.
@@ -249,6 +257,7 @@ class _HomePageState extends State<HomePage> {
249257 iconSize: toolbarIconSize,
250258 controller: _controller! ,
251259 ),
260+
252261 for (final builder in embedButtons) builder (_controller! , toolbarIconSize, null , null ),
253262 ],
254263 );
@@ -264,17 +273,6 @@ class _HomePageState extends State<HomePage> {
264273 afterButtonPressed: _focusNode.requestFocus,
265274 );
266275 }
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- }
278276
279277 return SafeArea (
280278 child: Column (
@@ -300,17 +298,6 @@ class _HomePageState extends State<HomePage> {
300298 );
301299 }
302300
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-
314301 // Renders the image picked by imagePicker from local file storage
315302 // You can also upload the picked image to any server (eg : AWS s3
316303 // or Firebase) and then return the uploaded image URL.
@@ -357,29 +344,6 @@ class _HomePageState extends State<HomePage> {
357344 ),
358345 );
359346
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-
383347 Future <String > _onImagePaste (Uint8List imageBytes) async {
384348 // Saves the image to applications directory
385349 final appDocDir = await getApplicationDocumentsDirectory ();
0 commit comments