[0.1.3]
This commit is contained in:
@@ -57,23 +57,23 @@ class AstromicImage extends StatelessWidget {
|
|||||||
this.assetBytes,
|
this.assetBytes,
|
||||||
this.assetFallback,
|
this.assetFallback,
|
||||||
//
|
//
|
||||||
this.sizingMaster ,
|
this.sizingMaster = ImageSizingMaster.w,
|
||||||
this.widthSizing,
|
this.widthSizing,
|
||||||
this.heightSizing,
|
this.heightSizing,
|
||||||
this.fixedWidth,
|
this.fixedWidth,
|
||||||
this.fixedHeight,
|
this.fixedHeight,
|
||||||
//
|
//
|
||||||
this.isCircular,
|
this.isCircular = false,
|
||||||
this.borderWidth,
|
this.borderWidth,
|
||||||
this.borderColor,
|
this.borderColor,
|
||||||
this.borderPadding,
|
this.borderPadding,
|
||||||
this.radius,
|
this.radius = BorderRadius.zero,
|
||||||
this.shadow,
|
this.shadow,
|
||||||
this.overlayColor,
|
this.overlayColor,
|
||||||
this.overlayGradient,
|
this.overlayGradient,
|
||||||
//
|
//
|
||||||
this.fit,
|
this.fit = BoxFit.contain,
|
||||||
this.alignment,
|
this.alignment = Alignment.center,
|
||||||
this.blendMode,
|
this.blendMode,
|
||||||
this.fadeInCurve,
|
this.fadeInCurve,
|
||||||
this.fadeInDuration,
|
this.fadeInDuration,
|
||||||
@@ -83,18 +83,23 @@ class AstromicImage extends StatelessWidget {
|
|||||||
this.loadingWidget,
|
this.loadingWidget,
|
||||||
this.errorWidget,
|
this.errorWidget,
|
||||||
}) :
|
}) :
|
||||||
// Assert that a source is provided, or provide a fallback source..
|
// 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(
|
assert(
|
||||||
(assetPath != null && assetBytes == null && assetURL == null) ||
|
((assetPath?.isNotEmpty ?? false) || (assetURL?.isNotEmpty ?? false) || (assetBytes?.isNotEmpty ?? false)) || (assetFallback?.isNotEmpty ?? false),
|
||||||
(assetPath == null && assetBytes != null && assetURL == null) ||
|
'Please specify a source or provide a fallback.',
|
||||||
(assetPath == null && assetBytes == null && assetURL != null),
|
),
|
||||||
'Please specify only ONE Asset Source'),
|
// Assert that only ONE source is provided.
|
||||||
// Assert that correct sizing plan is provided...
|
assert(
|
||||||
assert((sizingMaster == ImageSizingMaster.w && (widthSizing != null || fixedWidth != null)) || (sizingMaster == ImageSizingMaster.h && (heightSizing != null || fixedHeight != null)),
|
(assetPath != null && assetBytes == null && assetURL == null) ||
|
||||||
'Please provide the correct sizing configurations based on the SizingMaster choosen');
|
(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
|
//SECTION - Widget Arguments
|
||||||
//S1 -- Assets
|
//S1 -- Assets
|
||||||
final String? assetPath;
|
final String? assetPath;
|
||||||
@@ -181,14 +186,14 @@ class AstromicImage extends StatelessWidget {
|
|||||||
)
|
)
|
||||||
: null;
|
: null;
|
||||||
|
|
||||||
Widget buildImage(Size size) {
|
Widget buildImage(Size size) {
|
||||||
return Stack(
|
return Stack(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
OctoImage(
|
OctoImage(
|
||||||
key: ValueKey<String>(assetType == _DeclaredAssetType.bytes ? (assetRef as Uint8List).length.toString() : assetRef),
|
key: ValueKey<String>(assetType == _DeclaredAssetType.bytes ? (assetRef as Uint8List).length.toString() : assetRef),
|
||||||
//
|
//
|
||||||
width: size.width,
|
width: size.width,
|
||||||
height: size.height == double.infinity? null : size.height,
|
height: size.height == double.infinity ? null : size.height,
|
||||||
fit: fit,
|
fit: fit,
|
||||||
alignment: alignment,
|
alignment: alignment,
|
||||||
filterQuality: FilterQuality.none,
|
filterQuality: FilterQuality.none,
|
||||||
@@ -205,7 +210,7 @@ class AstromicImage extends StatelessWidget {
|
|||||||
//
|
//
|
||||||
progressIndicatorBuilder: (_, ImageChunkEvent? bytes) => SizedBox(
|
progressIndicatorBuilder: (_, ImageChunkEvent? bytes) => SizedBox(
|
||||||
width: size.width,
|
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,
|
child: loadingWidget != null ? loadingWidget!(bytes?.cumulativeBytesLoaded, bytes?.expectedTotalBytes) : defaultLoadingWidget,
|
||||||
),
|
),
|
||||||
// placeholderBuilder: (BuildContext context) => loadingWidget != null ? loadingWidget!(null, null) : defaultLoadingWidget,
|
// placeholderBuilder: (BuildContext context) => loadingWidget != null ? loadingWidget!(null, null) : defaultLoadingWidget,
|
||||||
@@ -213,7 +218,7 @@ class AstromicImage extends StatelessWidget {
|
|||||||
fadeInDuration: fadeInDuration,
|
fadeInDuration: fadeInDuration,
|
||||||
imageBuilder: (BuildContext context, Widget image) => Container(
|
imageBuilder: (BuildContext context, Widget image) => Container(
|
||||||
width: size.width,
|
width: size.width,
|
||||||
height: size.height == double.infinity? null : size.height,
|
height: size.height == double.infinity ? null : size.height,
|
||||||
padding: borderPadding ?? EdgeInsets.zero,
|
padding: borderPadding ?? EdgeInsets.zero,
|
||||||
margin: EdgeInsets.zero,
|
margin: EdgeInsets.zero,
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
@@ -250,7 +255,7 @@ class AstromicImage extends StatelessWidget {
|
|||||||
//SECTION - Build Return
|
//SECTION - Build Return
|
||||||
return LayoutBuilder(builder: (BuildContext context, BoxConstraints constraints) {
|
return LayoutBuilder(builder: (BuildContext context, BoxConstraints constraints) {
|
||||||
Size size = _calculateSize(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
|
//!SECTION
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user