title: Flutter A value of type 'Future<dynamic>' can't be returned from the method '_onBackPress' because it has a return type of 'Future<bool>'
body: <p><strong>i am working on back button in my app but i face this issue in flutter</strong>
  Thank so much in advanced
  i am doing this before with this function but now it's not working
  i think because of null safty
  sorry for my bad english
  <a href="https://i.stack.imgur.com/o9Ptu.png" rel="nofollow noreferrer">screenshot</a></p>
  <p>here is my flutter doctor</p>
  <pre><code>Doctor summary (to see all details, run flutter doctor -v):
  [√] Flutter (Channel stable, 2.2.3, on Microsoft Windows [Version 10.0.19043.1110], locale en-US)
  [√] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
  [√] Chrome - develop for the web
  [√] Android Studio (version 4.1.0)
  [√] VS Code (version 1.58.2)
  [√] Connected device (3 available)
  
  • No issues found!
  </code></pre>
  <p>here is my build method and Future function</p>
  <pre><code>Future&lt;bool&gt; _onBackPress() {
      return showDialog(
        context: context,
        builder: (BuildContext context) {
          return AlertDialog(
            content: Text('Exit From The App'),
            actions: [
              TextButton(
                onPressed: () {
                  Navigator.of(context).pop(false);
                },
                child: Text('No'),
              ),
              TextButton(
                onPressed: () {
                  Navigator.of(context).pop(true);
                },
                child: Text('Yes'),
              ),
            ],
          );
        },
      );
    }
  
    @override
    Widget build(BuildContext context) {
      return WillPopScope(
        onWillPop: _onBackPress,
        child: Scaffold(
          appBar: AppBar(
            automaticallyImplyLeading: false,
            brightness: Brightness.dark,
            title: Text('Internet Availability Checker'),
          ),
        ),
      );
    }
  </code></pre>