title: How to use image_picker in flutter
body: <p>I am confused about how to use image_picker, this is how I use it in my application (like in many tutorials):</p>
  
  <pre><code>class AddDialogState extends State&lt;AddDialog&gt; {
      File galleryFile;
      Widget _onlyStatus() {
           getLocalImage() async {
                 var _galleryFile = await ImagePicker.pickImage(
                       source: ImageSource.gallery
                 };
                 setState(() {
                     galleryFile = _galleryFile;
                 });
                 print(_galleryFile.path);
           }
  
           return Column(
                 ........
                 FlatButton.icon(
                      onPressed: () {
                           getLocalImage();
                      }
                 )
           )
  
      }
  
      @override
      Widget build(BuildContext context) {
           // fullscreen dialog
           .........
           body: _onlyStatus()
      }
  }
  </code></pre>
  
  <p>The problem was, the above code doesn't start ImagePicker, when i click the FlatButton, the above code just produce an error <code>the getter 'path' was called on null</code>, it doesn't start any new activity related to gallery, so what's wrong with my code?</p>