[0.1.3]
This commit is contained in:
@@ -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: <Widget>[
|
||||
OctoImage(
|
||||
key: ValueKey<String>(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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user