<p dir="auto">A few Days Ago, everything was fine but recently I'm starting facing to get Flutter Packages. Please have a look and help me out. Optional =&gt; I'm not from China</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Creating project test_run...
  test_run\.gitignore (created)
  test_run\.idea\libraries\Dart_SDK.xml (created)
  test_run\.idea\libraries\Flutter_for_Android.xml (created)
  test_run\.idea\libraries\KotlinJavaRuntime.xml (created)
  test_run\.idea\modules.xml (created)
  test_run\.idea\runConfigurations\main_dart.xml (created)
  test_run\.idea\workspace.xml (created)
  test_run\.metadata (created)
  test_run\android\app\build.gradle (created)
  test_run\android\app\src\main\java\com\example\testrun\MainActivity.java (created)
  test_run\android\build.gradle (created)
  test_run\android\test_run_android.iml (created)
  test_run\android\app\src\main\AndroidManifest.xml (created)
  test_run\android\app\src\main\res\drawable\launch_background.xml (created)
  test_run\android\app\src\main\res\mipmap-hdpi\ic_launcher.png (created)
  test_run\android\app\src\main\res\mipmap-mdpi\ic_launcher.png (created)
  test_run\android\app\src\main\res\mipmap-xhdpi\ic_launcher.png (created)
  test_run\android\app\src\main\res\mipmap-xxhdpi\ic_launcher.png (created)
  test_run\android\app\src\main\res\mipmap-xxxhdpi\ic_launcher.png (created)
  test_run\android\app\src\main\res\values\styles.xml (created)
  test_run\android\gradle\wrapper\gradle-wrapper.properties (created)
  test_run\android\gradle.properties (created)
  test_run\android\settings.gradle (created)
  test_run\ios\Runner\AppDelegate.h (created)
  test_run\ios\Runner\AppDelegate.m (created)
  test_run\ios\Runner\main.m (created)
  test_run\ios\Runner.xcodeproj\project.pbxproj (created)
  test_run\ios\Runner.xcodeproj\xcshareddata\xcschemes\Runner.xcscheme (created)
  test_run\ios\Flutter\AppFrameworkInfo.plist (created)
  test_run\ios\Flutter\Debug.xcconfig (created)
  test_run\ios\Flutter\Release.xcconfig (created)
  test_run\ios\Runner\Assets.xcassets\AppIcon.appiconset\Contents.json (created)
  test_run\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-1024x1024@1x.png (created)
  test_run\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-20x20@1x.png (created)
  test_run\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-20x20@2x.png (created)
  test_run\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-20x20@3x.png (created)
  test_run\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-29x29@1x.png (created)
  test_run\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-29x29@2x.png (created)
  test_run\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-29x29@3x.png (created)
  test_run\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-40x40@1x.png (created)
  test_run\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-40x40@2x.png (created)
  test_run\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-40x40@3x.png (created)
  test_run\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-60x60@2x.png (created)
  test_run\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-60x60@3x.png (created)
  test_run\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-76x76@1x.png (created)
  test_run\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-76x76@2x.png (created)
  test_run\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-83.5x83.5@2x.png (created)
  test_run\ios\Runner\Assets.xcassets\LaunchImage.imageset\Contents.json (created)
  test_run\ios\Runner\Assets.xcassets\LaunchImage.imageset\LaunchImage.png (created)
  test_run\ios\Runner\Assets.xcassets\LaunchImage.imageset\LaunchImage@2x.png (created)
  test_run\ios\Runner\Assets.xcassets\LaunchImage.imageset\LaunchImage@3x.png (created)
  test_run\ios\Runner\Assets.xcassets\LaunchImage.imageset\README.md (created)
  test_run\ios\Runner\Base.lproj\LaunchScreen.storyboard (created)
  test_run\ios\Runner\Base.lproj\Main.storyboard (created)
  test_run\ios\Runner\Info.plist (created)
  test_run\ios\Runner.xcodeproj\project.xcworkspace\contents.xcworkspacedata (created)
  test_run\ios\Runner.xcworkspace\contents.xcworkspacedata (created)
  test_run\lib\main.dart (created)
  test_run\test_run.iml (created)
  test_run\pubspec.yaml (created)
  test_run\README.md (created)
  test_run\test\widget_test.dart (created)
