🎨 Use SizedBox.shrink instead of empty SizedBox for placeholder

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

View File

@ -109,7 +109,7 @@ class SolianApp extends StatelessWidget {
return SystemShell(
child: ScaffoldMessenger(
child: BootstrapperShell(
child: child ?? const SizedBox(),
child: child ?? const SizedBox.shrink(),
),
),
);

View File

@ -36,7 +36,7 @@ class AboutScreen extends StatelessWidget {
future: PackageInfo.fromPlatform(),
builder: (context, snapshot) {
if (!snapshot.hasData) {
return const SizedBox();
return const SizedBox.shrink();
}
return Text(

View File

@ -84,7 +84,7 @@ class _CallScreenState extends State<CallScreen> with TickerProviderStateMixin {
participant: call.focusTrack.value!,
onTap: () {},
)
: const SizedBox(),
: const SizedBox.shrink(),
),
Positioned(
left: 0,

View File

@ -222,7 +222,7 @@ class _ChannelChatScreenState extends State<ChannelChatScreen>
actions: [
const BackgroundStateWidget(),
Builder(builder: (context) {
if (_isBusy || _channel == null) return const SizedBox();
if (_isBusy || _channel == null) return const SizedBox.shrink();
return ChatCallButton(
realm: _channel!.realm,
@ -299,7 +299,7 @@ class _ChannelChatScreenState extends State<ChannelChatScreen>
if (_chatController.isLoading.isTrue) {
return const LinearProgressIndicator().animate().slideY();
} else {
return const SizedBox();
return const SizedBox.shrink();
}
}),
ClipRect(
@ -350,7 +350,7 @@ class _ChannelChatScreenState extends State<ChannelChatScreen>
]),
);
}
return const SizedBox();
return const SizedBox.shrink();
}),
],
);

View File

@ -112,7 +112,7 @@ class _ChatScreenState extends State<ChatScreen> {
children: [
Obx(() {
if (_channels.isLoading.isFalse) {
return const SizedBox();
return const SizedBox.shrink();
} else {
return const LinearProgressIndicator();
}

View File

@ -190,7 +190,7 @@ class _DashboardScreenState extends State<DashboardScreen> {
icon: const Icon(Icons.local_fire_department),
onPressed: _signingDaily ? null : _signDaily,
)
: const SizedBox(),
: const SizedBox.shrink(),
),
),
).paddingSymmetric(horizontal: 8),

View File

@ -155,7 +155,7 @@ class PostCreatePopup extends StatelessWidget {
final AuthProvider auth = Get.find();
if (auth.isAuthorized.isFalse) {
return const SizedBox();
return const SizedBox.shrink();
}
final List<dynamic> actionList = [

View File

@ -45,7 +45,7 @@ class _AccountBadgeWidgetState extends State<AccountBadgeWidget> {
Widget build(BuildContext context) {
final spec = badges[widget.item.type];
if (spec == null) return const SizedBox();
if (spec == null) return const SizedBox.shrink();
return Tooltip(
richMessage: TextSpan(

View File

@ -71,7 +71,7 @@ class AccountHeadingWidget extends StatelessWidget {
content: banner,
fit: BoxFit.cover,
)
: const SizedBox(),
: const SizedBox.shrink(),
),
),
).paddingSymmetric(horizontal: 16),

View File

@ -22,7 +22,7 @@ class AppBarLeadingButton extends StatelessWidget {
onPressed: () => rootScaffoldKey.currentState!.openDrawer(),
);
} else {
return const SizedBox();
return const SizedBox.shrink();
}
}
}

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(

View File

@ -64,7 +64,7 @@ class ChannelCallIndicator extends StatelessWidget {
const Gap(6),
Obx(() {
if (call.isInitialized.value) {
return const SizedBox();
return const SizedBox.shrink();
}
if (ongoingCall.participants.isNotEmpty) {
return Container(
@ -84,7 +84,7 @@ class ChannelCallIndicator extends StatelessWidget {
),
);
}
return const SizedBox();
return const SizedBox.shrink();
})
],
),
@ -113,7 +113,7 @@ class ChannelCallIndicator extends StatelessWidget {
child: Text('callJoin'.tr),
);
}
return const SizedBox();
return const SizedBox.shrink();
})
],
);

