How can I limit video capturing via ImagePicker to 1 minutes maximum duration in Flutter?

3,110

use maxDuration provided by image_picker

 final PickedFile videoFile = await picker.getVideo( 
      source: ImageSource.camera,   
      maxDuration: const Duration(seconds: 60),
  );
Share:
3,110
Ghada Shebl
Author by

Ghada Shebl

Updated on December 14, 2022

Comments

  • Ghada Shebl
    Ghada Shebl over 1 year

    I'm using ImagePicker to upload videos either from gallery or via capturing them from camera.

    Problem is that I don't want the video to exceed 1 minute duration, when in gallery picking mode, I check the duration of selected video and show a message if video is longer than 1 minute.

    How can I do something like retrica, open camera but with limit on video duration ?