你好,有人可以帮我吗?我尝试编码(在图像上) 我不确定我是否应该在这里使用卡片盒或容器或任何其他小部件
import 'package:flutter/material.dart';
class AppHome extends StatefulWidget {
const AppHome({super.key});
@override
State<AppHome> createState() => _AppHomeState();
}
class _AppHomeState extends State<AppHome> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Center(child: Text('Cats')),
backgroundColor: Color(0xFF002804),
),
body: Container(
height: 300,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage('assets/images/1.jpg'),
fit: BoxFit.fill,
),
shape: BoxShape.rectangle,
),
));
}
}
我不明白你的意思,但如果你正在谈论制作类似的东西,你可以尝试这个:
Container(
decoration: BoxDecoration(
border: Border.all(color: Colors.black, width: 1)),
height: ...,
width: ...,
child: Column(
children: [
Image.asset('assets/images/1.jng'),
const Text('BROWN LIST'),
const Text('lorem ipsum dollar sit amet'),
],
),
))
或者,如果您正在谈论渲染的图像不合适,您可以只为容器添加宽度,例如:
Container(
height: 300,
width: 300,
...);