mirror of
https://github.com/krille-chan/fluffychat
synced 2024-09-10 11:45:10 +00:00
treewide: Container -> SizedBox.shrink()
This helps performance without any user-facing changes, since SizedBox is constant while Container isn't
This commit is contained in:
parent
f88837232b
commit
ab0b7cb6b9
21 changed files with 31 additions and 31 deletions
|
@ -17,7 +17,7 @@ class ChatAppBarTitle extends StatelessWidget {
|
|||
Widget build(BuildContext context) {
|
||||
final room = controller.room;
|
||||
if (room == null) {
|
||||
return Container();
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
if (controller.selectedEvents.isNotEmpty) {
|
||||
return Text(controller.selectedEvents.length.toString());
|
||||
|
|
|
@ -91,7 +91,7 @@ class ChatEventList extends StatelessWidget {
|
|||
),
|
||||
);
|
||||
}
|
||||
return Container();
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
|
||||
// The message at this index:
|
||||
|
@ -127,7 +127,7 @@ class ChatEventList extends StatelessWidget {
|
|||
? controller.timeline!.events[i]
|
||||
: null,
|
||||
)
|
||||
: Container(),
|
||||
: const SizedBox.shrink(),
|
||||
);
|
||||
},
|
||||
childCount: controller.timeline!.events.length + 2,
|
||||
|
|
|
@ -23,7 +23,7 @@ class ChatInputRow extends StatelessWidget {
|
|||
Widget build(BuildContext context) {
|
||||
if (controller.showEmojiPicker &&
|
||||
controller.emojiPickerType == EmojiPickerType.reaction) {
|
||||
return Container();
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
return Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
|
@ -72,7 +72,7 @@ class ChatInputRow extends StatelessWidget {
|
|||
),
|
||||
),
|
||||
)
|
||||
: Container(),
|
||||
: const SizedBox.shrink(),
|
||||
]
|
||||
: <Widget>[
|
||||
KeyBoardShortcuts(
|
||||
|
|
|
@ -54,7 +54,7 @@ class Message extends StatelessWidget {
|
|||
EventTypes.CallInvite
|
||||
}.contains(event.type)) {
|
||||
if (event.type.startsWith('m.call.')) {
|
||||
return Container();
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
return StateMessage(event);
|
||||
}
|
||||
|
|
|
@ -313,7 +313,7 @@ class InputBar extends StatelessWidget {
|
|||
),
|
||||
);
|
||||
}
|
||||
return Container();
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
|
||||
void insertSuggestion(_, Map<String, String?> suggestion) {
|
||||
|
@ -458,11 +458,11 @@ class InputBar extends StatelessWidget {
|
|||
buildSuggestion(c, s, Matrix.of(context).client),
|
||||
onSuggestionSelected: (Map<String, String?> suggestion) =>
|
||||
insertSuggestion(context, suggestion),
|
||||
errorBuilder: (BuildContext context, Object? error) => Container(),
|
||||
loadingBuilder: (BuildContext context) => Container(),
|
||||
errorBuilder: (BuildContext context, Object? error) => const SizedBox.shrink(),
|
||||
loadingBuilder: (BuildContext context) => const SizedBox.shrink(),
|
||||
// fix loading briefly flickering a dark box
|
||||
noItemsFoundBuilder: (BuildContext context) =>
|
||||
Container(), // fix loading briefly showing no suggestions
|
||||
const SizedBox.shrink(), // fix loading briefly showing no suggestions
|
||||
),
|
||||
),
|
||||
);
|
||||
|
|
|
@ -49,7 +49,7 @@ class PinnedEvents extends StatelessWidget {
|
|||
final pinnedEventIds = controller.room!.pinnedEventIds;
|
||||
|
||||
if (pinnedEventIds.isEmpty) {
|
||||
return Container();
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
final completers = pinnedEventIds.map<Completer<Event?>>((e) {
|
||||
final completer = Completer<Event?>();
|
||||
|
|
|
@ -15,7 +15,7 @@ class ReactionsPicker extends StatelessWidget {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (controller.showEmojiPicker) return Container();
|
||||
if (controller.showEmojiPicker) return const SizedBox.shrink();
|
||||
final display = controller.editEvent == null &&
|
||||
controller.replyEvent == null &&
|
||||
controller.room!.canSendDefaultMessages &&
|
||||
|
@ -29,7 +29,7 @@ class ReactionsPicker extends StatelessWidget {
|
|||
child: Builder(
|
||||
builder: (context) {
|
||||
if (!display) {
|
||||
return Container();
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
final proposals = proposeEmojis(
|
||||
controller.selectedEvents.first.plaintextBody,
|
||||
|
|
|
@ -58,7 +58,7 @@ class _EditContent extends StatelessWidget {
|
|||
Widget build(BuildContext context) {
|
||||
final event = this.event;
|
||||
if (event == null) {
|
||||
return Container();
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
return Row(
|
||||
children: <Widget>[
|
||||
|
|
|
@ -39,7 +39,7 @@ class StickerPickerDialogState extends State<StickerPickerDialog> {
|
|||
final imageKeys =
|
||||
filteredImagePackImageEntried.map((e) => e.key).toList();
|
||||
if (imageKeys.isEmpty) {
|
||||
return Container();
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
final packName = pack.pack.displayName ?? packSlugs[packIndex];
|
||||
return Column(
|
||||
|
|
|
@ -12,7 +12,7 @@ class TombstoneDisplay extends StatelessWidget {
|
|||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (controller.room!.getState(EventTypes.RoomTombstone) == null) {
|
||||
return Container();
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
return SizedBox(
|
||||
height: 72,
|
||||
|
|
|
@ -409,7 +409,7 @@ class ChatDetailsView extends StatelessWidget {
|
|||
),
|
||||
onTap: () => VRouter.of(context).to('invite'),
|
||||
)
|
||||
: Container(),
|
||||
: const SizedBox.shrink(),
|
||||
],
|
||||
)
|
||||
: i < controller.members!.length + 1
|
||||
|
|
|
@ -62,7 +62,7 @@ class ParticipantListItem extends StatelessWidget {
|
|||
),
|
||||
),
|
||||
membershipBatch[user.membership]!.isEmpty
|
||||
? Container()
|
||||
? const SizedBox.shrink()
|
||||
: Container(
|
||||
padding: const EdgeInsets.all(4),
|
||||
margin: const EdgeInsets.symmetric(horizontal: 8),
|
||||
|
|
|
@ -227,7 +227,7 @@ class ChatListViewBody extends StatelessWidget {
|
|||
.contains(
|
||||
controller.searchController.text.toLowerCase(),
|
||||
)) {
|
||||
return Container();
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
return ChatListItem(
|
||||
rooms[i],
|
||||
|
|
|
@ -326,7 +326,7 @@ class ChatListItem extends StatelessWidget {
|
|||
fontSize: 13,
|
||||
),
|
||||
)
|
||||
: Container(),
|
||||
: const SizedBox.shrink(),
|
||||
),
|
||||
),
|
||||
],
|
||||
|
|
|
@ -189,7 +189,7 @@ class ClientChooserButton extends StatelessWidget {
|
|||
index,
|
||||
context,
|
||||
),
|
||||
child: Container(),
|
||||
child: const SizedBox.shrink(),
|
||||
),
|
||||
),
|
||||
KeyBoardShortcuts(
|
||||
|
@ -199,7 +199,7 @@ class ClientChooserButton extends StatelessWidget {
|
|||
},
|
||||
helpLabel: L10n.of(context)!.nextAccount,
|
||||
onKeysPressed: () => _nextAccount(matrix, context),
|
||||
child: Container(),
|
||||
child: const SizedBox.shrink(),
|
||||
),
|
||||
KeyBoardShortcuts(
|
||||
keysToPress: {
|
||||
|
@ -209,7 +209,7 @@ class ClientChooserButton extends StatelessWidget {
|
|||
},
|
||||
helpLabel: L10n.of(context)!.previousAccount,
|
||||
onKeysPressed: () => _previousAccount(matrix, context),
|
||||
child: Container(),
|
||||
child: const SizedBox.shrink(),
|
||||
),
|
||||
PopupMenuButton<Object>(
|
||||
onSelected: (o) => _clientSelected(o, context),
|
||||
|
|
|
@ -121,7 +121,7 @@ class StoriesHeader extends StatelessWidget {
|
|||
final displayname = creator.calcDisplayname();
|
||||
final avatarUrl = creator.avatarUrl;
|
||||
if (!displayname.toLowerCase().contains(filter.toLowerCase())) {
|
||||
return Container();
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
return _StoryButton(
|
||||
profile: Profile(
|
||||
|
|
|
@ -107,7 +107,7 @@ class EmotesSettingsView extends StatelessWidget {
|
|||
)
|
||||
: ListView.separated(
|
||||
separatorBuilder: (BuildContext context, int i) =>
|
||||
Container(),
|
||||
const SizedBox.shrink(),
|
||||
itemCount: imageKeys.length + 1,
|
||||
itemBuilder: (BuildContext context, int i) {
|
||||
if (i >= imageKeys.length) {
|
||||
|
|
|
@ -35,7 +35,7 @@ class MultipleEmotesSettingsView extends StatelessWidget {
|
|||
final keys = packs.keys.toList();
|
||||
keys.sort();
|
||||
return ListView.separated(
|
||||
separatorBuilder: (BuildContext context, int i) => Container(),
|
||||
separatorBuilder: (BuildContext context, int i) => const SizedBox.shrink(),
|
||||
itemCount: keys.length,
|
||||
itemBuilder: (BuildContext context, int i) {
|
||||
final event = packs[keys[i]];
|
||||
|
|
|
@ -207,7 +207,7 @@ class StoryView extends StatelessWidget {
|
|||
final videoPlayerController = snapshot.data;
|
||||
if (videoPlayerController == null) {
|
||||
controller.loadingModeOn();
|
||||
return Container();
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
controller.loadingModeOff();
|
||||
return Center(child: VideoPlayer(videoPlayerController));
|
||||
|
@ -226,7 +226,7 @@ class StoryView extends StatelessWidget {
|
|||
final matrixFile = snapshot.data;
|
||||
if (matrixFile == null) {
|
||||
controller.loadingModeOn();
|
||||
return Container();
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
controller.loadingModeOff();
|
||||
return Container(
|
||||
|
|
|
@ -115,7 +115,7 @@ class ChatSettingsPopupMenuState extends State<ChatSettingsPopupMenu> {
|
|||
},
|
||||
helpLabel: L10n.of(context)!.chatDetails,
|
||||
onKeysPressed: _showChatDetails,
|
||||
child: Container(),
|
||||
child: const SizedBox.shrink(),
|
||||
),
|
||||
KeyBoardShortcuts(
|
||||
keysToPress: {
|
||||
|
@ -124,7 +124,7 @@ class ChatSettingsPopupMenuState extends State<ChatSettingsPopupMenu> {
|
|||
},
|
||||
helpLabel: L10n.of(context)!.matrixWidgets,
|
||||
onKeysPressed: _showWidgets,
|
||||
child: Container(),
|
||||
child: const SizedBox.shrink(),
|
||||
),
|
||||
PopupMenuButton(
|
||||
onSelected: (String choice) async {
|
||||
|
|
|
@ -163,7 +163,7 @@ class _MxcImageState extends State<MxcImage> {
|
|||
data == null ? CrossFadeState.showFirst : CrossFadeState.showSecond,
|
||||
firstChild: placeholder(context),
|
||||
secondChild: data == null || data.isEmpty
|
||||
? Container()
|
||||
? const SizedBox.shrink()
|
||||
: Image.memory(
|
||||
data,
|
||||
width: widget.width,
|
||||
|
|
Loading…
Reference in a new issue