student-hub / acs-upb-mobile

A mobile application for students at ACS UPB.
MIT License
27 stars 22 forks source link

Add wrapper over Navigator to support both web and mobile navigation #265

Closed RazvanRotaru closed 2 years ago

RazvanRotaru commented 3 years ago

This solves #209.

A custom navigation option AppNavigator is implemented and used instead of the basic Navigator. This method assures that the web navigation will have Navigator 2.0 features as history, back and forward support, while mobile navigation will remain the same, using the basic imperative Navigator.

Navigator 2.0 overview

Important implementation details:

acs-upb-mobile-bot commented 3 years ago
3 Warnings
:warning: Big PR
:warning: No test changes detected. You should usually add at least one test for any new functionality.
:warning: lib/pages/people/view/people_page.dart#L13 - The library 'package:flutter/material.dart' doesn't export a member with the hidden name 'Autocomplete'

If this is a trivial change that doesn't warrant a test or changelog entry, you can mark it as #trivial in the PR title.

Generated by :no_entry_sign: Danger

vladtf commented 3 years ago

Getting this exception when redirected to home page after authentication:


++++++++++++
restoreRouteInformation: Instance of 'HomePath'
++++++++++++
Error: Navigator.onGenerateRoute was null, but the route named "/home" was referenced.
To use the Navigator API with named routes (pushNamed, pushReplacementNamed, or pushNamedAndRemoveUntil), the Navigator must be provided with an onGenerateRoute handler.
The Navigator was:
  NavigatorState#124f0(tickers: tracking 2 tickers)
    at Object.throw_ [as throw] (http://localhost:53614/dart_sdk.js:4348:11)
    at http://localhost:53614/packages/flutter/src/widgets/widget_span.dart.lib.js:22796:21
    at navigator$.NavigatorState.new.[_routeNamed] (http://localhost:53614/packages/flutter/src/widgets/widget_span.dart.lib.js:22799:23)
    at navigator$.NavigatorState.new.pushReplacementNamed (http://localhost:53614/packages/flutter/src/widgets/widget_span.dart.lib.js:22838:74)
    at Function.pushReplacementNamed (http://localhost:53614/packages/flutter/src/widgets/widget_span.dart.lib.js:21050:63)
    at http://localhost:53614/packages/acs_upb_mobile/pages/settings/view/settings_page.dart.lib.js:4884:39
    at Generator.next (<anonymous>)
    at http://localhost:53614/dart_sdk.js:37956:33
    at _RootZone.runUnary (http://localhost:53614/dart_sdk.js:37810:58)
    at _FutureListener.thenAwait.handleValue (http://localhost:53614/dart_sdk.js:32771:29)
    at handleValueCallback (http://localhost:53614/dart_sdk.js:33319:49)
    at Function._propagateToListeners (http://localhost:53614/dart_sdk.js:33357:17)
    at _Future.new.[_completeWithValue] (http://localhost:53614/dart_sdk.js:33199:23)
    at async._AsyncCallbackEntry.new.callback (http://localhost:53614/dart_sdk.js:33222:35)
    at Object._microtaskLoop (http://localhost:53614/dart_sdk.js:38071:13)
    at _startMicrotaskLoop (http://localhost:53614/dart_sdk.js:38077:13)
    at http://localhost:53614/dart_sdk.js:33574:9
RazvanRotaru commented 3 years ago

Getting this exception when redirected to home page after authentication:

++++++++++++
restoreRouteInformation: Instance of 'HomePath'
++++++++++++
Error: Navigator.onGenerateRoute was null, but the route named "/home" was referenced.
To use the Navigator API with named routes (pushNamed, pushReplacementNamed, or pushNamedAndRemoveUntil), the Navigator must be provided with an onGenerateRoute handler.
The Navigator was:
  NavigatorState#124f0(tickers: tracking 2 tickers)
    at Object.throw_ [as throw] (http://localhost:53614/dart_sdk.js:4348:11)
    at http://localhost:53614/packages/flutter/src/widgets/widget_span.dart.lib.js:22796:21
    at navigator$.NavigatorState.new.[_routeNamed] (http://localhost:53614/packages/flutter/src/widgets/widget_span.dart.lib.js:22799:23)
    at navigator$.NavigatorState.new.pushReplacementNamed (http://localhost:53614/packages/flutter/src/widgets/widget_span.dart.lib.js:22838:74)
    at Function.pushReplacementNamed (http://localhost:53614/packages/flutter/src/widgets/widget_span.dart.lib.js:21050:63)
    at http://localhost:53614/packages/acs_upb_mobile/pages/settings/view/settings_page.dart.lib.js:4884:39
    at Generator.next (<anonymous>)
    at http://localhost:53614/dart_sdk.js:37956:33
    at _RootZone.runUnary (http://localhost:53614/dart_sdk.js:37810:58)
    at _FutureListener.thenAwait.handleValue (http://localhost:53614/dart_sdk.js:32771:29)
    at handleValueCallback (http://localhost:53614/dart_sdk.js:33319:49)
    at Function._propagateToListeners (http://localhost:53614/dart_sdk.js:33357:17)
    at _Future.new.[_completeWithValue] (http://localhost:53614/dart_sdk.js:33199:23)
    at async._AsyncCallbackEntry.new.callback (http://localhost:53614/dart_sdk.js:33222:35)
    at Object._microtaskLoop (http://localhost:53614/dart_sdk.js:38071:13)
    at _startMicrotaskLoop (http://localhost:53614/dart_sdk.js:38077:13)
    at http://localhost:53614/dart_sdk.js:33574:9

This is odd because Navigator.onGenerateRoute should not be called and also the tests passed. I double checked it in a clean project. It should work. Did you run pub get?

vladtf commented 3 years ago

This is odd because Navigator.onGenerateRoute should not be called and also the tests passed. I double checked it in a clean project. It should work. Did you run pub get?

Tested on wrong branch. My bad. Didn't notice this exception on web/layout/refined_navigation.