我遇到了一个小问题,这个问题肯定很容易解决,但我找不到任何解决方案.所有建议的subjetc都是关于自定义背景的. 以下是我的代码:
class HomeTest extends StatefulWidget {
const HomeTest({super.key});
@override
State<HomeTest> createState() => _HomeTestState();
}
class _HomeTestState extends State<HomeTest> {
final courantController = TextEditingController();
@override
Widget build(BuildContext context) {
final soldes = FirebaseFirestore.instance.collection('Soldes');
return Scaffold(
appBar: AppBar(title: const Text('Test')),
body: SingleChildScrollView(
child: Padding(
padding: const EdgeInsets.all(10),
child: Column(
children: [
const Text("text"),
const SizedBox(height: 20),
const Text(
'another text',
textAlign: TextAlign.center,
),
Container(
color: Colors.white,
height: 50,
),
const SizedBox(height: 10),
Container(
color: Colors.white,
height: 100,
child: Text('Container text')),
const AnnoyingList(),
],
),
),
));
}
}
class AnnoyingList extends StatefulWidget {
const AnnoyingList({super.key});
@override
State<AnnoyingList> createState() => _AnnoyingListState();
}
class _AnnoyingListState extends State<AnnoyingList> {
@override
Widget build(BuildContext context) {
return SizedBox(
height: 250,
child: ListView(children: [
ListTile(
tileColor: const Color.fromARGB(93, 88, 127, 158),
shape: RoundedRectangleBorder(
side: const BorderSide(width: 2),
borderRadius: BorderRadius.circular(50), //<-- SEE HERE
),
title: const Text('Tile 1'),
),
const SizedBox(height: 20),
ListTile(
tileColor: const Color.fromARGB(93, 88, 127, 158),
shape: RoundedRectangleBorder(
side: const BorderSide(width: 2),
borderRadius: BorderRadius.circular(50), //<-- SEE HERE
),
title: const Text('Tile 2'),
),
const SizedBox(height: 20),
ListTile(
tileColor: const Color.fromARGB(93, 88, 127, 158),
shape: RoundedRectangleBorder(
side: const BorderSide(width: 2),
borderRadius: BorderRadius.circular(50), //<-- SEE HERE
),
title: const Text('Tile 3'),
),
const SizedBox(height: 20),
ListTile(
tileColor: const Color.fromARGB(93, 88, 127, 158),
shape: RoundedRectangleBorder(
side: const BorderSide(width: 2),
borderRadius: BorderRadius.circular(50), //<-- SEE HERE
),
title: const Text('Tile 4'),
),
const SizedBox(height: 20),
ListTile(
tileColor: const Color.fromARGB(93, 88, 127, 158),
shape: RoundedRectangleBorder(
side: const BorderSide(width: 2),
borderRadius: BorderRadius.circular(50), //<-- SEE HERE
),
title: const Text('Tile 5'),
),
const SizedBox(height: 20),
ListTile(
tileColor: const Color.fromARGB(93, 88, 127, 158),
shape: RoundedRectangleBorder(
side: const BorderSide(width: 2),
borderRadius: BorderRadius.circular(50), //<-- SEE HERE
),
title: const Text('Tile 6'),
),
]),
);
}
}
问题是ListView位于SizedBox之外,并且在SizedBox之外是可见的.
在移动列表之前
在移动列表之后
正如你所看到的,我试图添加容器,但很明显,我一放东西在上面,它就会适应它的宽度.对于列表保留在SizedBox中有什么简单的解决方案吗? 看起来背景是透明的,但我没能通过改变应用程序的主题来解决这个问题… 谢谢!