showImagePickerBottomSheet static method

dynamic showImagePickerBottomSheet(
  1. BuildContext context,
  2. void callback(
    1. File image
    ), {
  3. String? galleryName = 'Gallery',
  4. String? cameraName = 'Camera',
  5. String? cameraAssets,
  6. String? galleryAssets,
})

Implementation

static showImagePickerBottomSheet(
  BuildContext context,
  void Function(File image) callback, {
  String? galleryName = 'Gallery',
  String? cameraName = 'Camera',
  String? cameraAssets,
  String? galleryAssets,
}) {
  showModalBottomSheet(
    backgroundColor: Colors.transparent,
    isScrollControlled: true,
    context: context,
    builder: (BuildContext bc) {
      return Container(
        alignment: Alignment.bottomCenter,
        child: Wrap(
          children: [
            SizedBox(
              height: 130.0,
              child: Container(
                decoration: const BoxDecoration(
                  color: Colors.white,
                  borderRadius: BorderRadius.only(
                    topLeft: Radius.circular(16.0),
                    topRight: Radius.circular(16.0),
                  ),
                ),
                child: Row(
                  children: [
                    Expanded(
                      child: InkWell(
                        onTap: () {
                          Navigator.pop(context);
                          pickImage(ImageSource.camera).then((imageFile) {
                            if (imageFile != null) {
                              callback(imageFile);
                            }
                          });
                        },
                        child: Column(
                          mainAxisAlignment: MainAxisAlignment.center,
                          children: [
                            cameraAssets == null
                                ? const Icon(
                                    Icons.camera,
                                    size: 40.0,
                                    color: Colors.blue,
                                  )
                                : SvgPicture.asset(
                                    cameraAssets,
                                    width: 40.0,
                                    height: 40.0,
                                  ),
                            const SizedBox(height: 10.0),
                            Text(
                              cameraName ?? 'Camera',
                              style: GSFormStyle().titleTextStyle,
                            )
                          ],
                        ),
                      ),
                    ),
                    Expanded(
                      child: InkWell(
                        onTap: () {
                          Navigator.pop(context);
                          pickImage(ImageSource.gallery).then((imageFile) {
                            if (imageFile != null) {
                              callback(imageFile);
                            }
                          });
                        },
                        child: Column(
                          mainAxisAlignment: MainAxisAlignment.center,
                          children: [
                            galleryAssets == null
                                ? const Icon(
                                    Icons.photo_library,
                                    size: 40.0,
                                    color: Colors.blue,
                                  )
                                : SvgPicture.asset(
                                    galleryAssets,
                                    width: 40.0,
                                    height: 40.0,
                                  ),
                            const SizedBox(height: 10.0),
                            Text(
                              galleryName ?? 'Gallery',
                              style: GSFormStyle().titleTextStyle,
                            )
                          ],
                        ),
                      ),
                    ),
                  ],
                ),
              ),
            ),
          ],
        ),
      );
    },
  );
}