FilledStacks / flutter-tutorials

The repo contains the source code for all the tutorials on the FilledStacks Youtube channel.
MIT License
4.75k stars 1.76k forks source link

Navigation Service and null safety #136

Closed JavierPerezLavadie closed 3 years ago

JavierPerezLavadie commented 3 years ago

Hey hello I appreciate your videos thanks for that.

I currently have a problem with the navigation service and null safety security. Can you tell me how I can make this tutorial code compatible with non-null security? Thank you.

Can you also tell me how to add animations to the routes generated in this way?

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

class NavigationService {
  GlobalKey<NavigatorState> _navigationKey = GlobalKey<NavigatorState>();

  GlobalKey<NavigatorState> get navigationKey => _navigationKey;

  void pop() {
    return _navigationKey.currentState.pop();
  }

  Future<dynamic> navigateTo(String? routeName, {dynamic arguments}) {
    return _navigationKey.currentState
        .pushNamed(routeName, arguments: arguments);
  }
} 

Thanks a lot for your help

fairlycasual commented 3 years ago

Combining the base architecture with the other navigation tutorial found here solved this issue for me.