title: Flutter How to save Image file to new folder in gallery?
body: <p>I want to save the image in the gallery after I get the file from the camera, how to create a new directory and save the image file that we have obtained from the camera?</p>
  
  <pre><code> Future getImageCamera() async {
  var imageFile = await ImagePicker.pickImage(
      source: ImageSource.camera, maxHeight: 20.0, maxWidth: 20.0);
  
  DateTime ketF = new DateTime.now();
  String baru = "${ketF.year}${ketF.month}${ketF.day}";
  
  //proses kompres
  final temDirk = await getTemporaryDirectory();
  final pathss = temDirk.path;
  
  int rand = new math.Random().nextInt(100000);
  
  //mengganti nama file
  // String juduld = controllerJudul.text;
  
  img.Image gambard = img.decodeImage(imageFile.readAsBytesSync());
  img.Image gambarKecilx = img.copyResize(gambard,
      700); //parameter awal adalah sumber gambar // parameter kedua ukuran width, hp=&gt;1k
  
  var kompresimg = new File("$pathss/image_$baru$rand.jpg")
    ..writeAsBytesSync(img.encodeJpg(gambarKecilx, quality: 95));
  
  setState(() {
    _gambar = kompresimg;
    namafile = "image_$baru$rand.jpg";
  });
  </code></pre>