Repository: flutter
Issue: [flutter_camera] CameraPreview black screen after reinitialising CameraController (switch Cameras)
Labels: platform-ios,p: camera,package,has reproducible steps,P2,found in release: 2.2,team-ios,triaged-ios

<!-- Thank you for using Flutter!

     If you are looking for support, please check out our documentation
     or consider asking a question on Stack Overflow:
      * https://flutter.dev/
      * https://api.flutter.dev/
      * https://stackoverflow.com/questions/tagged/flutter?sort=frequent

     If you have found a bug or if our documentation doesn't have an answer
     to what you're looking for, then fill out the template below. Please read
     our guide to filing a bug first: https://flutter.dev/docs/resources/bug-reports
-->

## Steps to Reproduce

Add the following Widget to a Flutter App and install flutter_camera

    class CameraSwitchTest extends StatefulWidget {
      CameraSwitchTest({Key? key}) : super(key: key);

      @override
      _CameraSwitchTestState createState() => _CameraSwitchTestState();
    }

    class _CameraSwitchTestState extends State<CameraSwitchTest> {
      CameraController? controller;
      bool frontCamera = false;

      List<CameraDescription>? cameras;

      @override
      void initState() {
        initCamera();
        super.initState();
      }

      initCamera() async {
        if (cameras == null) {
          cameras = await availableCameras();
        }

        if (controller?.value.isInitialized ?? false) {
          controller!.dispose();
        }
        controller = CameraController(
            cameras!.firstWhere(
              (element) => element.lensDirection == (frontCamera ? CameraLensDirection.front : CameraLensDirection.back),
            ),
            ResolutionPreset.medium,
            enableAudio: false);
        controller!.initialize().then((value) {
          setState(() {});
        });
      }

      @override
      Widget build(BuildContext context) {
        return Scaffold(
          appBar: AppBar(title: Text("Camera Test")),
          body: Column(
            children: [
              if (controller != null)
                Container(
                  child: CameraPreview(controller!),
                  height: 400,
                ),
              Row(
                children: [
                  ElevatedButton(
                    onPressed: () {
                      frontCamera = !frontCamera;
                      initCamera();
                    },
                    child: Text("Switch"),
                  ),
                ],
              ),
            ],
          ),
        );
      }
    }



**Expected results:** <!-- what did you want to see? -->

On "Switch" Button pressed, the `initCamera` method is called, updates the state and the the CameraPreview is rendered on screen showing the camera preview.

**Actual results:** <!-- what did you see? -->

When calling `initCamera` from inside the initState method, the CameraController is initialised and the CameraPreview is rendered on the screen. However when the `initCamera` method is called a second time from the "Switch" Buttom, the CameraPreview is rebuild but shows only a black screen and not the actual camera preview. No Errors or helpful logs appear in the console

<details>
  <summary>Logs</summary>

<!--
      Run your application with `flutter run --verbose` and attach all the
      log output below between the lines with the backticks. If there is an
      exception, please see if the error message includes enough information
      to explain how to solve the issue.
-->

```
```

<!--
     Run `flutter analyze` and attach any output of that command below.
     If there are any analysis errors, try resolving them before filing this issue.
-->

```
```

<!-- Finally, paste the output of running `flutter doctor -v` here. -->

```
[✓] Flutter (Channel stable, 2.2.1, on macOS 11.4 20F71 darwin-x64, locale en-DE)
    • Flutter version 2.2.1 at /Users/jonas/flutter
    • Framework revision 02c026b03c (5 weeks ago), 2021-05-27 12:24:44 -0700
    • Engine revision 0fdb562ac8
    • Dart version 2.13.1

[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
    • Android SDK at /Users/jonas/Library/Android/sdk
    • Platform android-30, build-tools 29.0.3
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b4-5784211)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 12.5, Build version 12E262
    • CocoaPods version 1.10.1

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 3.6)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 45.1.1
    • Dart plugin version 192.7761
    • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b4-5784211)

[✓] VS Code (version 1.57.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.23.0

[✓] Connected device (2 available)
    • iPhone 12 Pro Max (mobile) • AA7498B9-DC82-4A9F-9CE0-8E9693749661 • ios            • com.apple.CoreSimulator.SimRuntime.iOS-14-5 (simulator)
    • Chrome (web)               • chrome                               • web-javascript • Google Chrome 91.0.4472.114

• No issues found!
```

</details>