multipleImageView method

Widget multipleImageView(
  1. ValueNotifier<List<XFile>> pickedImage
)

Implementation

Widget multipleImageView(ValueNotifier<List<XFile>> pickedImage) {
  return LayoutBuilder(
    builder: (BuildContext context, BoxConstraints constraints) => Wrap(
      runSpacing: 2,
      spacing: 2,
      children: List.generate(
          pickedImage.value.length <= 3 ? pickedImage.value.length : 4,
          (index) {
        if (index < 3) {
          return SizedBox(
            height: (constraints.maxHeight / 2) - 2,
            width: (constraints.maxWidth / 2) - 2,
            child: Image.file(
              File(pickedImage.value[index].path),
              fit: BoxFit.cover,
            ),
          );
        } else {
          return SizedBox(
            height: (constraints.maxHeight / 2) - 2,
            width: (constraints.maxWidth / 2) - 2,
            child: Stack(
              fit: StackFit.expand,
              children: [
                Image.file(
                  File(pickedImage.value[index].path),
                  fit: BoxFit.cover,
                ),
                Center(
                  child: Container(
                      color: Colors.black.withOpacity(0.5),
                      child: Text('+${pickedImage.value.length - 4}')
                          .fontSize(18)
                          .fontWeight(FontWeight.w500)
                          .textColor(Colors.white)
                          .center()),
                ),
              ],
            ),
          );
        }
      }),
    ),
  );
}