Repository: flutter
Issue: [AppLifecycleListener] 'System.exitApplication' always returns null
Labels: platform-android,framework,has reproducible steps,P2,team-framework,triaged-framework,found in release: 3.16,found in release: 3.19

### Steps to reproduce

I was just testing [this](https://api.flutter.dev/flutter/widgets/AppLifecycleListener-class.html#:~:text=This%20example%20shows%20how%20an%20application%20can%20optionally%20decide%20to%20abort%20a%20request%20for%20exiting%20instead%20of%20obeying%20the%20request.) example provided by the docs and realized that it wasn't working on the browser, so I created a local sample (using flutter create --sample=widgets.AppLifecycleListener.2 mysample) and tried on a AVD and a physical device, but it also didn't work. When I started debugging I saw that the `await SystemChannels.platform.invokeMethod<Map<String, Object?>>(
      'System.exitApplication',
      <String, Object?>{'type': exitType.name, 'exitCode': exitCode},
    );` was always returning null, therefore the exit is not being called neither the onExitRequested from AppLifecycleListener

### Expected results

I need this to work in order to know when the user is trying to close the app, so I can log from which page he left

### Actual results

I'm not able to close the app using the way provided by the doc's example

### Code sample

<details open><summary>Code sample</summary>

```dart
import 'dart:ui';

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

/// Flutter code sample for [AppLifecycleListener].

void main() {
  runApp(const AppLifecycleListenerExample());
}

class AppLifecycleListenerExample extends StatelessWidget {
  const AppLifecycleListenerExample({super.key});

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      home: Scaffold(body: ApplicationExitControl()),
    );
  }
}

class ApplicationExitControl extends StatefulWidget {
  const ApplicationExitControl({super.key});

  @override
  State<ApplicationExitControl> createState() => _ApplicationExitControlState();
}

class _ApplicationExitControlState extends State<ApplicationExitControl> {
  late final AppLifecycleListener _listener;
  bool _shouldExit = false;
  String _lastExitResponse = 'No exit requested yet';

  @override
  void initState() {
    super.initState();
    _listener = AppLifecycleListener(
      onExitRequested: _handleExitRequest,
    );
  }

  @override
  void dispose() {
    _listener.dispose();
    super.dispose();
  }

  Future<void> _quit() async {
    final AppExitType exitType = _shouldExit ? AppExitType.required : AppExitType.cancelable;
    await ServicesBinding.instance.exitApplication(exitType, 1);
  }

  Future<AppExitResponse> _handleExitRequest() async {
    final AppExitResponse response = _shouldExit ? AppExitResponse.exit : AppExitResponse.cancel;
    setState(() {
      _lastExitResponse = 'App responded ${response.name} to exit request';
    });
    return response;
  }

  void _radioChanged(bool? value) {
    value ??= true;
    if (_shouldExit == value) {
      return;
    }
    setState(() {
      _shouldExit = value!;
    });
  }

  @override
  Widget build(BuildContext context) {
    return Center(
      child: SizedBox(
        width: 300,
        child: Column(
          mainAxisSize: MainAxisSize.min,
          children: <Widget>[
            RadioListTile<bool>(
              title: const Text('Do Not Allow Exit'),
              groupValue: _shouldExit,
              value: false,
              onChanged: _radioChanged,
            ),
            RadioListTile<bool>(
              title: const Text('Allow Exit'),
              groupValue: _shouldExit,
              value: true,
              onChanged: _radioChanged,
            ),
            const SizedBox(height: 30),
            ElevatedButton(
              onPressed: _quit,
              child: const Text('Quit'),
            ),
            const SizedBox(height: 30),
            Text('Exit Request: $_lastExitResponse'),
          ],
        ),
      ),
    );
  }
}
```

</details>


### Screenshots or Video

<details open>
<summary>Screenshots / Video demonstration</summary>

![Captura de tela 2024-01-09 145940](https://github.com/flutter/flutter/assets/101265005/3355542e-7871-4026-99df-dc83b5abbcce)

![video](https://github.com/flutter/flutter/assets/101265005/98142985-63d3-434c-aac3-83cae5e2cf09)

</details>


### Logs

<details open><summary>Logs</summary>

```console
[Paste your logs here]
```

</details>


### Flutter Doctor output

<details open><summary>Doctor output</summary>

```console
 [√] Flutter (Channel stable, 3.16.5, on Microsoft Windows [versÆo 10.0.19045.3803], locale pt-BR)
    • Flutter version 3.16.5 on channel stable at D:\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 78666c8dc5 (3 weeks ago), 2023-12-19 16:14:14 -0800
    • Engine revision 3f3e560236
    • Dart version 3.2.3
    • DevTools version 2.28.4

[√] Windows Version (Installed version of Windows is version 10 or higher)

[√] Android toolchain - develop for Android devices (Android SDK version 34.0.0-rc4)
    • Android SDK at C:\Users\user\AppData\Local\Android\Sdk
    • Platform android-34, build-tools 34.0.0-rc4
    • Java binary at: C:\Program Files\Android\Android Studio\jbr\bin\java
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-b2043.56-9586694)
    • All Android licenses accepted.

[√] Chrome - develop for the web
    • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[X] Visual Studio - develop Windows apps
    X Visual Studio not installed; this is necessary to develop Windows apps.
      Download at https://visualstudio.microsoft.com/downloads/.
      Please install the "Desktop development with C++" workload, including all of its default components

[√] Android Studio (version 2022.2)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-b2043.56-9586694)

[√] VS Code (version 1.85.1)
    • VS Code at C:\Users\user\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.80.0

[√] Connected device (4 available)
    • sdk gphone x86 (mobile) • emulator-5554 • android-x86    • Android 11 (API 30) (emulator)
    • Windows (desktop)       • windows       • windows-x64    • Microsoft Windows [versÆo 10.0.19045.3803]
    • Chrome (web)            • chrome        • web-javascript • Google Chrome 120.0.6099.200
    • Edge (web)              • edge          • web-javascript • Microsoft Edge 120.0.2210.121

[√] Network resources
    • All expected network resources are available.

! Doctor found issues in 1 category.
```

</details>