refactor: Update CakeImageWidget to allow nullable BoxFit (#2326)

This commit is contained in:
David Adegoke 2025-06-17 21:24:18 +01:00 committed by GitHub
parent 65402ba1eb
commit c6cb48096d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 5 additions and 8 deletions

View file

@ -1,6 +1,5 @@
import 'package:cake_wallet/src/widgets/cake_image_widget.dart'; import 'package:cake_wallet/src/widgets/cake_image_widget.dart';
import 'package:cake_wallet/src/widgets/scollable_with_bottom_section.dart'; import 'package:cake_wallet/src/widgets/scollable_with_bottom_section.dart';
import 'package:cake_wallet/themes/core/material_base_theme.dart';
import 'package:cake_wallet/utils/responsive_layout_util.dart'; import 'package:cake_wallet/utils/responsive_layout_util.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:cake_wallet/routes.dart'; import 'package:cake_wallet/routes.dart';

View file

@ -7,7 +7,7 @@ class CakeImageWidget extends StatelessWidget {
this.imageUrl, this.imageUrl,
this.height, this.height,
this.width, this.width,
this.fit = BoxFit.cover, this.fit,
this.loadingWidget, this.loadingWidget,
this.errorWidget, this.errorWidget,
this.color, this.color,
@ -16,7 +16,7 @@ class CakeImageWidget extends StatelessWidget {
final String? imageUrl; final String? imageUrl;
final double? height; final double? height;
final double? width; final double? width;
final BoxFit fit; final BoxFit? fit;
final Widget? loadingWidget; final Widget? loadingWidget;
final Widget? errorWidget; final Widget? errorWidget;
final Color? color; final Color? color;
@ -37,8 +37,7 @@ class CakeImageWidget extends StatelessWidget {
imageUrl!, imageUrl!,
height: height, height: height,
width: width, width: width,
fit: fit, fit: fit ?? BoxFit.contain,
color: color,
) )
: Image.asset( : Image.asset(
imageUrl!, imageUrl!,
@ -53,8 +52,7 @@ class CakeImageWidget extends StatelessWidget {
imageUrl!, imageUrl!,
height: height, height: height,
width: width, width: width,
fit: fit, fit: fit ?? BoxFit.contain,
color: color,
placeholderBuilder: (_) { placeholderBuilder: (_) {
return loadingWidget ?? const Center(child: CircularProgressIndicator()); return loadingWidget ?? const Center(child: CircularProgressIndicator());
}, },
@ -64,7 +62,7 @@ class CakeImageWidget extends StatelessWidget {
imageUrl!, imageUrl!,
height: height, height: height,
width: width, width: width,
fit: fit, fit: fit ?? BoxFit.cover,
color: color, color: color,
loadingBuilder: (_, Widget child, ImageChunkEvent? progress) { loadingBuilder: (_, Widget child, ImageChunkEvent? progress) {
if (progress == null) return child; if (progress == null) return child;