firebase / FirebaseUI-Flutter

Apache License 2.0
107 stars 99 forks source link

🐛 setState() called after dispose(): _EmailVerificationBadgeState#cd282(lifecycle state: defunct, not mounted) #353

Open JestrabikR opened 5 months ago

JestrabikR commented 5 months ago

Is there an existing issue for this?

What plugin is this bug for?

Firebase UI Auth

What platform(s) does this bug affect?

Android

List of dependencies used.

flutter pub deps -s list
  Dart SDK 3.3.4
Flutter SDK 3.19.6
xxx 1.0.0+1

dependencies:
- flutter 0.0.0
  - characters 1.3.0
  - collection 1.18.0
  - material_color_utilities 0.8.0
  - meta 1.11.0
  - vector_math 2.1.4
  - sky_engine any
- cupertino_icons 1.0.8
- firebase_core 2.30.1
  - firebase_core_platform_interface ^5.0.0
  - firebase_core_web ^2.16.0
  - flutter any
  - meta ^1.8.0
- cloud_firestore 4.17.2
  - cloud_firestore_platform_interface ^6.2.2
  - cloud_firestore_web ^3.12.2
  - collection ^1.0.0
  - firebase_core ^2.30.1
  - firebase_core_platform_interface ^5.0.0
  - flutter any
  - meta ^1.8.0
- firebase_storage 11.7.4
  - firebase_core ^2.30.1
  - firebase_core_platform_interface ^5.0.0
  - firebase_storage_platform_interface ^5.1.19
  - firebase_storage_web ^3.9.4
  - flutter any
- firebase_auth 4.19.4
  - firebase_auth_platform_interface ^7.2.5
  - firebase_auth_web ^5.11.4
  - firebase_core ^2.30.1
  - firebase_core_platform_interface ^5.0.0
  - flutter any
  - meta ^1.8.0
- firebase_ui_auth 1.14.0
  - email_validator ^2.1.17
  - firebase_auth ^4.17.5
  - firebase_core ^2.25.4
  - firebase_dynamic_links ^5.4.14
  - firebase_ui_localizations ^1.11.0
  - firebase_ui_oauth ^1.5.2
  - firebase_ui_shared ^1.4.1
  - flutter any
  - flutter_localizations any
  - meta ^1.10.0
- json_annotation 4.9.0
  - meta ^1.4.0
- json_serializable 6.8.0
  - analyzer >=5.12.0 <7.0.0
  - async ^2.8.0
  - build ^2.0.0
  - build_config >=0.4.4 <2.0.0
  - collection ^1.14.0
  - json_annotation >=4.9.0 <4.10.0
  - meta ^1.3.0
  - path ^1.8.0
  - pub_semver ^2.0.0
  - pubspec_parse ^1.0.0
  - source_gen ^1.3.2
  - source_helper ^1.3.0
- build_runner 2.4.9
  - analyzer >=4.4.0 <7.0.0
  - args ^2.0.0
  - async ^2.5.0
  - build >=2.1.0 <2.5.0
  - build_config >=1.1.0 <1.2.0
  - build_daemon ^4.0.0
  - build_resolvers ^2.0.0
  - build_runner_core ^7.2.0
  - code_builder ^4.2.0
  - collection ^1.15.0
  - crypto ^3.0.0
  - dart_style ^2.0.0
  - frontend_server_client >=3.0.0 <5.0.0
  - glob ^2.0.0
  - graphs ^2.2.0
  - http_multi_server ^3.0.0
  - io ^1.0.0
  - js >=0.6.3 <0.8.0
  - logging ^1.0.0
  - meta ^1.3.0
  - mime ^1.0.0
  - package_config ^2.0.0
  - path ^1.8.0
  - pool ^1.5.0
  - pub_semver ^2.0.0
  - pubspec_parse ^1.0.0
  - shelf ^1.0.0
  - shelf_web_socket ^1.0.0
  - stack_trace ^1.10.0
  - stream_transform ^2.0.0
  - timing ^1.0.0
  - watcher ^1.0.0
  - web_socket_channel ^2.0.0
  - yaml ^3.0.0
- injectable 2.4.1
  - get_it >=7.2.0 <8.0.0
  - meta 1.11.0
