From 0f99ba21a7d92919105c3e486068bb39fead0dbe Mon Sep 17 00:00:00 2001 From: "Michael W. Aziz" Date: Wed, 5 Mar 2025 12:27:00 +0200 Subject: [PATCH] [0.1.3] --- lib/src/Widgets/src/image.widget.dart | 47 +++++++++++++++------------ 1 file changed, 26 insertions(+), 21 deletions(-) diff --git a/lib/src/Widgets/src/image.widget.dart b/lib/src/Widgets/src/image.widget.dart index bacf20e..b80f8cf 100644 --- a/lib/src/Widgets/src/image.widget.dart +++ b/lib/src/Widgets/src/image.widget.dart @@ -57,23 +57,23 @@ class AstromicImage extends StatelessWidget { this.assetBytes, this.assetFallback, // - this.sizingMaster , + this.sizingMaster = ImageSizingMaster.w, this.widthSizing, this.heightSizing, this.fixedWidth, this.fixedHeight, // - this.isCircular, + this.isCircular = false, this.borderWidth, this.borderColor, this.borderPadding, - this.radius, + this.radius = BorderRadius.zero, this.shadow, this.overlayColor, this.overlayGradient, // - this.fit, - this.alignment, + this.fit = BoxFit.contain, + this.alignment = Alignment.center, this.blendMode, this.fadeInCurve, this.fadeInDuration, @@ -83,18 +83,23 @@ class AstromicImage extends StatelessWidget { this.loadingWidget, this.errorWidget, }) : - // Assert that a source is provided, or provide a fallback source.. - assert(((assetPath?.isNotEmpty ?? false) || (assetURL?.isNotEmpty ?? false) || (assetBytes?.isNotEmpty ?? false)) || (assetFallback?.isNotEmpty ?? false), - 'Please specify a source or provide a fallback.'), - // Assert that only ONE source is provided... + // Assert that a source is provided, or provide a fallback source. assert( - (assetPath != null && assetBytes == null && assetURL == null) || - (assetPath == null && assetBytes != null && assetURL == null) || - (assetPath == null && assetBytes == null && assetURL != null), - 'Please specify only ONE Asset Source'), - // Assert that correct sizing plan is provided... - assert((sizingMaster == ImageSizingMaster.w && (widthSizing != null || fixedWidth != null)) || (sizingMaster == ImageSizingMaster.h && (heightSizing != null || fixedHeight != null)), - 'Please provide the correct sizing configurations based on the SizingMaster choosen'); + ((assetPath?.isNotEmpty ?? false) || (assetURL?.isNotEmpty ?? false) || (assetBytes?.isNotEmpty ?? false)) || (assetFallback?.isNotEmpty ?? false), + 'Please specify a source or provide a fallback.', + ), + // Assert that only ONE source is provided. + assert( + (assetPath != null && assetBytes == null && assetURL == null) || + (assetPath == null && assetBytes != null && assetURL == null) || + (assetPath == null && assetBytes == null && assetURL != null), + 'Please specify only ONE Asset Source.', + ), + // Assert that correct sizing plan is provided. + assert( + (sizingMaster == ImageSizingMaster.w && (widthSizing != null || fixedWidth != null)) || (sizingMaster == ImageSizingMaster.h && (heightSizing != null || fixedHeight != null)), + 'Please provide the correct sizing configurations based on the SizingMaster chosen.', + ); //SECTION - Widget Arguments //S1 -- Assets final String? assetPath; @@ -181,14 +186,14 @@ class AstromicImage extends StatelessWidget { ) : null; - Widget buildImage(Size size) { + Widget buildImage(Size size) { return Stack( children: [ OctoImage( key: ValueKey(assetType == _DeclaredAssetType.bytes ? (assetRef as Uint8List).length.toString() : assetRef), // width: size.width, - height: size.height == double.infinity? null : size.height, + height: size.height == double.infinity ? null : size.height, fit: fit, alignment: alignment, filterQuality: FilterQuality.none, @@ -205,7 +210,7 @@ class AstromicImage extends StatelessWidget { // progressIndicatorBuilder: (_, ImageChunkEvent? bytes) => SizedBox( width: size.width, - height: size.height == double.infinity? null : size.height, + height: size.height == double.infinity ? null : size.height, child: loadingWidget != null ? loadingWidget!(bytes?.cumulativeBytesLoaded, bytes?.expectedTotalBytes) : defaultLoadingWidget, ), // placeholderBuilder: (BuildContext context) => loadingWidget != null ? loadingWidget!(null, null) : defaultLoadingWidget, @@ -213,7 +218,7 @@ class AstromicImage extends StatelessWidget { fadeInDuration: fadeInDuration, imageBuilder: (BuildContext context, Widget image) => Container( width: size.width, - height: size.height == double.infinity? null : size.height, + height: size.height == double.infinity ? null : size.height, padding: borderPadding ?? EdgeInsets.zero, margin: EdgeInsets.zero, decoration: BoxDecoration( @@ -250,7 +255,7 @@ class AstromicImage extends StatelessWidget { //SECTION - Build Return return LayoutBuilder(builder: (BuildContext context, BoxConstraints constraints) { Size size = _calculateSize(constraints); - return SizedBox(width: size.width, height: size.height, child: buildImage(size)); + return SizedBox(width: size.width == double.infinity? null : size.width, height: size.height == double.infinity? null : size.height, child: buildImage(size)); }); //!SECTION }