title: "[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: type 'Future<File>' is not a subtype of type 'File?' in type cast" Error
body: <p>I'm trying to upload a pic with Flutter and upload this image to imgur. But I am getting an error. Before that, let me show you my codes:</p>
  <pre><code>FloatingActionButton.large(
    child: Icon(Icons.folder, color: Colors.white, size: 45,),
    backgroundColor: Color.fromARGB(255, 36, 36, 36),
    onPressed: () async {
      final File? image = ImagePicker.pickImage(source: ImageSource.gallery) as File?;
      final File? imagefile = File(image!.path);
      if (imagefile == null) {
        ScaffoldMessenger.of(context).showSnackBar(
          SnackBar(
            content: Text(&quot;not image selected.&quot;),
            backgroundColor: Color.fromARGB(255, 36, 36, 36),
          ),
        );
        return null;
      }
      else {
        print(&quot;else&quot;);
        uploadImage(&quot;bolat&quot;, image);
      }
    },
  ),
  // ...
    void uploadImage(String title, File file) async {
      var request = http.MultipartRequest(&quot;POST&quot;, Uri.parse(&quot;https://api.imgur.com/3/image&quot;));
      request.fields[&quot;title&quot;] = title;
      request.headers[&quot;Authorization&quot;] = &quot;&quot;;
      var picture = http.MultipartFile.fromBytes('image', (await rootBundle.load('assets/testimage.png')).buffer.asUint8List(),
      filename: 'image.png');
      request.files.add(picture);
      var response = await request.send();
      var responseData = await response.stream.toBytes();
      var result = String.fromCharCodes(responseData);
      print(result);
   }
  </code></pre>
  <p>When I try this code I get this error:</p>
  <pre><code>[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: type 'Future&lt;File&gt;' is not a subtype of type 'File?' in type cast
  #0      _BolatAktarAppState.build.&lt;anonymous closure&gt;.&lt;anonymous closure&gt;.&lt;anonymous closure&gt; (package:bolataktar_resimyukleme/screens/resimyukleme_main.dart:66:104)
  #1      _BolatAktarAppState.build.&lt;anonymous closure&gt;.&lt;anonymous closure&gt;.&lt;anonymous closure&gt; (package:bolataktar_resimyukleme/screens/resimyukleme_main.dart:65:42)
  #2      _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:1010:21)
  #3      GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:247:24)
  #4      TapGestureRecognizer.handleTapUp (package:flutter/src/gestures/tap.dart:620:11)
  #5      BaseTapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:299:5)
  #6      BaseTapGestureRecognizer.acceptGesture (package:flutter/src/gestures/tap.dart:269:7)
  #7      GestureArenaManager.sweep (package:flutter/src/gestures/arena.dart:163:27)
  #8      GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:454:20)
  #9      GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:430:22)
  #10     RendererBinding.dispatchEvent (package:flutter/src/rendering/binding.dart:337:11)
  #11     GestureBinding._handlePointerEventImmediately (package:flutter/src/gestures/binding.dart:385:7)
  #12     GestureBinding.handlePointerEvent (package:flutter/src/gestures/binding.dart:347:5)
  #13     GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:304:7)
  #14     GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:285:7)
  #15     _invoke1 (dart:ui/hooks.dart:167:13)
  #16     PlatformDispatcher._dispatchPointerDataPacket (dart:ui/platform_dispatcher.dart:341:7)
  #17     _dispatchPointerDataPacket (dart:ui/hooks.dart:94:31)
  
  [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: MissingPluginException(No implementation found for method pickImage on channel plugins.flutter.io/image_picker)
  #0      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:292:7)
  &lt;asynchronous suspension&gt;
  #1      ImagePicker.pickImage (package:image_picker/image_picker.dart:64:25)
  &lt;asynchronous suspension&gt;
  </code></pre>
  <p>How can I solve this problem? Thanks in advance for your help.</p>