我创建了一个小部件。这是一个卡片。整个卡片按列排列。在这个卡片中,两个图标(删除和勾选)需要并排放置。接下来,应该使用一个 SizedBox 作为分隔线(我也尝试过 Divider,但结果相同)。在这条分隔线之后,应该出现另一个大小合适的盒子,用于容纳后续内容。现在出现了一个问题,分隔线或大小合适的盒子没有显示,我不清楚错误出在哪里。小部件如下:
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
class TischCredentials extends ConsumerStatefulWidget {
const TischCredentials({super.key});
@override
ConsumerState<ConsumerStatefulWidget> createState() {
return _TischCredentialsState();
}
}
class _TischCredentialsState extends ConsumerState<TischCredentials> {
@override
Widget build(BuildContext context) {
//final tischIndex = ref.watch(tischProvider.notifier).state;
//tischIndexErhoehen(tischIndex);
return Card(
child: Column(
children: [
Row(
children: [
//Text("Tisch " + tischIndex.toString()),
IconButton(
icon: Icon(Icons.delete),
onPressed: () {},
),
IconButton(onPressed: () {}, icon: Icon(Icons.check)),
],
),
SizedBox(
height: 10,
child: Center(
child: Container(
margin: EdgeInsetsDirectional.only(start: 1.0, end: 1.0),
height: 5.0,
color: Colors.red,
),
),
),
SizedBox(
height: 100,
width: 200,
),
],
),
);
}
}
谢谢你的帮助。
看来你的分隔线没有宽度,你可以将它添加到容器中: