这是我的代码
final City city;
CityCard(city, {super.key, dynamic id, String? name, String? imageUrl});
@override
Widget build(BuildContext context) {
return ClipRRect(
borderRadius: BorderRadius.circular(18),
child: Container(
height: 150,
width: 120,
color: Color(0xffF6F7F8),
child: Column(
children: [
Stack(
children: [
Image.asset(
city.imageUrl,
width: 120,
height: 102,
fit: BoxFit.cover,
),
city.isPopular
? Align(
alignment: Alignment.topRight,
child: Container(
width: 50,
height: 30,
decoration: BoxDecoration(
color: purpleColor,
borderRadius: BorderRadius.only(
bottomLeft: Radius.circular(36),
)),
child: Center(
child: Image.asset(
'assets/star.png',
width: 22,
height: 22,
),
),
),
)
: Container(),
],
),
const SizedBox(
height: 11,
),
Text(
city.name,
style: blackTextStyle.copyWith(
fontSize: 16,
),
),
],
),
),
);
}
}
字符串
我试着去弥补,但还是不能
final City city;
CityCard(dynamic? city, {super.key, dynamic id, String? name, String? imageUrl});
型
1条答案
按热度按时间yfjy0ee71#
对于您的情况,您需要使用
this.city
字符串