Pete
0
Q:

A value of type 'void' can't be returned from method 'goBack' because it has a return type of 'bool'.

AssetNotFoundException: the_basics|lib/services/navigation_service.ddc.js
Error compiling dartdevc module:the_basics|lib/services/navigation_service.ddc.js

packages/the_basics/services/navigation_service.dart:12:38: Error: This expression has type 'void' and
can't be used.
    return navigatorKey.currentState.pop();

/*
	 Code that this error is based on.
import 'package:flutter/material.dart';

class NavigationService {
  final GlobalKey<NavigatorState> navigatorKey =
      GlobalKey<NavigatorState>();

  Future<dynamic> navigateTo(String routeName) {
    return navigatorKey.currentState.pushNamed(routeName);
  }

  bool goBack() {
    return navigatorKey.currentState.pop();
  }
}
*/
Answer is by changing the goBack() to return void, and remove the 'return' operator
0

New to Communities?

Join the community