我正在尝试覆盖红色区域,并在滑块中填充图像。尝试过 fit: BoxFit.fill 但没有成功,有人能帮我解决这个问题吗?谢谢你的帮助,上帝保佑你,我不知道该发什么短信,它一直要求我发更多短信。
// ignore_for_file: public_member_api_docs, sort_constructors_first
import 'package:flutter/material.dart';
class HomeSliderItem extends StatelessWidget {
final bool isActive;
final String imageAssetPath;
const HomeSliderItem({
super.key,
required this.isActive,
required this.imageAssetPath,
});
@override
Widget build(BuildContext context) {
return FractionallySizedBox(
widthFactor: 20,
child: AnimatedScale(
duration: const Duration(milliseconds: 2500),
scale: isActive ? 1 : 1,
child: ClipRRect(
//borderRadius: BorderRadius.circular(0),
child: Stack(
children: [
Image.asset(imageAssetPath),
Container(
color: Colors.red,
),
Image.asset(imageAssetPath, fit: BoxFit.fill),
],
),
),
),
);
}
}
尝试以下代码并添加
width: double.infinity,
图像注意:只需用我的网络图像更改您的资产图像即可
输出屏幕