- get_it 7.7.0
  - async ^2.11.0
  - collection ^1.17.1
  - meta ^1.11.0
- image_picker 1.1.1
  - flutter any
  - image_picker_android ^0.8.7
  - image_picker_for_web >=2.2.0 <4.0.0
  - image_picker_ios ^0.8.8
  - image_picker_linux ^0.2.1
  - image_picker_macos ^0.2.1
  - image_picker_platform_interface ^2.10.0
  - image_picker_windows ^0.2.1
- provider 6.1.2
  - collection ^1.15.0
  - flutter any
  - nested ^1.0.0
- flutter_form_builder 9.2.1
  - flutter any
  - intl >=0.18.0 <0.20.0
- flutter_localizations 0.0.0
  - flutter any
  - intl 0.18.1
  - characters 1.3.0
  - clock 1.1.1
  - collection 1.18.0
  - material_color_utilities 0.8.0
  - meta 1.11.0
  - path 1.9.0
  - vector_math 2.1.4
- intl 0.18.1
  - clock ^1.1.0
  - meta ^1.0.2
  - path ^1.8.0
- firebase_ui_localizations 1.11.0
  - flutter any
  - flutter_localizations any
  - path ^1.8.3

dev dependencies:
- injectable_generator 2.6.1
  - build ^2.1.0
  - source_gen ^1.2.7
  - path ^1.8.0
  - glob ^2.0.1
  - analyzer >=6.4.1 <7.0.0
  - code_builder ^4.10.0
  - dart_style ^2.0.3
  - injectable ^2.4.0
  - collection ^1.17.1
  - recase ^4.1.0
  - meta ^1.9.1
- flutter_test 0.0.0
  - flutter any
  - test_api 0.6.1
  - matcher 0.12.16+1
  - path 1.9.0
  - fake_async 1.3.1
  - clock 1.1.1
  - stack_trace 1.11.1
  - vector_math 2.1.4
  - leak_tracker_flutter_testing 2.0.1
  - async 2.11.0
  - boolean_selector 2.1.1
  - characters 1.3.0
  - collection 1.18.0
  - leak_tracker 10.0.0
  - leak_tracker_testing 2.0.1
  - material_color_utilities 0.8.0
  - meta 1.11.0
  - source_span 1.10.0
  - stream_channel 2.1.2
  - string_scanner 1.2.0
  - term_glyph 1.2.1
  - vm_service 13.0.0
- flutter_lints 3.0.2
  - lints ^3.0.0
- test 1.24.9
  - analyzer >=5.12.0 <7.0.0
  - async ^2.5.0
  - boolean_selector ^2.1.0
  - collection ^1.15.0
  - coverage ^1.0.1
  - http_multi_server ^3.0.0
  - io ^1.0.0
  - js ^0.6.4
  - matcher >=0.12.16 <0.12.17
  - node_preamble ^2.0.0
  - package_config ^2.0.0
  - path ^1.8.0
  - pool ^1.5.0
  - shelf ^1.0.0
  - shelf_packages_handler ^3.0.0
  - shelf_static ^1.0.0
  - shelf_web_socket ^1.0.0
  - source_span ^1.8.0
  - stack_trace ^1.10.0
  - stream_channel ^2.1.0
  - test_api 0.6.1
  - test_core 0.5.9
  - typed_data ^1.3.0
  - web_socket_channel ^2.0.0
  - webkit_inspection_protocol ^1.0.0
  - yaml ^3.0.0

transitive dependencies:
- _fe_analyzer_shared 67.0.0
  - meta ^1.9.0
- _flutterfire_internals 1.3.32
  - collection ^1.0.0
  - firebase_core ^2.30.1
  - firebase_core_platform_interface ^5.0.0
  - flutter any
  - meta ^1.8.0
- analyzer 6.4.1
  - _fe_analyzer_shared ^67.0.0
  - collection ^1.17.0
  - convert ^3.0.0
  - crypto ^3.0.0
  - glob ^2.0.0
  - meta ^1.11.0
  - package_config ^2.0.0
  - path ^1.8.0
  - pub_semver ^2.1.4
  - source_span ^1.8.0
  - watcher ^1.1.0
  - yaml ^3.0.0
- args 2.5.0
- async 2.11.0
  - collection ^1.15.0
  - meta ^1.1.7
