Refactor: Reduce .of(context) calls theme

Signed commit
This commit is contained in:
Thomas Klein Langenhorst 2024-08-04 14:09:36 +02:00
commit 5d2aaef3ca
No known key found for this signature in database
GPG key ID: CA868C3CB279DA5B
69 changed files with 525 additions and 501 deletions

View file

@ -35,6 +35,8 @@ class Avatar extends StatelessWidget {
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
var fallbackLetters = '@';
final name = this.name;
if (name != null) {
@ -68,7 +70,7 @@ class Avatar extends StatelessWidget {
width: size,
height: size,
child: Material(
color: Theme.of(context).brightness == Brightness.light
color: theme.brightness == Brightness.light
? Colors.white
: Colors.black,
shape: RoundedRectangleBorder(
@ -89,7 +91,7 @@ class Avatar extends StatelessWidget {
placeholder: (_) => Center(
child: Icon(
Icons.person_2,
color: Theme.of(context).colorScheme.tertiary,
color: theme.colorScheme.tertiary,
size: size / 1.5,
),
),
@ -118,8 +120,7 @@ class Avatar extends StatelessWidget {
width: 16,
height: 16,
decoration: BoxDecoration(
color: presenceBackgroundColor ??
Theme.of(context).colorScheme.surface,
color: presenceBackgroundColor ?? theme.colorScheme.surface,
borderRadius: BorderRadius.circular(32),
),
alignment: Alignment.center,
@ -131,7 +132,7 @@ class Avatar extends StatelessWidget {
borderRadius: BorderRadius.circular(16),
border: Border.all(
width: 1,
color: Theme.of(context).colorScheme.surface,
color: theme.colorScheme.surface,
),
),
),