[0.1.0]
This commit is contained in:
@@ -11,15 +11,6 @@ import 'package:flutter/material.dart';
|
||||
//s1 Exports
|
||||
|
||||
class AstromicBlur extends StatelessWidget {
|
||||
//SECTION - Widget Arguments
|
||||
final Widget child;
|
||||
final (double x, double y)? sigma;
|
||||
final TileMode? tileMode;
|
||||
final Color? overlayColor;
|
||||
final Gradient? overlayGradient;
|
||||
final BorderRadius? radius;
|
||||
final List<BoxShadow>? shadow;
|
||||
final Widget? childOnTop;
|
||||
//!SECTION
|
||||
//
|
||||
const AstromicBlur({
|
||||
@@ -33,6 +24,15 @@ class AstromicBlur extends StatelessWidget {
|
||||
this.shadow,
|
||||
this.childOnTop,
|
||||
});
|
||||
//SECTION - Widget Arguments
|
||||
final Widget child;
|
||||
final (double x, double y)? sigma;
|
||||
final TileMode? tileMode;
|
||||
final Color? overlayColor;
|
||||
final Gradient? overlayGradient;
|
||||
final BorderRadius? radius;
|
||||
final List<BoxShadow>? shadow;
|
||||
final Widget? childOnTop;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -56,7 +56,7 @@ class AstromicBlur extends StatelessWidget {
|
||||
borderRadius: radius ?? BorderRadius.zero,
|
||||
child: Stack(
|
||||
fit: StackFit.expand,
|
||||
children: [
|
||||
children: <Widget>[
|
||||
child, // The main widget goes under the blurred background
|
||||
BackdropFilter(
|
||||
filter: ImageFilter.blur(sigmaX: sigma!.$1, sigmaY: sigma!.$2),
|
||||
|
||||
@@ -47,42 +47,6 @@ _DeclaredAssetType _parseAssetType(
|
||||
}
|
||||
|
||||
class AstromicImage extends StatelessWidget {
|
||||
//SECTION - Widget Arguments
|
||||
//S1 -- Assets
|
||||
final String? assetPath;
|
||||
final String? assetURL;
|
||||
final Uint8List? assetBytes;
|
||||
final String? assetFallback;
|
||||
//S1 -- Sizing
|
||||
final ImageSizingMaster? sizingMaster;
|
||||
final (double factor, double? min, double? max)? widthSizing;
|
||||
|
||||
/// Used when the width is Master and want to set fixed width OR if height is Master and want to constraint the width
|
||||
final double? fixedWidth;
|
||||
final (double factor, double? min, double? max)? heightSizing;
|
||||
|
||||
/// Used when the height is Master and want to set fixed height OR if width is Master and want to constraint the height
|
||||
final double? fixedHeight;
|
||||
//S1 -- STYLING
|
||||
final bool? isCircular;
|
||||
final double? borderWidth;
|
||||
final Color? borderColor;
|
||||
final EdgeInsetsGeometry? borderPadding;
|
||||
final BorderRadiusGeometry? radius;
|
||||
final List<BoxShadow>? shadow;
|
||||
final Color? overlayColor;
|
||||
final Gradient? overlayGradient;
|
||||
//S1 -- CONFIGURATIONS
|
||||
final Alignment? alignment;
|
||||
final BoxFit? fit;
|
||||
final BlendMode? blendMode;
|
||||
final Curve? fadeInCurve;
|
||||
final Duration? fadeInDuration;
|
||||
//S1 -- SVG FILTERS
|
||||
final Color? svgColor;
|
||||
//S1 -- STATE WIDGETS
|
||||
final Widget Function(int? loadedBytes, int? totalBytesToLoad)? loadingWidget;
|
||||
final Widget Function(dynamic error, StackTrace? stackTrace)? errorWidget;
|
||||
//!SECTION
|
||||
//
|
||||
AstromicImage({
|
||||
@@ -121,16 +85,52 @@ class AstromicImage extends StatelessWidget {
|
||||
}) :
|
||||
// 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."),
|
||||
'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"),
|
||||
'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");
|
||||
'Please provide the correct sizing configurations based on the SizingMaster choosen');
|
||||
//SECTION - Widget Arguments
|
||||
//S1 -- Assets
|
||||
final String? assetPath;
|
||||
final String? assetURL;
|
||||
final Uint8List? assetBytes;
|
||||
final String? assetFallback;
|
||||
//S1 -- Sizing
|
||||
final ImageSizingMaster? sizingMaster;
|
||||
final (double factor, double? min, double? max)? widthSizing;
|
||||
|
||||
/// Used when the width is Master and want to set fixed width OR if height is Master and want to constraint the width
|
||||
final double? fixedWidth;
|
||||
final (double factor, double? min, double? max)? heightSizing;
|
||||
|
||||
/// Used when the height is Master and want to set fixed height OR if width is Master and want to constraint the height
|
||||
final double? fixedHeight;
|
||||
//S1 -- STYLING
|
||||
final bool? isCircular;
|
||||
final double? borderWidth;
|
||||
final Color? borderColor;
|
||||
final EdgeInsetsGeometry? borderPadding;
|
||||
final BorderRadiusGeometry? radius;
|
||||
final List<BoxShadow>? shadow;
|
||||
final Color? overlayColor;
|
||||
final Gradient? overlayGradient;
|
||||
//S1 -- CONFIGURATIONS
|
||||
final Alignment? alignment;
|
||||
final BoxFit? fit;
|
||||
final BlendMode? blendMode;
|
||||
final Curve? fadeInCurve;
|
||||
final Duration? fadeInDuration;
|
||||
//S1 -- SVG FILTERS
|
||||
final Color? svgColor;
|
||||
//S1 -- STATE WIDGETS
|
||||
final Widget Function(int? loadedBytes, int? totalBytesToLoad)? loadingWidget;
|
||||
final Widget Function(dynamic error, StackTrace? stackTrace)? errorWidget;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -152,7 +152,7 @@ class AstromicImage extends StatelessWidget {
|
||||
Widget? finalSVGWidget(Size size, Widget? loadingWidget) => assetType == _DeclaredAssetType.path
|
||||
? SvgPicture.asset(
|
||||
assetRef,
|
||||
key: ValueKey(assetRef),
|
||||
key: ValueKey<String>(assetRef),
|
||||
width: size.width,
|
||||
height: size.height,
|
||||
fit: fit!,
|
||||
@@ -167,7 +167,7 @@ class AstromicImage extends StatelessWidget {
|
||||
: assetType == _DeclaredAssetType.url
|
||||
? SvgPicture.network(
|
||||
assetRef,
|
||||
key: ValueKey(assetRef),
|
||||
key: ValueKey<String>(assetRef),
|
||||
width: size.width,
|
||||
height: size.height,
|
||||
fit: fit!,
|
||||
@@ -183,9 +183,9 @@ class AstromicImage extends StatelessWidget {
|
||||
|
||||
Widget buildImage(Size size) {
|
||||
return Stack(
|
||||
children: [
|
||||
children: <Widget>[
|
||||
OctoImage(
|
||||
key: ValueKey(assetType == _DeclaredAssetType.bytes ? (assetRef as Uint8List).length.toString() : assetRef),
|
||||
key: ValueKey<String>(assetType == _DeclaredAssetType.bytes ? (assetRef as Uint8List).length.toString() : assetRef),
|
||||
//
|
||||
width: size.width,
|
||||
height: size.height,
|
||||
@@ -195,8 +195,8 @@ class AstromicImage extends StatelessWidget {
|
||||
color: svgColor,
|
||||
colorBlendMode: blendMode ?? (isSVG ? BlendMode.srcATop : null),
|
||||
//
|
||||
errorBuilder: (context, error, stackTrace) {
|
||||
debugPrint("AstromicImage Error: $error");
|
||||
errorBuilder: (BuildContext context, Object error, StackTrace? stackTrace) {
|
||||
debugPrint('AstromicImage Error: $error');
|
||||
return errorWidget != null
|
||||
? errorWidget!(error, stackTrace)
|
||||
: assetFallback != null
|
||||
@@ -204,15 +204,15 @@ class AstromicImage extends StatelessWidget {
|
||||
: defaultErrorWidget(error);
|
||||
},
|
||||
//
|
||||
progressIndicatorBuilder: (_, bytes) => SizedBox(
|
||||
progressIndicatorBuilder: (_, ImageChunkEvent? bytes) => SizedBox(
|
||||
width: size.width,
|
||||
height: size.height,
|
||||
child: loadingWidget != null ? loadingWidget!(bytes?.cumulativeBytesLoaded, bytes?.expectedTotalBytes) : defaultLoadingWidget,
|
||||
),
|
||||
placeholderBuilder: (context) => loadingWidget != null ? loadingWidget!(null, null) : defaultLoadingWidget,
|
||||
placeholderBuilder: (BuildContext context) => loadingWidget != null ? loadingWidget!(null, null) : defaultLoadingWidget,
|
||||
fadeInCurve: fadeInCurve,
|
||||
fadeInDuration: fadeInDuration,
|
||||
imageBuilder: (context, image) => Container(
|
||||
imageBuilder: (BuildContext context, Widget image) => Container(
|
||||
width: size.width,
|
||||
height: size.height,
|
||||
padding: borderPadding ?? EdgeInsets.zero,
|
||||
@@ -220,7 +220,6 @@ class AstromicImage extends StatelessWidget {
|
||||
decoration: BoxDecoration(
|
||||
border: borderWidth != null
|
||||
? Border.all(
|
||||
strokeAlign: BorderSide.strokeAlignInside,
|
||||
width: borderWidth!,
|
||||
color: borderColor ?? const Color(0xff000000),
|
||||
)
|
||||
@@ -250,7 +249,7 @@ class AstromicImage extends StatelessWidget {
|
||||
//!SECTION
|
||||
|
||||
//SECTION - Build Return
|
||||
return LayoutBuilder(builder: (context, constraints) {
|
||||
return LayoutBuilder(builder: (BuildContext context, BoxConstraints constraints) {
|
||||
Size size = _calculateSize(constraints);
|
||||
return SizedBox(width: size.width, height: size.height, child: buildImage(size));
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user