- boolean_selector 2.1.1
  - source_span ^1.8.0
  - string_scanner ^1.1.0
- build 2.4.1
  - analyzer >=1.5.0 <7.0.0
  - async ^2.5.0
  - convert ^3.0.0
  - crypto ^3.0.0
  - glob ^2.0.0
  - logging ^1.0.0
  - meta ^1.3.0
  - package_config ^2.1.0
  - path ^1.8.0
- build_config 1.1.1
  - checked_yaml ^2.0.0
  - json_annotation ^4.5.0
  - path ^1.8.0
  - pubspec_parse ^1.0.0
  - yaml ^3.0.0
- build_daemon 4.0.1
  - built_collection ^5.0.0
  - built_value ^8.1.0
  - crypto ^3.0.3
  - http_multi_server ^3.0.0
  - logging ^1.0.0
  - path ^1.8.0
  - pool ^1.5.0
  - shelf ^1.0.0
  - shelf_web_socket ^1.0.0
  - stream_transform ^2.0.0
  - watcher ^1.0.0
  - web_socket_channel ^2.0.0
- build_resolvers 2.4.2
  - analyzer >=5.12.0 <7.0.0
  - async ^2.5.0
  - build ^2.0.0
  - collection ^1.17.0
  - convert ^3.1.1
  - crypto ^3.0.0
  - graphs >=1.0.0 <3.0.0
  - logging ^1.0.0
  - package_config ^2.0.0
  - path ^1.8.0
  - pool ^1.5.0
  - pub_semver ^2.0.0
  - stream_transform ^2.0.0
  - yaml ^3.0.0
- build_runner_core 7.3.0
  - async ^2.5.0
  - build ^2.4.0
  - build_config ^1.0.0
  - build_resolvers ^2.4.0
  - collection ^1.15.0
  - convert ^3.0.0
  - crypto ^3.0.0
  - glob ^2.0.0
  - graphs ^2.0.0
  - json_annotation ^4.8.1
  - logging ^1.2.0
  - meta ^1.3.0
  - package_config ^2.0.0
  - path ^1.8.0
  - pool ^1.5.0
  - timing ^1.0.0
  - watcher ^1.0.0
  - yaml ^3.0.0
- built_collection 5.1.1
- built_value 8.9.2
  - built_collection ^5.0.0
  - collection ^1.15.0
  - fixnum ^1.0.0
  - meta ^1.3.0
- characters 1.3.0
- checked_yaml 2.0.3
  - json_annotation ^4.3.0
  - source_span ^1.8.0
  - yaml ^3.0.0
- clock 1.1.1
- cloud_firestore_platform_interface 6.2.2
  - _flutterfire_internals ^1.3.32
  - collection ^1.15.0
  - firebase_core ^2.30.1
  - flutter any
  - meta ^1.8.0
  - plugin_platform_interface ^2.1.3
- cloud_firestore_web 3.12.2
  - _flutterfire_internals ^1.3.32
  - cloud_firestore_platform_interface ^6.2.2
  - collection ^1.0.0
  - firebase_core ^2.30.1
  - firebase_core_web ^2.16.0
  - flutter any
  - flutter_web_plugins any
- code_builder 4.10.0
  - built_collection ^5.0.0
  - built_value ^8.0.0
  - collection ^1.15.0
  - matcher ^0.12.10
  - meta ^1.3.0
- collection 1.18.0
- convert 3.1.1
  - typed_data ^1.3.0
- coverage 1.7.2
  - args ^2.0.0
  - logging ^1.0.0
  - package_config ^2.0.0
  - path ^1.8.0
  - source_maps ^0.10.10
  - stack_trace ^1.10.0
  - vm_service >=12.0.0 <15.0.0
- cross_file 0.3.4+1
  - meta ^1.3.0
  - web ^0.5.0
- crypto 3.0.3
  - typed_data ^1.3.0
- dart_style 2.3.6
  - analyzer ^6.2.0
  - args >=1.0.0 <3.0.0
  - collection ^1.17.0
  - path ^1.0.0
  - pub_semver >=1.4.4 <3.0.0
  - source_span ^1.4.0
- desktop_webview_auth 0.0.15
  - crypto ^3.0.3
  - flutter any
  - http ^1.0.0
  - flutter_web_plugins any
  - plugin_platform_interface ^2.1.4
