admin管理员组文章数量:1122832
I am trying to cover the red area, full with image in slider. Tried fit: BoxFit.fill but no luck, can someone help me with the problem. Thank you for your help god bless you i don't know what to text more it keep asking me to text more.
// 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),
],
),
),
),
);
}
}
I am trying to cover the red area, full with image in slider. Tried fit: BoxFit.fill but no luck, can someone help me with the problem. Thank you for your help god bless you i don't know what to text more it keep asking me to text more.
// 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),
],
),
),
),
);
}
}
Share
Improve this question
asked yesterday
melearningmelearning
351 silver badge2 bronze badges
1 Answer
Reset to default 1Try below code and add width: double.infinity,
for image
Note: just change your asset image with my network image
Stack(
children: [
Container(
color: Colors.red,
),
Image.network(
'https://images.pexels.com/photos/3225517/pexels-photo-3225517.jpeg?auto=compress&cs=tinysrgb&w=800',
fit: BoxFit.cover,
width: double.infinity,
),
],
),
Output Screen
本文标签: flutterBackground coverStack Overflow
版权声明:本文标题:flutter - Background cover - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736281557a1926358.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论