_Running &quot;flutter packages get&quot; in test_run...
Got socket error trying to find package cupertino_icons at https://pub.dartlang.org.
pub get failed (69) -- attempting retry 1 in 1 second..._"><pre class="notranslate"><code class="notranslate">Creating project test_run...
  test_run\.gitignore (created)
  test_run\.idea\libraries\Dart_SDK.xml (created)
  test_run\.idea\libraries\Flutter_for_Android.xml (created)
  test_run\.idea\libraries\KotlinJavaRuntime.xml (created)
  test_run\.idea\modules.xml (created)
  test_run\.idea\runConfigurations\main_dart.xml (created)
  test_run\.idea\workspace.xml (created)
  test_run\.metadata (created)
  test_run\android\app\build.gradle (created)
  test_run\android\app\src\main\java\com\example\testrun\MainActivity.java (created)
  test_run\android\build.gradle (created)
  test_run\android\test_run_android.iml (created)
  test_run\android\app\src\main\AndroidManifest.xml (created)
  test_run\android\app\src\main\res\drawable\launch_background.xml (created)
  test_run\android\app\src\main\res\mipmap-hdpi\ic_launcher.png (created)
  test_run\android\app\src\main\res\mipmap-mdpi\ic_launcher.png (created)
  test_run\android\app\src\main\res\mipmap-xhdpi\ic_launcher.png (created)
  test_run\android\app\src\main\res\mipmap-xxhdpi\ic_launcher.png (created)
  test_run\android\app\src\main\res\mipmap-xxxhdpi\ic_launcher.png (created)
  test_run\android\app\src\main\res\values\styles.xml (created)
  test_run\android\gradle\wrapper\gradle-wrapper.properties (created)
  test_run\android\gradle.properties (created)
  test_run\android\settings.gradle (created)
  test_run\ios\Runner\AppDelegate.h (created)
  test_run\ios\Runner\AppDelegate.m (created)
  test_run\ios\Runner\main.m (created)
  test_run\ios\Runner.xcodeproj\project.pbxproj (created)
  test_run\ios\Runner.xcodeproj\xcshareddata\xcschemes\Runner.xcscheme (created)
  test_run\ios\Flutter\AppFrameworkInfo.plist (created)
  test_run\ios\Flutter\Debug.xcconfig (created)
  test_run\ios\Flutter\Release.xcconfig (created)
  test_run\ios\Runner\Assets.xcassets\AppIcon.appiconset\Contents.json (created)
  test_run\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-1024x1024@1x.png (created)
  test_run\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-20x20@1x.png (created)
  test_run\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-20x20@2x.png (created)
  test_run\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-20x20@3x.png (created)
  test_run\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-29x29@1x.png (created)
  test_run\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-29x29@2x.png (created)
  test_run\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-29x29@3x.png (created)
  test_run\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-40x40@1x.png (created)
  test_run\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-40x40@2x.png (created)
  test_run\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-40x40@3x.png (created)
  test_run\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-60x60@2x.png (created)
  test_run\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-60x60@3x.png (created)
  test_run\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-76x76@1x.png (created)
  test_run\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-76x76@2x.png (created)
  test_run\ios\Runner\Assets.xcassets\AppIcon.appiconset\Icon-App-83.5x83.5@2x.png (created)
  test_run\ios\Runner\Assets.xcassets\LaunchImage.imageset\Contents.json (created)
  test_run\ios\Runner\Assets.xcassets\LaunchImage.imageset\LaunchImage.png (created)
  test_run\ios\Runner\Assets.xcassets\LaunchImage.imageset\LaunchImage@2x.png (created)
  test_run\ios\Runner\Assets.xcassets\LaunchImage.imageset\LaunchImage@3x.png (created)
  test_run\ios\Runner\Assets.xcassets\LaunchImage.imageset\README.md (created)
  test_run\ios\Runner\Base.lproj\LaunchScreen.storyboard (created)
  test_run\ios\Runner\Base.lproj\Main.storyboard (created)
  test_run\ios\Runner\Info.plist (created)
  test_run\ios\Runner.xcodeproj\project.xcworkspace\contents.xcworkspacedata (created)
  test_run\ios\Runner.xcworkspace\contents.xcworkspacedata (created)
  test_run\lib\main.dart (created)
  test_run\test_run.iml (created)
  test_run\pubspec.yaml (created)
  test_run\README.md (created)
  test_run\test\widget_test.dart (created)
