Refactor badge handling across components to use m3e colors, remove unused _SmallDot widget, and clean up redundant code.

This commit is contained in:
Emily Pauli 2025-10-23 14:45:16 +02:00
commit 05c489991a
6 changed files with 21 additions and 32 deletions

View file

@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:m3e_design/m3e_design.dart';
import 'enums.dart';
@ -44,6 +45,7 @@ class IconButtonM3E extends StatelessWidget {
@override
Widget build(BuildContext context) {
final scheme = Theme.of(context).colorScheme;
final m3e = context.m3e;
final Size visual = size.visual(width);
final Size target = size.target(width);
@ -133,19 +135,27 @@ class IconButtonM3E extends StatelessWidget {
badge = null;
} else if (v is num) {
final int c = v.round().clamp(0, 999999);
badge = Badge.count(
count: c,
backgroundColor: scheme.error,
textColor: scheme.onError,
);
if (c == 0) {
badge = Badge(
smallSize: 8,
backgroundColor: m3e.colors.primary,
textColor: m3e.colors.onPrimary,
);
} else {
badge = Badge.count(
count: c,
backgroundColor: m3e.colors.primary,
textColor: m3e.colors.onPrimary,
);
}
} else if (v is String) {
if (v.isEmpty) {
badge = null;
} else {
badge = Badge(
label: Text(v),
backgroundColor: scheme.error,
textColor: scheme.onError,
backgroundColor: m3e.colors.primary,
textColor: m3e.colors.onPrimary,
);
}
} else {

View file

@ -13,9 +13,10 @@ dependencies:
sdk: flutter
dev_dependencies:
flutter_lints: ^4.0.0
flutter_test:
sdk: flutter
flutter_lints: ^4.0.0
flutter:
uses-material-design: true