refactor: del unused or dead code and optimize reusable code

This commit is contained in:
csf
2022-09-13 21:36:38 +08:00
parent d3eac8539d
commit a28fd5d772
10 changed files with 259 additions and 974 deletions

View File

@@ -99,7 +99,7 @@ class _PeerCardState extends State<_PeerCard>
color: str2color('${peer.id}${peer.platform}', 0x7f),
),
alignment: Alignment.center,
child: _getPlatformImage('${peer.platform}', 30).paddingAll(6),
child: getPlatformImage(peer.platform, size: 30).paddingAll(6),
),
Expanded(
child: Container(
@@ -196,7 +196,8 @@ class _PeerCardState extends State<_PeerCard>
children: [
Container(
padding: const EdgeInsets.all(6),
child: _getPlatformImage(peer.platform, 60),
child:
getPlatformImage(peer.platform, size: 60),
),
Row(
children: [
@@ -287,17 +288,6 @@ class _PeerCardState extends State<_PeerCard>
);
}
/// Get the image for the current [platform].
Widget _getPlatformImage(String platform, double size) {
platform = platform.toLowerCase();
if (platform == 'mac os') {
platform = 'mac';
} else if (platform != 'linux' && platform != 'android') {
platform = 'win';
}
return Image.asset('assets/$platform.png', height: size, width: size);
}
@override
bool get wantKeepAlive => true;
}