hm21 / pro_image_editor

The pro_image_editor is a Flutter widget designed for image editing within your application. It provides a flexible and convenient way to integrate image editing capabilities into your Flutter project.
https://hm21.github.io/pro_image_editor/
BSD 3-Clause "New" or "Revised" License
94 stars 59 forks source link

[Bug]: Custom closeWarningDialog throw error #148

Closed thanglq1 closed 2 months ago

thanglq1 commented 2 months ago

Package Version

4.2.1

Flutter Version

3.22.2

Platforms

Android, iOS

How to reproduce?

Hi @hm21. I'm trying customcloseWarningDialog but it throw error. You can see the log and the video below.

https://github.com/hm21/pro_image_editor/assets/26729342/17729809-86e2-4f40-a591-8072e131966b

Logs (optional)

[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: 'package:flutter/src/widgets/navigator.dart': Failed assertion: line 4817 pos 12: '!_debugLocked': is not true.
#0      _AssertionError._doThrowNew (dart:core-patch/errors_patch.dart:51:61)
#1      _AssertionError._throwNew (dart:core-patch/errors_patch.dart:40:5)
#2      NavigatorState._pushEntry (package:flutter/src/widgets/navigator.dart:4817:12)
#3      NavigatorState.push (package:flutter/src/widgets/navigator.dart:4774:5)
#4      showDialog (package:flutter/src/material/dialog.dart:1436:65)
#5      _CustomAppbarBottombarExampleState._buildEditor.<anonymous closure>.<anonymous closure> (package:example/pages/custom_appbar_bottombar_example.dart:149:30)
#6      ProImageEditorState.closeWarning (package:pro_image_editor/modules/main_editor/main_editor.dart:1525:65)
#7      ProImageEditorState.build.<anonymous closure> (package:pro_image_editor/modules/main_editor/main_editor.dart:1705:13)
#8      ModalRoute.onPopInvoked (packa<…>

Example code (optional)

closeWarningDialog: (proImageEditorState) async {
                return await showDialog<bool>(
                      context: context,
                      builder: (BuildContext context) => AlertDialog(
                        title: const Text('Close?'),
                        content: const Text(
                            'Are you sure you want to close the Image Editor? Your changes will not be saved.'),
                        actions: <Widget>[
                          TextButton(
                            onPressed: () => Navigator.pop(context, false),
                            child: const Text('Cancel'),
                          ),
                          TextButton(
                            onPressed: () => Navigator.pop(context, true),
                            child: const Text('OK'),
                          ),
                        ],
                      ),
                    ) ??
                    false;
              },

Device Model (optional)

No response

hm21 commented 2 months ago

Can you try version 4.2.2, maybe that will fix it for you too.

thanglq1 commented 2 months ago

Its working now. Thank you for quick fix @hm21.