Skip to content

Commit

Permalink
Merge branch 'XCacheImage'
Browse files Browse the repository at this point in the history
  • Loading branch information
haolun committed Oct 24, 2023
2 parents db17112 + 17422d6 commit 6270765
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion lib/base_x.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ export 'api_service/index.dart';
export 'x_widget/index.dart' show XCachedImage, XPicker, showXPicker, XSkeleton;
export 'controller/index.dart' show XController, XLangController;

export 'package:get/get.dart' hide Response, FormData;
export 'package:get/get.dart' hide Response, FormData, MultipartFile;
18 changes: 11 additions & 7 deletions lib/x_widget/x_cached_image.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

import 'package:baseX/base_x.dart';
import 'package:cached_network_image/cached_network_image.dart';

import 'package:baseX/base_x.dart';

class XCachedImage extends StatefulWidget {
XCachedImage({
// Plugin properties
Expand All @@ -15,7 +16,7 @@ class XCachedImage extends StatefulWidget {
// Loader Color
this.loaderColor = CupertinoColors.activeBlue,
// Widget properties
this.borderRadius = 0,
@Deprecated('Use BoxDecaration instead') this.borderRadius = 0,
this.defaultBackground = const Color(0xFFE4E5E8),
this.aspectRatio,
// Error properties
Expand Down Expand Up @@ -107,6 +108,7 @@ class XCachedImage extends StatefulWidget {
// Loader Color
final Color loaderColor;
// Widget properties
@Deprecated('Use BoxDecaration instead')
final double borderRadius;
final Color defaultBackground;
final double? aspectRatio;
Expand Down Expand Up @@ -160,10 +162,7 @@ class XCachedImageState extends State<XCachedImage> {
return ClipOval(child: _image(boxConstraints: constraints));
},
)
: ClipRRect(
borderRadius: BorderRadius.circular(widget.borderRadius),
child: _image(),
);
: _image();
}

Widget _image({BoxConstraints? boxConstraints}) {
Expand All @@ -179,10 +178,15 @@ class XCachedImageState extends State<XCachedImage> {
height = widget.height;
width = widget.width;
}

return Container(
decoration: widget.boxDecoration,
decoration: widget.boxDecoration ??
BoxDecoration(
borderRadius: BorderRadius.circular(widget.borderRadius),
),
height: height,
width: width,
clipBehavior: Clip.antiAlias,
child: widget.aspectRatio == null
? _cachedImage()
: AspectRatio(
Expand Down

0 comments on commit 6270765

Please sign in to comment.