refactor(mobile): Use switch expression when possible (#15852)

refactor: Use `switch` expression when possible

Co-authored-by: Alex <alex.tran1502@gmail.com>
This commit is contained in:
Damiano Ferrari 2025-02-02 22:46:46 +01:00 committed by GitHub
parent 4efacfbb91
commit 96a6cc20b7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
17 changed files with 219 additions and 374 deletions

View file

@ -220,23 +220,20 @@ class NetworkStatusIcon extends StatelessWidget {
);
}
Widget _buildIcon(BuildContext context) {
switch (status) {
case AuxCheckStatus.loading:
return Padding(
padding: const EdgeInsets.only(left: 4.0),
child: SizedBox(
width: 18,
height: 18,
child: CircularProgressIndicator(
color: context.primaryColor,
strokeWidth: 2,
key: const ValueKey('loading'),
Widget _buildIcon(BuildContext context) => switch (status) {
AuxCheckStatus.loading => Padding(
padding: const EdgeInsets.only(left: 4.0),
child: SizedBox(
width: 18,
height: 18,
child: CircularProgressIndicator(
color: context.primaryColor,
strokeWidth: 2,
key: const ValueKey('loading'),
),
),
),
);
case AuxCheckStatus.valid:
return enabled
AuxCheckStatus.valid => enabled
? const Icon(
Icons.check_circle_rounded,
color: Colors.green,
@ -246,9 +243,8 @@ class NetworkStatusIcon extends StatelessWidget {
Icons.check_circle_rounded,
color: context.colorScheme.onSurface.withAlpha(100),
key: const ValueKey('success'),
);
case AuxCheckStatus.error:
return enabled
),
AuxCheckStatus.error => enabled
? const Icon(
Icons.error_rounded,
color: Colors.red,
@ -258,9 +254,7 @@ class NetworkStatusIcon extends StatelessWidget {
Icons.error_rounded,
color: Colors.grey,
key: ValueKey('error'),
);
default:
return const Icon(Icons.circle_outlined, key: ValueKey('unknown'));
}
}
),
_ => const Icon(Icons.circle_outlined, key: ValueKey('unknown')),
};
}