🎨 Use SizedBox.shrink instead of empty SizedBox for placeholder

This commit is contained in:
2024-09-07 17:48:07 +08:00
parent 85f97521e5
commit 4e8f2ddef3
20 changed files with 37 additions and 36 deletions

View File

@ -347,7 +347,8 @@ class _AttachmentEditorPopupState extends State<AttachmentEditorPopup> {
FutureBuilder(
future: element.file.length(),
builder: (context, snapshot) {
if (!snapshot.hasData) return const SizedBox();
if (!snapshot.hasData)
return const SizedBox.shrink();
return Text(
_formatBytes(snapshot.data!),
style: Theme.of(context).textTheme.bodySmall,
@ -628,7 +629,7 @@ class _AttachmentEditorPopupState extends State<AttachmentEditorPopup> {
),
);
}
return const SizedBox();
return const SizedBox.shrink();
}),
],
),
@ -667,7 +668,7 @@ class _AttachmentEditorPopupState extends State<AttachmentEditorPopup> {
),
Obx(() {
if (_uploadController.isUploading.value) {
return const SizedBox();
return const SizedBox.shrink();
}
return TextButton(
child: Text('attachmentUploadQueueStart'.tr),
@ -681,7 +682,7 @@ class _AttachmentEditorPopupState extends State<AttachmentEditorPopup> {
),
);
}
return const SliverToBoxAdapter(child: SizedBox());
return const SliverToBoxAdapter(child: SizedBox.shrink());
}),
Obx(() {
if (_uploadController.queueOfUpload.isNotEmpty) {
@ -697,7 +698,7 @@ class _AttachmentEditorPopupState extends State<AttachmentEditorPopup> {
),
);
}
return const SliverToBoxAdapter(child: SizedBox());
return const SliverToBoxAdapter(child: SizedBox.shrink());
}),
if (_attachments.isNotEmpty)
SliverPadding(

View File

@ -139,7 +139,7 @@ class _AttachmentListState extends State<AttachmentList> {
@override
Widget build(BuildContext context) {
if (widget.attachmentsId.isEmpty) {
return const SizedBox();
return const SizedBox.shrink();
}
if (_isLoading) {
@ -172,7 +172,7 @@ class _AttachmentListState extends State<AttachmentList> {
children: widget.attachmentsId.map((x) {
final element = _attachmentsMeta[idx];
idx++;
if (element == null) return const SizedBox();
if (element == null) return const SizedBox.shrink();
double ratio = element.metadata?['ratio']?.toDouble() ?? 16 / 9;
return Container(
decoration: BoxDecoration(