_Running "flutter packages get" in test_run...
Got socket error trying to find package cupertino_icons at https://pub.dartlang.org.
pub get failed (69) -- attempting retry 1 in 1 second..._
</code></pre></div>
<h2 dir="auto">Problem</h2>
<p dir="auto">The Camera Preview doesn't load on my iPhone Xs, or my iPhone 8 Plus, when I'm using the <code class="notranslate">ResolutionPreset.high</code> setting. There is some weird functionality even when I tried running the sample app where it would stop working half the time and then start working if I either re checked out the code base, or if I messed around with the bundle identifier. Even when the camera preview isn't working the phone will still take pictures properly using this resolution, and it works fine for the most part on Android. (Samsung devices are buggy, but that's another problem). Medium and low resolutions work properly. It works fine on my iPhone 6s. I have a feeling it has something to do with the dual camera setup of the newer phones. All the log information below is from the iPhone Xs</p>
<h2 dir="auto">Code</h2>
<div class="highlight highlight-source-dart notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import 'dart:io';

import 'package:camera/camera.dart';
import 'package:flutter/material.dart';
import 'package:flutter_login/image_viewer.dart';
import 'package:path_provider/path_provider.dart';
import 'package:flutter/painting.dart';
import 'package:device_info/device_info.dart';

class CloudVisionPage extends StatefulWidget {
  static String tag = 'cloud-vision-page';

  @override
  _CloudVisionPageState createState() =&gt; _CloudVisionPageState();
}

class _CloudVisionPageState extends State&lt;CloudVisionPage&gt; {
  CameraController controller;
  List&lt;CameraDescription&gt; _cameras;
  bool _isReady = false;
  final GlobalKey&lt;ScaffoldState&gt; _scaffoldKey = GlobalKey&lt;ScaffoldState&gt;();

  @override
  void initState() {
    super.initState();
    _setUpCamera();
  }

  void _setUpCamera() async {
    try {
      // initialize cameras.
      _cameras = await availableCameras();
      // initialize camera controllers.
      // Current bug for high / medium with samsung devices.
      if (Platform.isAndroid) {
        DeviceInfoPlugin deviceInfo = DeviceInfoPlugin();
        AndroidDeviceInfo androidDeviceInfo = await deviceInfo.androidInfo;
        if (androidDeviceInfo.manufacturer.toLowerCase() == &quot;samsung&quot;) {
          controller = CameraController(_cameras[0], ResolutionPreset.low);
        } else {
          controller = CameraController(_cameras[0], ResolutionPreset.high);
        }
      } else {
        controller = CameraController(_cameras[0], ResolutionPreset.high);
      }

      await controller.initialize();
    } on CameraException catch (_) {
      // do something on error.
    }
    if (!mounted) return;
    setState(() {
      _isReady = true;
    });
  }

  @override
  void dispose() {
    controller?.dispose();
    super.dispose();
  }

  Widget cameraPreview() {
    return AspectRatio(
        aspectRatio:
        controller.value.aspectRatio,
        child: CameraPreview(controller)
    );
  }

  Widget floatingButton() {
    return FloatingActionButton(
      backgroundColor: Colors.blue,
      onPressed: _onPictureButtonPressed,
      child: Icon(
        Icons.camera,
      ),
    );
  }

  void _onPictureButtonPressed() {
    _takePicture().then((String filePath) {
      if (mounted) {
        if (filePath != null) {
          Navigator.push(
            context,
            MaterialPageRoute(builder: (context) =&gt; ImagePage(filePath)),
          );
        }
      }
    });
  }

  void showInSnackBar(String message) {
    _scaffoldKey.currentState.showSnackBar(SnackBar(content: Text(message)));
  }

  String timestamp() =&gt; DateTime.now().millisecondsSinceEpoch.toString();