- email_validator 2.1.17
- fake_async 1.3.1
  - clock ^1.1.0
  - collection ^1.15.0
- file 7.0.0
  - meta ^1.9.1
  - path ^1.8.3
- file_selector_linux 0.9.2+1
  - cross_file ^0.3.1
  - file_selector_platform_interface ^2.6.0
  - flutter any
- file_selector_macos 0.9.4
  - cross_file ^0.3.1
  - file_selector_platform_interface ^2.6.0
  - flutter any
- file_selector_platform_interface 2.6.2
  - cross_file ^0.3.0
  - flutter any
  - http >=0.13.0 <2.0.0
  - plugin_platform_interface ^2.1.7
- file_selector_windows 0.9.3+1
  - cross_file ^0.3.1
  - file_selector_platform_interface ^2.6.0
  - flutter any
- firebase_auth_platform_interface 7.2.5
  - _flutterfire_internals ^1.3.32
  - collection ^1.16.0
  - firebase_core ^2.30.1
  - flutter any
  - meta ^1.8.0
  - plugin_platform_interface ^2.1.3
- firebase_auth_web 5.11.4
  - firebase_auth_platform_interface ^7.2.5
  - firebase_core ^2.30.1
  - firebase_core_web ^2.16.0
  - flutter any
  - flutter_web_plugins any
  - http_parser ^4.0.0
  - meta ^1.8.0
  - web ^0.5.1
- firebase_core_platform_interface 5.0.0
  - collection ^1.0.0
  - flutter any
  - flutter_test any
  - meta ^1.8.0
  - plugin_platform_interface ^2.1.3
- firebase_core_web 2.16.0
  - firebase_core_platform_interface ^5.0.0
  - flutter any
  - flutter_web_plugins any
  - meta ^1.8.0
  - web ^0.5.1
- firebase_dynamic_links 5.5.4
  - firebase_core ^2.30.1
  - firebase_core_platform_interface ^5.0.0
  - firebase_dynamic_links_platform_interface ^0.2.6+32
  - flutter any
  - meta ^1.8.0
  - plugin_platform_interface ^2.1.3
- firebase_dynamic_links_platform_interface 0.2.6+32
  - _flutterfire_internals ^1.3.32
  - firebase_core ^2.30.1
  - flutter any
  - meta ^1.8.0
  - plugin_platform_interface ^2.1.3
- firebase_storage_platform_interface 5.1.19
  - _flutterfire_internals ^1.3.32
  - collection ^1.15.0
  - firebase_core ^2.30.1
  - flutter any
  - meta ^1.8.0
  - plugin_platform_interface ^2.1.3
- firebase_storage_web 3.9.4
  - _flutterfire_internals ^1.3.32
  - async ^2.5.0
  - firebase_core ^2.30.1
  - firebase_core_web ^2.16.0
  - firebase_storage_platform_interface ^5.1.19
  - flutter any
  - flutter_web_plugins any
  - http >=0.13.0 <2.0.0
  - meta ^1.8.0
  - web ^0.5.1
- firebase_ui_oauth 1.5.2
  - desktop_webview_auth ^0.0.14
  - firebase_auth ^4.17.5
  - firebase_ui_auth ^1.14.0
  - firebase_ui_shared ^1.4.1
  - flutter_svg ^2.0.9
  - flutter any
- firebase_ui_shared 1.4.1
  - flutter any
- fixnum 1.1.0
- flutter_plugin_android_lifecycle 2.0.19
  - flutter any
- flutter_svg 2.0.10+1
  - flutter any
  - http ^1.0.0
  - vector_graphics ^1.1.11
  - vector_graphics_codec ^1.1.11
  - vector_graphics_compiler ^1.1.11
- flutter_web_plugins 0.0.0
  - flutter any
  - characters 1.3.0
  - collection 1.18.0
  - material_color_utilities 0.8.0
  - meta 1.11.0
  - vector_math 2.1.4
- frontend_server_client 3.2.0
  - async ^2.5.0
  - path ^1.8.0
- glob 2.1.2
  - async ^2.5.0
  - collection ^1.15.0
  - file >=6.1.3 <8.0.0
  - path ^1.8.0
  - string_scanner ^1.1.0
