title: How to add an image from camera in flutter?
body: <p>I created a placeholder for an image in my app, on clicking which I want to be able to open camera, and show the image clicked in the placeholder. I used the image_picker package for this. I wrapped my placeholder container with GestureDetector, however nothing happens on tapping on the container. How do i resolve this ?</p>
  
  <p>In my main file containing Stateless widget, i added my Stateful widget addImage()</p>
  
  <pre><code>Column(
                crossAxisAlignment: CrossAxisAlignment.stretch,
                children: &lt;Widget&gt;[
  
                    addImage(),  // my stateful widget 
                  TextField(
  
                    )
                  ),              
                  Row(
                   //other implementation here 
                    ],
                  )
  
                ]
              )
  </code></pre>
  
  <p>My addImage stateful widget looks like this</p>
  
  <pre><code>import 'dart:async';
  import 'dart:io';
  import 'package:flutter/material.dart';
  import 'package:image_picker/image_picker.dart';
  
  
  class addImage extends StatefulWidget{
    @override
    _addImageState createState() =&gt; _addImageState();
  }
  
  class _addImageState extends State&lt;addImage&gt; {
  
    File _image;
  
    Future getImagefromCamera() async{
  
      var image = await ImagePicker.pickImage(source: ImageSource.camera);
  
      setState(() {
        _image = image;
      });
    }
  
  
    @override
    Widget build(BuildContext context) {
  
      return GestureDetector(
        onTap: getImagefromCamera,
        child: _image == null ? Container(decoration: BoxDecoration(color: Colors.red[50],border: Border.all(color: Colors.red[200], width: 1.0),borderRadius: BorderRadius.circular(10.0)),
            child: Column(
              children: &lt;Widget&gt;[
                SizedBox(height:30.0),
                Icon(Icons.camera_alt, color: Colors.red),
                SizedBox(height: 10.0),
                Text('Take Image of the Item', style: TextStyle(color: Colors.red)),
                SizedBox(height: 30.0)
              ],
            )) : Image.file(_image),
      );
    }
  
  }
  </code></pre>
  
  <p>I even added the dependency in pubspec.yaml , however still doesnt work </p>
  
  <pre><code> image_picker: ^0.4.5
  
  </code></pre>