  Future&lt;String&gt; _takePicture() async {
    if (!controller.value.isInitialized) {
      return null;
    }
    // This is the private app directory.
    final Directory extDir = await getApplicationDocumentsDirectory();

    final String dirPath = '${extDir.path}/Pictures/flutter_test';
    await Directory(dirPath).create(recursive: true);
    final String filePath = '$dirPath/${&quot;test_image&quot;}.jpg';
    // Delete file to override image.
    File imageFile = File(filePath);
    if (imageFile.existsSync()) {
      imageFile.deleteSync(recursive: false);
    }

    // Must clear this because flutter caches the images behind the scenes.
    imageCache.clear();

    if (controller.value.isTakingPicture) {
      // A capture is already pending, do nothing.
      return null;
    }

    try {
      await controller.takePicture(filePath);
    } on CameraException catch (e) {
      _showCameraException(e);
      return null;
    }
    return filePath;
  }

  void _showCameraException(CameraException e) {
    logError(e.code, e.description);
    showInSnackBar('Error: ${e.code}\n${e.description}');
  }

  void logError(String code, String message) =&gt;
      print('Error: $code\nError Message: $message');

  @override
  Widget build(BuildContext context) {
    if (_isReady == false ||
        controller == null || !controller.value.isInitialized) {
      return Container();
    }
    return Scaffold(
      key: _scaffoldKey,
      body: SafeArea(
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.center,
          mainAxisAlignment: MainAxisAlignment.center,
          children: &lt;Widget&gt;[
            Center(
              child: cameraPreview(),
            ),
            SizedBox(height: 8.0,),
            floatingButton(),
          ],
        ),
      ),
    );
  }
}"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-s">'dart:io'</span>;

<span class="pl-k">import</span> <span class="pl-s">'package:camera/camera.dart'</span>;
<span class="pl-k">import</span> <span class="pl-s">'package:flutter/material.dart'</span>;
<span class="pl-k">import</span> <span class="pl-s">'package:flutter_login/image_viewer.dart'</span>;
<span class="pl-k">import</span> <span class="pl-s">'package:path_provider/path_provider.dart'</span>;
<span class="pl-k">import</span> <span class="pl-s">'package:flutter/painting.dart'</span>;
<span class="pl-k">import</span> <span class="pl-s">'package:device_info/device_info.dart'</span>;

<span class="pl-k">class</span> <span class="pl-c1">CloudVisionPage</span> <span class="pl-k">extends</span> <span class="pl-c1">StatefulWidget</span> {
  <span class="pl-k">static</span> <span class="pl-c1">String</span> tag <span class="pl-k">=</span> <span class="pl-s">'cloud-vision-page'</span>;

  <span class="pl-k">@override</span>
  <span class="pl-c1">_CloudVisionPageState</span> <span class="pl-en">createState</span>() <span class="pl-k">=&gt;</span> <span class="pl-c1">_CloudVisionPageState</span>();
}