- graphs 2.3.1
  - collection ^1.1.0
- http 1.2.1
  - async ^2.5.0
  - http_parser ^4.0.0
  - meta ^1.3.0
  - web ^0.5.0
- http_multi_server 3.2.1
  - async ^2.5.0
- http_parser 4.0.2
  - collection ^1.15.0
  - source_span ^1.8.0
  - string_scanner ^1.1.0
  - typed_data ^1.3.0
- image_picker_android 0.8.12+1
  - flutter any
  - flutter_plugin_android_lifecycle ^2.0.1
  - image_picker_platform_interface ^2.10.0
- image_picker_for_web 3.0.4
  - flutter any
  - flutter_web_plugins any
  - image_picker_platform_interface ^2.9.0
  - mime ^1.0.4
  - web ^0.5.1
- image_picker_ios 0.8.11+2
  - flutter any
  - image_picker_platform_interface ^2.10.0
- image_picker_linux 0.2.1+1
  - file_selector_linux ^0.9.1+3
  - file_selector_platform_interface ^2.2.0
  - flutter any
  - image_picker_platform_interface ^2.8.0
- image_picker_macos 0.2.1+1
  - file_selector_macos ^0.9.1+1
  - file_selector_platform_interface ^2.3.0
  - flutter any
  - image_picker_platform_interface ^2.8.0
- image_picker_platform_interface 2.10.0
  - cross_file ^0.3.1+1
  - flutter any
  - http >=0.13.0 <2.0.0
  - plugin_platform_interface ^2.1.7
- image_picker_windows 0.2.1+1
  - file_selector_platform_interface ^2.2.0
  - file_selector_windows ^0.9.0
  - flutter any
  - image_picker_platform_interface ^2.8.0
- io 1.0.4
  - meta ^1.3.0
  - path ^1.8.0
  - string_scanner ^1.1.0
- js 0.6.7
  - meta ^1.7.0
- leak_tracker 10.0.0
  - clock ^1.1.1
  - collection ^1.15.0
  - meta ^1.8.0
  - path ^1.8.3
  - vm_service >=11.10.0 <15.0.0
- leak_tracker_flutter_testing 2.0.1
  - flutter any
  - leak_tracker >=10.0.0 <11.0.0
  - leak_tracker_testing >=2.0.1 <3.0.0
  - matcher ^0.12.16
  - meta ^1.8.0
- leak_tracker_testing 2.0.1
  - leak_tracker >=9.0.0 <11.0.0
  - matcher ^0.12.16
  - meta ^1.11.0
- lints 3.0.0
- logging 1.2.0
- matcher 0.12.16+1
  - async ^2.10.0
  - meta ^1.8.0
  - stack_trace ^1.10.0
  - term_glyph ^1.2.0
  - test_api >=0.5.0 <0.8.0
- material_color_utilities 0.8.0
  - collection ^1.15.0
- meta 1.11.0
- mime 1.0.5
- nested 1.0.0
  - flutter any
- node_preamble 2.0.2
- package_config 2.1.0
  - path ^1.8.0
- path 1.9.0
- path_parsing 1.0.1
  - vector_math ^2.1.0
  - meta ^1.3.0
- petitparser 6.0.2
  - meta ^1.9.0
- plugin_platform_interface 2.1.8
  - meta ^1.3.0
- pool 1.5.1
  - async ^2.5.0
  - stack_trace ^1.10.0
- pub_semver 2.1.4
  - collection ^1.15.0
  - meta ^1.3.0
- pubspec_parse 1.2.3
  - checked_yaml ^2.0.1
  - collection ^1.15.0
  - json_annotation ^4.8.0
  - pub_semver ^2.0.0
  - yaml ^3.0.0
- recase 4.1.0
- shelf 1.4.1
  - async ^2.5.0
  - collection ^1.15.0
  - http_parser ^4.0.0
  - path ^1.8.0
  - stack_trace ^1.10.0
  - stream_channel ^2.1.0
- shelf_packages_handler 3.0.2
  - path ^1.8.0
  - shelf ^1.0.0
  - shelf_static ^1.0.0
- shelf_static 1.1.2
  - convert ^3.0.0
  - http_parser ^4.0.0
  - mime ^1.0.0
  - path ^1.8.0
  - shelf ^1.1.2
