feduke-nukem / flutter_easy_dialogs

Easy dialogs library for Flutter
https://pub.dev/packages/flutter_easy_dialogs
MIT License
13 stars 0 forks source link

[Bug]: "Concurrent modification during iteration" when hiding dialog right after showing it #20

Closed Apollo108 closed 1 year ago

Apollo108 commented 1 year ago

What happened?

My code:

image

Usage:

image

I'm hiding it right after showing, according to logs. It doesn't happen when I'm using FlutterEasyDialogs.hide(PositionedDialog.identifier(position: EasyDialogPosition.top)); though.

But I'm trying to target a specific dialog when I'm hiding, can we expect working with dialogs by 'id's?

Relevant log output

I/flutter (17824): │ #0   _CompactIterator.moveNext (dart:collection-patch/compact_hash.dart:710:7)
I/flutter (17824): │ #1   WhereIterator.moveNext (dart:_internal/iterable.dart:440:22)
I/flutter (17824): │ #2   MappedIterator.moveNext (dart:_internal/iterable.dart:392:19)
I/flutter (17824): │ #3   Future.wait (dart:async/future.dart:523:26)
I/flutter (17824): │ #4   EasyDialogsController.hideWhere (package:flutter_easy_dialogs/src/core/easy_dialogs_controller.dart:90:14)
I/flutter (17824): │ #5   FlutterEasyDialogs.hideWhere (package:flutter_easy_dialogs/src/flutter_easy_dialogs.dart:45:18)
I/flutter (17824): │ #6   DialogService.hideNoInternetSnackbar (package:bazz_flutter/services/dialog_service.dart:54:24)
I/flutter (17824): │ #7   AuthController.onReady.<anonymous closure> (package:bazz_flutter/modules/auth_module/auth_controller.dart:149:66)
I/flutter (17824): │ #8   GetStream._notifyData (package:get/get_rx/src/rx_stream/get_stream.dart:47:21)
I/flutter (17824): │ #9   GetStream.add (package:get/get_rx/src/rx_stream/get_stream.dart:97:5)
I/flutter (17824): │ #10   RxObjectMixin.value= (package:get/get_rx/src/rx_types/rx_core/rx_impl.dart:105:13)
I/flutter (17824): │ #11   RxObjectMixin.call (package:get/get_rx/src/rx_types/rx_core/rx_impl.dart:64:7)
I/flutter (17824): │ #12   DataConnectionChecker.setIsOnline (package:bazz_flutter/services/data_connection_checker.dart:150:44)
I/flutter (17824): │ #13   DataConnectionChecker.start.<anonymous closure> (package:bazz_flutter/services/data_connection_checker.dart:162:7)
I/flutter (17824): │ #14   _RootZone.runUnaryGuarded (dart:async/zone.dart:1594:10)
I/flutter (17824): │ #15   _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11)
I/flutter (17824): ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
I/flutter (17824): │ 10:43:41.684 (+0:00:10.379604)
I/flutter (17824): ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
I/flutter (17824): │ ⛔ <PlatformDispatcher> Concurrent modification during iteration: _Map len:0.

Code of Conduct

Apollo108 commented 1 year ago

Should any checks be performed before showing or hiding dialogs in order to do it safely?

feduke-nukem commented 1 year ago

Hello, @Apollo108.

Thanks for the issue. I will take a close look now.

EasyDialogPosition is an identifier itself for the PositionedDialog. Additionally, you can use the hide method from a specific dialog instance:

final dialog = EasyDialog.positioned(
  content: Container(
    height: 150.0,
    color: Colors.blue[900],
    alignment: Alignment.center,
    child: Text(
      'dialog',
      style: const TextStyle(
        color: Colors.white,
        fontSize: 30.0,
      ),
    ),
  ),
);

dialog.show();
dialog.hide();
feduke-nukem commented 1 year ago

@Apollo108 I have published 3.1.2 version that fixes this bug. You may try it out.

Apollo108 commented 1 year ago

I wrote that the problem doesn't happen when I'm using FlutterEasyDialogs.hide(PositionedDialog.identifier(position: EasyDialogPosition.top));. Thanks for quick fixes, the package is awesome!