Repository: flutter
Issue: Render widgets based on AppLifeCycleState is not working on Android 
Labels: platform-android,framework,engine,has reproducible steps,P3,found in release: 2.0,found in release: 2.1,team-android,triaged-android

> This issue is copied from #33236 which was open (and has been fixed, it seems) specifically for iOS but the same issue is also happening on Android.

I have a simple application using `WidgetsBindingObserver` to detect the changes to `AppLifeCycleState`.
The expected behavior is to replace a child widget when the app goes to inactive or paused state (`red` vs `greenAccent` background)

<details>
<summary><strong>Source code</strong></summary>

```dart
import 'package:flutter/material.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: Scaffold(
        body: SecureScreen(
          child: Container(
            color: Colors.red,
          ),
        ),
      ),
    );
  }
}

class SecureScreen extends StatefulWidget {
  final Widget child;
  SecureScreen({@required this.child});

  @override
  SecureScreenState createState() => SecureScreenState();
}

class SecureScreenState extends State<SecureScreen>
    with WidgetsBindingObserver {
  AppLifecycleState _notification;

  @override
  void initState() {
    super.initState();
    WidgetsBinding.instance.addObserver(this);
  }

  @override
  void dispose() {
    WidgetsBinding.instance.removeObserver(this);
    super.dispose();
  }

  @override
  void didChangeAppLifecycleState(AppLifecycleState state) {
    print(state.toString());
    setState(() {
      _notification = state;
    });
  }

  @override
  Widget build(BuildContext context) {
    return (_notification == AppLifecycleState.paused ||
            _notification == AppLifecycleState.inactive)
        ? Container(
            color: Colors.greenAccent,
          )
        : widget.child;
  }
}
```


</details>

So when I click the home button to view all the open applications, it is triggering "inactive" state but it is not calling the `build()` method to render the container with the `greenAccent` color and the one with the `red` one stays on.

<details>
<summary>Screenshot on a Pixel 5 device</summary>
<img src="https://user-images.githubusercontent.com/19540101/114576148-29bb8e00-9c7b-11eb-8ea7-db78a703ff26.png"></img>
</details>



<details>
<summary>flutter doctor -v</summary>

```bash
[✓] Flutter (Channel stable, 2.0.4, on Linux, locale fr_FR.UTF-8)
    • Flutter version 2.0.4 at /home/***/snap/flutter/common/flutter
    • Framework revision b1395592de (il y a 12 jours), 2021-04-01 14:25:01 -0700
    • Engine revision 2dce47073a
    • Dart version 2.12.2

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
    • Android SDK at /home/***/Android/Sdk
    • Platform android-30, build-tools 30.0.2
    • Java binary at: /home/***/android-studio/jre/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)
    • All Android licenses accepted.

[✓] Chrome - develop for the web
    • Chrome at google-chrome

[✓] Linux toolchain - develop for Linux desktop
    • clang version 10.0.0-4ubuntu1
    • cmake version 3.16.3
    • ninja version 1.10.0
    • pkg-config version 0.29.1

[✓] Android Studio
    • Android Studio at /home/***/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 1.8.0_242-release-1644-b3-6222593)

[✓] VS Code (version 1.55.1)
    • VS Code at /usr/share/code
    • Flutter extension version 3.21.0

[✓] Connected device (3 available)
    • Pixel 5 (mobile) • android-arm64  • Android 11 (API 30)
    • Linux (desktop)  • linux             • linux-x64      • Linux
    • Chrome (web)     • chrome            • web-javascript • Google Chrome 89.0.4389.114

• No issues found!
```

</details>