getImage method

Future<PickedFile?> getImage(
  1. int index
)

Pick Image from Camera or gallery index 0->Gallery 1->Camera

Implementation

Future<PickedFile?> getImage(int index) async {
  PickedFile? selectedFile;

  if (kIsWeb) {
    selectedFile = await ImagePicker().getImage(source: ImageSource.gallery);
  } else {
    if (index == 0)
      selectedFile =
          await ImagePicker().getImage(source: ImageSource.gallery);
    else
      selectedFile = await ImagePicker().getImage(source: ImageSource.camera);
  }

  if (selectedFile != null) {
    return selectedFile;
  } else {
    return null;
  }
}