Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not sure if this is an issue or a feature #525

Open
arkanmgerges opened this issue May 28, 2022 · 2 comments
Open

Not sure if this is an issue or a feature #525

arkanmgerges opened this issue May 28, 2022 · 2 comments
Labels
enhancement New feature or request
Milestone

Comments

@arkanmgerges
Copy link

Describe the bug
A clear and concise description of what the bug is.

I'm not sure if this is a bug or a feature. I have a complex app that I've built, and I need to migrate from Navigator 1.0 to Beamer,
I successfully used BeamerLocationBuilder with beamLocations, but I was hit by some of the code that I need to migrate and I don't know if Beamer can handle this situation:
I have a code that use a scanner, then get the result back as follows:

onPressed: () async {
      var result = await Navigator.of(context).pushNamed(QrScanPage.route);
      qrcodeResult = "";
      if (result is String) {
        qrcodeResult = result;
      }

      // Try to extract project id and daily check group id from qrcode
      try {
        ProjectIdAndDailyCheckGroupId result = Project.extractProjectIdAndDailyCheckGroupId(qrcodeResult);
        SchedulerBinding.instance.addPostFrameCallback((_) {
          Navigator.of(context)
              .pushNamed(DailyCheckGroupEventsPage.route, arguments: [int.parse(result.projectId), int.parse(result.dailyCheckGroupId)]);
        });
      } catch (_e) {}

How can migrate such code ?:

var result = await Navigator.of(context).pushNamed(QrScanPage.route);

Beamer version: (e.g. v0.14.1, master, ...)
beamer: ^1.4.1+1

Thank you for making this package

@slovnicki slovnicki added the enhancement New feature or request label May 30, 2022
@slovnicki slovnicki added this to the v2 milestone May 30, 2022
@slovnicki
Copy link
Owner

Hey @arkanmgerges 👋
Thanks for creating an issue!

This functionality is a bit different in "Navigator 2.0" and is not currently well supported in Beamer. I plan to improve it for v2.
Still, you have 2 options:

  • Continue using "Navigator 1.0" for this specific scenario. Beamer has no problem with using both APIs, i.e. you can just continue using var result = await Navigator.of(context).pushNamed(QrScanPage.route). But this will not update URL so you would need to (if you need to) do it manually with Beamer.of(context).updateRouteInformation(...). As I said, this is the scenario I'm looking to improve in the near future.
  • From the QrScanScreen, save the result in some object you use for state management and then override onPopPage (which is called when you pop) in your BeamPage for QrScanScreen where you should be able to extract the wanted result from your state management.

@arkanmgerges
Copy link
Author

Thank you @slovnicki for the explanation, I will try to use one of the options you've suggested.
Thank you for making this package.

I'm not sure if this thread needs to be closed or not, so I will leave it open.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants