diff --git a/packages/neon/neon/lib/src/widgets/cached_image.dart b/packages/neon/neon/lib/src/widgets/cached_image.dart index 43d0331a..3e1fe9b6 100644 --- a/packages/neon/neon/lib/src/widgets/cached_image.dart +++ b/packages/neon/neon/lib/src/widgets/cached_image.dart @@ -27,46 +27,34 @@ abstract class NeonCachedImage extends StatefulWidget { } class _NeonCachedImageState extends State { - late Future future = widget.getImageFile(); + Future _readImage() async { + final file = await widget.getImageFile(); + return file.readAsBytes(); + } + + late Future _future = _readImage(); @override Widget build(final BuildContext context) => Center( - child: FutureBuilder( - future: future, + child: FutureBuilder( + future: _future, builder: (final context, final fileSnapshot) { - if (fileSnapshot.hasData) { - final content = fileSnapshot.requireData.readAsBytesSync(); - - try { - // TODO: Is this safe enough? - if (widget.isSvgHint || utf8.decode(content).contains(' { color: widget.iconColor ?? Theme.of(context).colorScheme.error, ); } - return SizedBox( + + final content = fileSnapshot.requireData; + + try { + // TODO: Is this safe enough? + if (widget.isSvgHint || utf8.decode(content).contains('