View File

@ -11,7 +11,7 @@ class ChatCallCurrentIndicator extends StatelessWidget {
return Obx(() {
if (call.current.value == null || call.channel.value == null) {
return const SizedBox();
return const SizedBox.shrink();
}
return ListTile(

View File

@ -40,7 +40,7 @@ class ChatEvent extends StatelessWidget {
}
Widget _buildLinkExpansion() {
if (item.body['text'] == null) return const SizedBox();
if (item.body['text'] == null) return const SizedBox.shrink();
return LinkExpansion(content: item.body['text']);
}
@ -49,7 +49,7 @@ class ChatEvent extends StatelessWidget {
? List<String>.from(item.body['attachments']?.whereType<String>())
: List<String>.empty();
if (attachments.isEmpty) return const SizedBox();
if (attachments.isEmpty) return const SizedBox.shrink();
if (isMinimal) {
final unFocusColor =
@ -94,7 +94,7 @@ class ChatEvent extends StatelessWidget {
),
builder: (context, snapshot) {
if (!snapshot.hasData || snapshot.data == null) {
return const SizedBox();
return const SizedBox.shrink();
}
return Container(

View File

@ -96,7 +96,7 @@ class ChatEventList extends StatelessWidget {
chatController.totalEvents - chatController.currentEvents.length;
if (amount.value <= 0 || chatController.isLoading.isTrue) {
return const SliverToBoxAdapter(child: SizedBox());
return const SliverToBoxAdapter(child: SizedBox.shrink());
}
return SliverToBoxAdapter(

View File

@ -57,7 +57,7 @@ class LinkExpansion extends StatelessWidget {
);
final matches = linkRegex.allMatches(content);
if (matches.isEmpty) {
return const SizedBox();
return const SizedBox.shrink();
}
final LinkExpandProvider expandController = Get.find();
@ -72,7 +72,7 @@ class LinkExpansion extends StatelessWidget {
future: expandController.expandLink(x.group(0)!),
builder: (context, snapshot) {
if (!snapshot.hasData) {
return const SizedBox();
return const SizedBox.shrink();
}
final isRichDescription = [

View File

@ -59,7 +59,7 @@ class PostEditorVisibilityDialog extends StatelessWidget {
controller.visibility.value == 3) {
return const Gap(8);
}
return const SizedBox();
return const SizedBox.shrink();
}),
Obx(() {
if (controller.visibility.value == 2) {
@ -86,7 +86,7 @@ class PostEditorVisibilityDialog extends StatelessWidget {
},
);
}
return const SizedBox();
return const SizedBox.shrink();
}),
Obx(() {
if (controller.visibility.value == 3) {
@ -113,7 +113,7 @@ class PostEditorVisibilityDialog extends StatelessWidget {
},
);
}
return const SizedBox();
return const SizedBox.shrink();
}),
],
),

View File

@ -79,7 +79,7 @@ class _PostItemState extends State<PostItem> {
}
Widget _buildThumbnail() {
if (widget.item.body['thumbnail'] == null) return const SizedBox();
if (widget.item.body['thumbnail'] == null) return const SizedBox.shrink();
final border = BorderSide(
color: Theme.of(context).dividerColor,
width: 0.3,
@ -148,7 +148,7 @@ class _PostItemState extends State<PostItem> {
vertical: 8,
);
}
return const SizedBox();
return const SizedBox.shrink();
}
Widget _buildFooter() {
@ -187,7 +187,7 @@ class _PostItemState extends State<PostItem> {
}
if (widgets.isEmpty) {
return const SizedBox();
return const SizedBox.shrink();
} else {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,

View File

@ -29,7 +29,7 @@ class PostWarpedListWidget extends StatelessWidget {
builderDelegate: PagedChildBuilderDelegate<Post>(
itemBuilder: (context, item, index) {
if (item.pinnedAt != null && !isPinned) {
return const SizedBox();
return const SizedBox.shrink();
}
return PostListEntryWidget(
renderOrder: index,