expandedImageWidget method

Widget expandedImageWidget(
  1. String? id, {
  2. required double aspectRatio,
  3. required BoxFit fit,
  4. BorderRadius clipRadius = BorderRadius.zero,
})

Implementation

Widget expandedImageWidget(String? id,
    {required double aspectRatio, required BoxFit fit, BorderRadius clipRadius = BorderRadius
        .zero}) {
  if (id?.isNotEmpty != true) return const SizedBox();

  return Expanded(
      child: AspectRatio(
          aspectRatio: aspectRatio,
          child: ClipRRect(
              borderRadius: clipRadius,
              child: FutureBuilder<Uint8List?>(
                  key: Key(id!),
                  future: DI.media().getImage(id),
                  builder: (context, snapshot) {
                    if (snapshot.hasData) {
                      return Image.memory(
                        key: Key(id),
                        snapshot.data!,
                        fit: fit,
                        gaplessPlayback: true,
                        errorBuilder: (context, obj, stack) {
                          return SizedBox(
                            child: SvgPicture.memory(
                              key: Key(id),
                              snapshot.data!,
                              fit: fit,
                            ),
                          );
                        },
                      );
                    }
                    return const SizedBox();
                  })
          )
      )
  );
}