@@ -63,60 +63,62 @@ class _MkImageState extends State<MkImage> with SingleTickerProviderStateMixin {
6363 width: widget.width, height: widget.height, fit: widget.fit),
6464 );
6565 }
66+ Widget image = ExtendedImage (
67+ image: getExtendedResizeImage (widget.url),
68+ shape: widget.shape,
69+ loadStateChanged: (state) {
70+ switch (state.extendedImageLoadState) {
71+ case LoadState .completed:
72+ _controller.forward ();
73+ var image = FadeTransition (
74+ opacity: _controller,
75+ child: ExtendedRawImage (
76+ image: state.extendedImageInfo? .image,
77+ height: widget.height,
78+ width: widget.width,
79+ fit: widget.fit,
80+ filterQuality: FilterQuality .medium,
81+ ),
82+ );
83+ if (widget.blurHash == null || widget.blurHash! .isEmpty) {
84+ return image;
85+ }
86+ return BlurHash (
87+ widget.blurHash! ,
88+ child: image,
89+ );
90+ case LoadState .loading:
91+ case LoadState .failed:
92+ return LayoutBuilder (
93+ builder: (context, constraints) {
94+ var constraintsHeight = constraints.maxHeight;
95+ var constraintsWidth = constraints.maxWidth;
96+ if (constraints.maxHeight == double .infinity) {
97+ constraintsHeight = constraints.minHeight;
98+ }
99+ if (constraints.maxWidth == double .infinity) {
100+ constraintsWidth = constraints.minWidth;
101+ }
102+ return Container (
103+ width: widget.width ?? widget.height ?? constraintsWidth,
104+ height: widget.height ?? constraintsHeight,
105+ color: const Color .fromARGB (10 , 0 , 0 , 0 ),
106+ child:
107+ (widget.blurHash != null && widget.blurHash! .isNotEmpty)
108+ ? BlurHash (widget.blurHash! )
109+ : null ,
110+ );
111+ },
112+ );
113+ }
114+ },
115+ );
116+
117+ if (widget.heroKey != null ) {
118+ image = Hero (tag: widget.heroKey ?? UniqueKey (), child: image);
119+ }
66120 return RepaintBoundary (
67- child: Hero (
68- tag: widget.heroKey ?? UniqueKey (),
69- child: ExtendedImage (
70- image: getExtendedResizeImage (widget.url),
71- shape: widget.shape,
72- loadStateChanged: (state) {
73- switch (state.extendedImageLoadState) {
74- case LoadState .completed:
75- _controller.forward ();
76- var image = FadeTransition (
77- opacity: _controller,
78- child: ExtendedRawImage (
79- image: state.extendedImageInfo? .image,
80- height: widget.height,
81- width: widget.width,
82- fit: widget.fit,
83- filterQuality: FilterQuality .medium,
84- ),
85- );
86- if (widget.blurHash == null || widget.blurHash! .isEmpty) {
87- return image;
88- }
89- return BlurHash (
90- widget.blurHash! ,
91- child: image,
92- );
93- case LoadState .loading:
94- case LoadState .failed:
95- return LayoutBuilder (
96- builder: (context, constraints) {
97- var constraintsHeight = constraints.maxHeight;
98- var constraintsWidth = constraints.maxWidth;
99- if (constraints.maxHeight == double .infinity) {
100- constraintsHeight = constraints.minHeight;
101- }
102- if (constraints.maxWidth == double .infinity) {
103- constraintsWidth = constraints.minWidth;
104- }
105- return Container (
106- width:
107- widget.width ?? widget.height ?? constraintsWidth,
108- height: widget.height ?? constraintsHeight,
109- color: const Color .fromARGB (10 , 0 , 0 , 0 ),
110- child: (widget.blurHash != null &&
111- widget.blurHash! .isNotEmpty)
112- ? BlurHash (widget.blurHash! )
113- : null ,
114- );
115- },
116- );
117- }
118- },
119- )),
121+ child: image,
120122 );
121123 }
122124}
0 commit comments