<span class="pl-k">class</span> <span class="pl-c1">_CloudVisionPageState</span> <span class="pl-k">extends</span> <span class="pl-c1">State</span>&lt;<span class="pl-c1">CloudVisionPage</span>&gt; {
  <span class="pl-c1">CameraController</span> controller;
  <span class="pl-c1">List</span>&lt;<span class="pl-c1">CameraDescription</span>&gt; _cameras;
  <span class="pl-c1">bool</span> _isReady <span class="pl-k">=</span> <span class="pl-c1">false</span>;
  <span class="pl-k">final</span> <span class="pl-c1">GlobalKey</span>&lt;<span class="pl-c1">ScaffoldState</span>&gt; _scaffoldKey <span class="pl-k">=</span> <span class="pl-c1">GlobalKey</span>&lt;<span class="pl-c1">ScaffoldState</span>&gt;();

  <span class="pl-k">@override</span>
  <span class="pl-k">void</span> <span class="pl-en">initState</span>() {
    <span class="pl-c1">super</span>.<span class="pl-en">initState</span>();
    <span class="pl-en">_setUpCamera</span>();
  }

  <span class="pl-k">void</span> <span class="pl-en">_setUpCamera</span>() <span class="pl-k">async</span> {
    <span class="pl-k">try</span> {
      <span class="pl-c">// initialize cameras.</span>
      _cameras <span class="pl-k">=</span> <span class="pl-k">await</span> <span class="pl-en">availableCameras</span>();
      <span class="pl-c">// initialize camera controllers.</span>
      <span class="pl-c">// Current bug for high / medium with samsung devices.</span>
      <span class="pl-k">if</span> (<span class="pl-c1">Platform</span>.isAndroid) {
        <span class="pl-c1">DeviceInfoPlugin</span> deviceInfo <span class="pl-k">=</span> <span class="pl-c1">DeviceInfoPlugin</span>();
        <span class="pl-c1">AndroidDeviceInfo</span> androidDeviceInfo <span class="pl-k">=</span> <span class="pl-k">await</span> deviceInfo.androidInfo;
        <span class="pl-k">if</span> (androidDeviceInfo.manufacturer.<span class="pl-en">toLowerCase</span>() <span class="pl-k">==</span> <span class="pl-s">"samsung"</span>) {
          controller <span class="pl-k">=</span> <span class="pl-c1">CameraController</span>(_cameras[<span class="pl-c1">0</span>], <span class="pl-c1">ResolutionPreset</span>.low);
        } <span class="pl-k">else</span> {
          controller <span class="pl-k">=</span> <span class="pl-c1">CameraController</span>(_cameras[<span class="pl-c1">0</span>], <span class="pl-c1">ResolutionPreset</span>.high);
        }
      } <span class="pl-k">else</span> {
        controller <span class="pl-k">=</span> <span class="pl-c1">CameraController</span>(_cameras[<span class="pl-c1">0</span>], <span class="pl-c1">ResolutionPreset</span>.high);
      }

      <span class="pl-k">await</span> controller.<span class="pl-en">initialize</span>();
    } <span class="pl-k">on</span> <span class="pl-c1">CameraException</span> <span class="pl-k">catch</span> (_) {
      <span class="pl-c">// do something on error.</span>
    }
    <span class="pl-k">if</span> (<span class="pl-k">!</span>mounted) <span class="pl-k">return</span>;
    <span class="pl-en">setState</span>(() {
      _isReady <span class="pl-k">=</span> <span class="pl-c1">true</span>;
    });
  }

  <span class="pl-k">@override</span>
  <span class="pl-k">void</span> <span class="pl-en">dispose</span>() {
    controller<span class="pl-k">?</span>.<span class="pl-en">dispose</span>();
    <span class="pl-c1">super</span>.<span class="pl-en">dispose</span>();
  }

  <span class="pl-c1">Widget</span> <span class="pl-en">cameraPreview</span>() {
    <span class="pl-k">return</span> <span class="pl-c1">AspectRatio</span>(
        aspectRatio<span class="pl-k">:</span>
        controller.value.aspectRatio,
        child<span class="pl-k">:</span> <span class="pl-c1">CameraPreview</span>(controller)
    );
  }

  <span class="pl-c1">Widget</span> <span class="pl-en">floatingButton</span>() {
    <span class="pl-k">return</span> <span class="pl-c1">FloatingActionButton</span>(
      backgroundColor<span class="pl-k">:</span> <span class="pl-c1">Colors</span>.blue,
      onPressed<span class="pl-k">:</span> _onPictureButtonPressed,
      child<span class="pl-k">:</span> <span class="pl-c1">Icon</span>(
        <span class="pl-c1">Icons</span>.camera,
      ),
    );
  }

  <span class="pl-k">void</span> <span class="pl-en">_onPictureButtonPressed</span>() {
    <span class="pl-en">_takePicture</span>().<span class="pl-en">then</span>((<span class="pl-c1">String</span> filePath) {
      <span class="pl-k">if</span> (mounted) {
        <span class="pl-k">if</span> (filePath <span class="pl-k">!=</span> <span class="pl-c1">null</span>) {
          <span class="pl-c1">Navigator</span>.<span class="pl-en">push</span>(
            context,
            <span class="pl-c1">MaterialPageRoute</span>(builder<span class="pl-k">:</span> (context) <span class="pl-k">=&gt;</span> <span class="pl-c1">ImagePage</span>(filePath)),
          );
        }
      }
    });
  }

  <span class="pl-k">void</span> <span class="pl-en">showInSnackBar</span>(<span class="pl-c1">String</span> message) {
    _scaffoldKey.currentState.<span class="pl-en">showSnackBar</span>(<span class="pl-c1">SnackBar</span>(content<span class="pl-k">:</span> <span class="pl-c1">Text</span>(message)));
  }

  <span class="pl-c1">String</span> <span class="pl-en">timestamp</span>() <span class="pl-k">=&gt;</span> <span class="pl-c1">DateTime</span>.<span class="pl-en">now</span>().millisecondsSinceEpoch.<span class="pl-en">toString</span>();

  <span class="pl-c1">Future</span>&lt;<span class="pl-c1">String</span>&gt; <span class="pl-en">_takePicture</span>() <span class="pl-k">async</span> {
    <span class="pl-k">if</span> (<span class="pl-k">!</span>controller.value.isInitialized) {
      <span class="pl-k">return</span> <span class="pl-c1">null</span>;
    }
    <span class="pl-c">// This is the private app directory.</span>
    <span class="pl-k">final</span> <span class="pl-c1">Directory</span> extDir <span class="pl-k">=</span> <span class="pl-k">await</span> <span class="pl-en">getApplicationDocumentsDirectory</span>();

    <span class="pl-k">final</span> <span class="pl-c1">String</span> dirPath <span class="pl-k">=</span> <span class="pl-s">'<span class="pl-s">${<span class="pl-v">extDir</span>.<span class="pl-v">path</span>}</span>/Pictures/flutter_test'</span>;
    <span class="pl-k">await</span> <span class="pl-c1">Directory</span>(dirPath).<span class="pl-en">create</span>(recursive<span class="pl-k">:</span> <span class="pl-c1">true</span>);
    <span class="pl-k">final</span> <span class="pl-c1">String</span> filePath <span class="pl-k">=</span> <span class="pl-s">'$<span class="pl-v">dirPath</span>/<span class="pl-s">${<span class="pl-s">"test_image"</span>}</span>.jpg'</span>;
    <span class="pl-c">// Delete file to override image.</span>
    <span class="pl-c1">File</span> imageFile <span class="pl-k">=</span> <span class="pl-c1">File</span>(filePath);
    <span class="pl-k">if</span> (imageFile.<span class="pl-en">existsSync</span>()) {
      imageFile.<span class="pl-en">deleteSync</span>(recursive<span class="pl-k">:</span> <span class="pl-c1">false</span>);
    }

    <span class="pl-c">// Must clear this because flutter caches the images behind the scenes.</span>
    imageCache.<span class="pl-en">clear</span>();

    <span class="pl-k">if</span> (controller.value.isTakingPicture) {
      <span class="pl-c">// A capture is already pending, do nothing.</span>
      <span class="pl-k">return</span> <span class="pl-c1">null</span>;
    }

    <span class="pl-k">try</span> {
      <span class="pl-k">await</span> controller.<span class="pl-en">takePicture</span>(filePath);
    } <span class="pl-k">on</span> <span class="pl-c1">CameraException</span> <span class="pl-k">catch</span> (e) {
      <span class="pl-en">_showCameraException</span>(e);
      <span class="pl-k">return</span> <span class="pl-c1">null</span>;
    }
    <span class="pl-k">return</span> filePath;
  }

  <span class="pl-k">void</span> <span class="pl-en">_showCameraException</span>(<span class="pl-c1">CameraException</span> e) {
    <span class="pl-en">logError</span>(e.code, e.description);
    <span class="pl-en">showInSnackBar</span>(<span class="pl-s">'Error: <span class="pl-s">${<span class="pl-v">e</span>.<span class="pl-v">code</span>}</span><span class="pl-cce">\n</span><span class="pl-s">${<span class="pl-v">e</span>.<span class="pl-v">description</span>}</span>'</span>);
  }

  <span class="pl-k">void</span> <span class="pl-en">logError</span>(<span class="pl-c1">String</span> code, <span class="pl-c1">String</span> message) <span class="pl-k">=&gt;</span>
      <span class="pl-en">print</span>(<span class="pl-s">'Error: $<span class="pl-v">code</span><span class="pl-cce">\n</span>Error Message: $<span class="pl-v">message</span>'</span>);

  <span class="pl-k">@override</span>
  <span class="pl-c1">Widget</span> <span class="pl-en">build</span>(<span class="pl-c1">BuildContext</span> context) {
    <span class="pl-k">if</span> (_isReady <span class="pl-k">==</span> <span class="pl-c1">false</span> <span class="pl-k">||</span>
        controller <span class="pl-k">==</span> <span class="pl-c1">null</span> <span class="pl-k">||</span> <span class="pl-k">!</span>controller.value.isInitialized) {
      <span class="pl-k">return</span> <span class="pl-c1">Container</span>();
    }
    <span class="pl-k">return</span> <span class="pl-c1">Scaffold</span>(
      key<span class="pl-k">:</span> _scaffoldKey,
      body<span class="pl-k">:</span> <span class="pl-c1">SafeArea</span>(
        child<span class="pl-k">:</span> <span class="pl-c1">Column</span>(
          crossAxisAlignment<span class="pl-k">:</span> <span class="pl-c1">CrossAxisAlignment</span>.center,
          mainAxisAlignment<span class="pl-k">:</span> <span class="pl-c1">MainAxisAlignment</span>.center,
          children<span class="pl-k">:</span> <span class="pl-k">&lt;</span><span class="pl-c1">Widget</span><span class="pl-k">&gt;</span>[
            <span class="pl-c1">Center</span>(
              child<span class="pl-k">:</span> <span class="pl-en">cameraPreview</span>(),
            ),
            <span class="pl-c1">SizedBox</span>(height<span class="pl-k">:</span> <span class="pl-c1">8.0</span>,),
            <span class="pl-en">floatingButton</span>(),
          ],
        ),
      ),
    );
  }
}</pre></div>
<h2 dir="auto">Logs</h2>