- shelf_web_socket 1.0.4
  - shelf ^1.1.0
  - stream_channel ^2.1.0
  - web_socket_channel ^2.0.0
- sky_engine 0.0.99
- source_gen 1.5.0
  - analyzer >=5.2.0 <7.0.0
  - async ^2.5.0
  - build ^2.1.0
  - dart_style ^2.0.0
  - glob ^2.0.0
  - path ^1.8.0
  - source_span ^1.8.0
  - yaml ^3.0.0
- source_helper 1.3.4
  - analyzer >=5.12.0 <7.0.0
  - collection ^1.15.0
  - source_gen ^1.0.0
- source_map_stack_trace 2.1.1
  - path ^1.8.0
  - source_maps ^0.10.10
  - stack_trace ^1.10.0
- source_maps 0.10.12
  - source_span ^1.8.0
- source_span 1.10.0
  - collection ^1.15.0
  - path ^1.8.0
  - term_glyph ^1.2.0
- stack_trace 1.11.1
  - path ^1.8.0
- stream_channel 2.1.2
  - async ^2.5.0
- stream_transform 2.1.0
- string_scanner 1.2.0
  - source_span ^1.8.0
- term_glyph 1.2.1
- test_api 0.6.1
  - async ^2.5.0
  - boolean_selector ^2.1.0
  - collection ^1.15.0
  - meta ^1.3.0
  - source_span ^1.8.0
  - stack_trace ^1.10.0
  - stream_channel ^2.1.0
  - string_scanner ^1.1.0
  - term_glyph ^1.2.0
- test_core 0.5.9
  - analyzer >=3.3.0 <7.0.0
  - args ^2.0.0
  - async ^2.5.0
  - boolean_selector ^2.1.0
  - collection ^1.15.0
  - coverage ^1.0.0
  - frontend_server_client >=3.2.0 <4.0.0
  - glob ^2.0.0
  - io ^1.0.0
  - meta ^1.3.0
  - package_config ^2.0.0
  - path ^1.8.0
  - pool ^1.5.0
  - source_map_stack_trace ^2.1.0
  - source_maps ^0.10.10
  - source_span ^1.8.0
  - stack_trace ^1.10.0
  - stream_channel ^2.1.0
  - test_api 0.6.1
  - vm_service >=6.0.0 <14.0.0
  - yaml ^3.0.0
- timing 1.0.1
  - json_annotation ^4.3.0
- typed_data 1.3.2
  - collection ^1.15.0
- vector_graphics 1.1.11+1
  - flutter any
  - http ^1.0.0
  - vector_graphics_codec 1.1.11+1
- vector_graphics_codec 1.1.11+1
- vector_graphics_compiler 1.1.11+1
  - args ^2.3.0
  - meta ^1.7.0
  - path_parsing ^1.0.1
  - xml ^6.3.0
  - vector_graphics_codec 1.1.11+1
  - path ^1.8.0
- vector_math 2.1.4
- vm_service 13.0.0
- watcher 1.1.0
  - async ^2.5.0
  - path ^1.8.0
- web 0.5.1
- web_socket_channel 2.4.5
  - async ^2.5.0
  - crypto ^3.0.0
  - stream_channel ^2.1.0
  - web ^0.5.0
- webkit_inspection_protocol 1.2.1
  - logging ^1.0.0
- xml 6.5.0
  - collection ^1.18.0
  - meta ^1.9.0
  - petitparser ^6.0.0
- yaml 3.1.2
  - collection ^1.15.0
  - source_span ^1.8.0
  - string_scanner ^1.1.0

Steps to reproduce

I can reproduce this bug in my app when I:

  1. Start the app
  2. Go to ProfileScreen
  3. Click "close" button under "email is not verified"
  4. Go to my page
  5. In my page I have form with ImagePicker that displays image after picking - after I pick image this error happens
                     pickedImage == null
                        ? Container()
                        : SizedBox(
                      width: size.width,
                      height: size.height * 0.23,
                      child: ClipRRect(
                        borderRadius: BorderRadius.circular(32.0),
                        child: Image.file(
                          File(pickedImage!.path),
                          fit: BoxFit.cover,
                          width: double.infinity,
                          height: double.infinity,
                        ),
                      ),
                    ),

                    ElevatedButton(
                      onPressed: () async {
                        ImagePicker imagePicker = ImagePicker();
                        pickedImage = await imagePicker.pickImage(source: ImageSource.gallery);
                        setState(() {}); // reload to display image
                      },
                      child: const Text("Vybrat obrázek")
                    ),

