toImageWidget method

Widget toImageWidget({
  1. double? height,
  2. double? width,
  3. int turns = 0,
})

Implementation

Widget toImageWidget({double? height, double? width, int turns = 0}) {
  if (kIsWeb || path.isEmpty) {
    return FutureBuilder(
      future: readAsBytes(),
      builder: (context, snapshot) {
        if (snapshot.hasData) {
          return RotatedBox(
            quarterTurns: turns,
            child: Image.memory(
              snapshot.data!,
              height: height,
              width: width,
            ),
          );
        } else {
          return Container();
        }
      },
    );
  }
  return RotatedBox(
    quarterTurns: turns,
    child: Image.file(
      File(path),
      width: width,
      height: height,
      fit: BoxFit.fill,
    ),
  );
}