<h3 dir="auto">flutter run --verbose</h3>
<p dir="auto"><a href="https://gist.github.com/dwach414/39f462cabe2e740f06a818dd9f5a7f60">https://gist.github.com/dwach414/39f462cabe2e740f06a818dd9f5a7f60</a></p>

<h3 dir="auto">flutter analyze</h3>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Analyzing flutter-login-poc...
No issues found! (ran in 1.4s)"><pre class="notranslate"><code class="notranslate">Analyzing flutter-login-poc...
No issues found! (ran in 1.4s)
</code></pre></div>

<h3 dir="auto">flutter doctor -v</h3>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="[✓] Flutter (Channel beta, v1.0.0, on Mac OS X 10.14.2 18C54, locale en-US)
    • Flutter version 1.0.0 at /Users/beemo/dev/flutter
    • Framework revision 5391447fae (2 weeks ago), 2018-11-29 19:41:26 -0800
    • Engine revision 7375a0f414
    • Dart version 2.1.0 (build 2.1.0-dev.9.4 f9ebf21297)

[✓] Android toolchain - develop for Android devices (Android SDK 28.0.3)
    • Android SDK at /Users/beemo/Library/Android/sdk
    • Android NDK at /Users/beemo/Library/Android/sdk/ndk-bundle
    • Platform android-28, build-tools 28.0.3
    • ANDROID_HOME = /Users/beemo/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1136-b06)
    • All Android licenses accepted.

