Mantano/iridium

Issue with back button in ReaderAppBar

carman247 opened this issue · 3 comments

Haven't quite got to the bottom of it yet but when running in release mode it seems there is an error/bug preventing closing the reader.

I think this onPopInvoked is throwing an error most of the time, possibly preventing the pop. Also seems to be getting called over an over again and maybe causing a stack overflow error:

reader_widget/lib/views/viewers/epub_screen.dart

  @override
  void onPopInvoked(didPop) async {
    try {
      readerContext.paginationInfo?.let((paginationInfo) =>
          readerAnnotationRepository.savePosition(paginationInfo));
      Navigator.pop(context, {
        'locator': readerContext.paginationInfo?.locator.json,
        'settings': _viewerSettingsBloc.viewerSettings.fontSize.toString(),
        'theme': json.encode(_readerThemeBloc.currentTheme.toJson()),
      });
    } catch (e) {
      // perhaps a snackbar notification can be added to indicate that there was a problem saving last location and settings
      debugPrint('error returning location and settings');
    }
  }

I'm not to interested in saving the info on pop so have removed the PopScope widget that wraps the scaffold in reader_widget/lib/views/viewers/epub_screen.dart in order to bypass the problem for now.

Thank you for this report. I'm surprised to see that we don't test didPop, but it's probably not the cause of your issue. But who knows, maybe you could try to add a test and only do the work if didPop is true?

Will do

It's probably a bug I introduced with this commit. You can undo the migration that I made from WillPopScope to PopScope.
Unfortunately, this commit contained a bunch of unrelated stuff, so you should simply manually pick the modifications related to this migration.
I'll try to make more atomic commits in the future, these ones were made in a hurry...