title: how to compress size of image in Flutter
body: <p>How can I(compress) the size of the image when I select it from the gallery or take it from the camera? Did Flutter have a package or ways to do it?</p>
  
  <pre><code>import 'package:image_picker/image_picker.dart';
  
  class MyHomePage extends StatefulWidget {
    @override
    _MyHomePageState createState() =&gt; _MyHomePageState();
  }
  
  class _MyHomePageState extends State&lt;MyHomePage&gt; {
    File _image;
  
    Future getImage() async {
      var image = await ImagePicker.pickImage(source: ImageSource.camera);
  
      setState(() {
        _image = image;
      });
    }
  
    @override
    Widget build(BuildContext context) {
      return Scaffold(
        appBar: AppBar(
          title: Text('Image Picker Example'),
        ),
        body: Center(
          child: _image == null
              ? Text('No image selected.')
              : Image.file(_image),
        ),
        floatingActionButton: FloatingActionButton(
          onPressed: getImage,
          tooltip: 'Pick Image',
          child: Icon(Icons.add_a_photo),
        ),
      );
    }
  }`
  </code></pre>