Repository: flutter
Issue: AppLifecycleListener doesn't report initial change detached -> resumed
Labels: platform-android,framework,has reproducible steps,P2,team-framework,triaged-framework,found in release: 3.13,found in release: 3.14

### Is there an existing issue for this?

- [X] I have searched the [existing issues](https://github.com/flutter/flutter/issues)
- [X] I have read the [guide to filing a bug](https://flutter.dev/docs/resources/bug-reports)

### Steps to reproduce

Testing on an Android device and iOS simulator, with the same results.

1. Copy the code sample and start the app.

I think that this is because the listener is attached too late, after the initial transition? Is there a way to make it work?
If there is no way, how about mentioning the fact that the initial transition is not 'discoverable' by the app in the documentation?

### Expected results

From the docs https://api.flutter.dev/flutter/widgets/AppLifecycleListener-class.html I understand that the app starts in the `detached` state and transits to `resumed`. However, my sample code doesn't show the expected output.

After the app is started, when sent to the background and back to the foreground, the expected output is printed.

### Actual results

The initial state change `detached` -> `resumed` is also reported to the app.

### Code sample

<details><summary>Code sample</summary>

```dart
import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatefulWidget {
  const MyApp();

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  late AppLifecycleListener _lifecycleListener;

  @override
  void initState() {
    super.initState();

    _lifecycleListener = AppLifecycleListener(
      onStateChange: (value) {
        print('<<>> $value');
      },
      onResume: () {
        print('<<>> RESUMED');
      },
    );
  }

  @override
  void dispose() {
    super.dispose();

    _lifecycleListener.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return const ColoredBox(color: Colors.pink);
  }
}
```

</details>


### Screenshots or Video

<details>
<summary>Screenshots / Video demonstration</summary>

[Upload media here]

</details>


### Flutter Doctor output

<details><summary>Doctor output</summary>

```console
$ flutter doctor -v
[✓] Flutter (Channel stable, 3.13.3, on macOS 13.5.2 22G91 darwin-arm64, locale en-DE)
    • Flutter version 3.13.3 on channel stable at /Users/rswierzy/fvm/versions/3.13.3
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 2524052335 (8 days ago), 2023-09-06 14:32:31 -0700
    • Engine revision b8d35810e9
    • Dart version 3.1.1
    • DevTools version 2.25.0

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
    • Android SDK at /Users/rswierzy/Library/Android/sdk
    • Platform android-33, build-tools 33.0.2
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b829.9-10027231)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 14.3.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 14E300c
    • CocoaPods version 1.12.1

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2022.3)
    • Android Studio at /Applications/Android Studio.app/Contents
    • 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-17.0.6b829.9-10027231)

[✓] VS Code (version 1.82.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.72.0

[✓] Connected device (4 available)
    • SM S908B (mobile)      • R3CTB08NJTT                          • android-arm64  • Android 13 (API 33)
    • iPhone 14 Pro (mobile) • 867A3146-F1F8-44BF-A0C9-292A02EB9F27 • ios            • com.apple.CoreSimulator.SimRuntime.iOS-16-4 (simulator)
    • macOS (desktop)        • macos                                • darwin-arm64   • macOS 13.5.2 22G91 darwin-arm64
    • Chrome (web)           • chrome                               • web-javascript • Google Chrome 117.0.5938.62

[✓] Network resources
    • All expected network resources are available.

• No issues found!
```

</details>