Expected Behavior

If I pick the image without closing the widget on profile screen, image is display without an error

Actual Behavior

If I close the widget on profile screen and then try to pick image, error is thrown after the setState(() { });

Additional Information

Error output:

======== Exception caught by foundation library ====================================================
The following assertion was thrown while dispatching notifications for EmailVerificationController:
setState() called after dispose(): _EmailVerificationBadgeState#cd282(lifecycle state: defunct, not mounted)

This error happens if you call setState() on a State object for a widget that no longer appears in the widget tree (e.g., whose parent widget no longer includes the widget in its build). This error can occur when code calls setState() from a timer or an animation callback.

The preferred solution is to cancel the timer or stop listening to the animation in the dispose() callback. Another solution is to check the "mounted" property of this object before calling setState() to ensure the object is still in the tree.
This error might indicate a memory leak if setState() is being called because another object is retaining a reference to this State object after it has been removed from the tree. To avoid memory leaks, consider breaking the reference to this object during dispose().

When the exception was thrown, this was the stack: 
#0      State.setState.<anonymous closure> (package:flutter/src/widgets/framework.dart:1167:9)
#1      State.setState (package:flutter/src/widgets/framework.dart:1202:6)
#2      _EmailVerificationBadgeState.service.<anonymous closure> (package:firebase_ui_auth/src/screens/profile_screen.dart:359:7)
#3      ChangeNotifier.notifyListeners (package:flutter/src/foundation/change_notifier.dart:433:24)
#4      ValueNotifier.value= (package:flutter/src/foundation/change_notifier.dart:555:5)
#5      EmailVerificationController.reload (package:firebase_ui_auth/src/email_verification.dart:89:7)
<asynchronous suspension>
The EmailVerificationController sending notification was: EmailVerificationController#9f882(EmailVerificationState.unverified)
russellwheatley commented 4 months ago

Hi @JestrabikR - do you mind providing a full reproduction code repository demonstrating this issue so I can check, please?

JestrabikR commented 4 months ago

Hello @russellwheatley, thank you. I was able to reproduce it with this code. This issue was discovered on Android device, haven't tested it on iOS yet.

To reproduce, you do the same as described above:

  1. Start the app
  2. Go to the ProfileScreen
  3. Click "close" button under "email is not verified"
  4. Go to the TestPage
  5. Click "Choose image" button
  6. Gallery will show up
  7. Close the gallery Then the error should be thrown

main.dart:

return MaterialApp(
  //... another params- not relevant to this example
  routes: {
    '/testPage': (context) {
        return const TestPage();
     },

     '/profile': (context) {
            return ProfileScreen(
              providers: providers,
              children: [
                ElevatedButton(
                  onPressed: () {
                    Navigator.pushNamed(context, '/testPage');
                  },
                  child: const Text("Test page"),
                ),

              ],
            );
        },
  }
)

test_page.dart:

import 'package:flutter/material.dart';
import 'package:image_picker/image_picker.dart';

class TestPage extends StatefulWidget {
  const TestPage({super.key});

  @override
  State<TestPage> createState() => _TestPageState();
}

class _TestPageState extends State<TestPage> {
  XFile? pickedImage;
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(),
      body: ElevatedButton(
          onPressed: () async {
            ImagePicker imagePicker = ImagePicker();
            pickedImage = await imagePicker.pickImage(source: ImageSource.gallery);
            setState(() {}); // reload to display image
          },
          child: const Text("Choose image")
      ),
    );
  }
}
russellwheatley commented 1 week ago

Hi @JestrabikR - I have a tentative fix for your issue. Do you mind trying out that branch and letting me know if it fixes your issue?

Here is the PR with relevant branch: https://github.com/firebase/FirebaseUI-Flutter/pull/419

russellwheatley commented 6 days ago

@JestrabikR - I couldn't get your example repro to work so it would be great if you could confirm