An async function or method in ES5/ES3 requires the 'Promise' constructor. code example

Example: 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 navigatorKey =
      GlobalKey();

  Future 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

Tags:

Misc Example