[✓] iOS toolchain - develop for iOS devices (Xcode 10.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 10.1, Build version 10B61
    • ios-deploy 1.9.4
    • CocoaPods version 1.5.3

[✓] Android Studio (version 3.2)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 31.1.1
    • Dart plugin version 181.5656
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1136-b06)

[✓] Connected device (1 available)
    • Daniel’s iPhone • 00008020-00165D420128002E • ios • iOS 12.1

• No issues found!"><pre class="notranslate"><code class="notranslate">[✓] Flutter (Channel beta, v1.0.0, on Mac OS X 10.14.2 18C54, locale en-US)
    • Flutter version 1.0.0 at /Users/beemo/dev/flutter
    • Framework revision 5391447fae (2 weeks ago), 2018-11-29 19:41:26 -0800
    • Engine revision 7375a0f414
    • Dart version 2.1.0 (build 2.1.0-dev.9.4 f9ebf21297)

[✓] Android toolchain - develop for Android devices (Android SDK 28.0.3)
    • Android SDK at /Users/beemo/Library/Android/sdk
    • Android NDK at /Users/beemo/Library/Android/sdk/ndk-bundle
    • Platform android-28, build-tools 28.0.3
    • ANDROID_HOME = /Users/beemo/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1136-b06)
    • All Android licenses accepted.

[✓] iOS toolchain - develop for iOS devices (Xcode 10.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 10.1, Build version 10B61
    • ios-deploy 1.9.4
    • CocoaPods version 1.5.3

[✓] Android Studio (version 3.2)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 31.1.1
    • Dart plugin version 181.5656
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1136-b06)

[✓] Connected device (1 available)
    • Daniel’s iPhone • 00008020-00165D420128002E • ios • iOS 12.1

• No issues found!
</code></pre></div>