Apply segment label colour changes to the painted text

A colour-only style change (selected, unselected or disabled) only
scheduled a repaint, but the text painter takes its style during
layout, so the label kept its old colour until something else caused a
layout. Request layout for every style change.
This commit is contained in:
zjs81 committed 2026-11-09 21:27:17 -07:00
1 parent 6daa85edae
commit b276b9daf3
2 files changed
+28 -3

No files matched your search

+22
View File
@@ -54,4 +54,26 @@ void main() {
expect(box.size.width, lessThanOrEqualTo(parent.size.width));
}
});
testWidgets('a colour-only style change reaches the painted text', (
tester,
) async {
Widget label(Color color) => MaterialApp(
home: Center(
child: DefaultTextStyle(
style: TextStyle(fontSize: 14, color: color),
child: const MeshSegmentLabel('Flood'),
),
),
);
Color? painted() =>
(tester.renderObject(find.byType(MeshSegmentLabel)) as dynamic)
.debugPaintedColor
as Color?;
await tester.pumpWidget(label(const Color(0xFF112233)));
expect(painted(), const Color(0xFF112233));
await tester.pumpWidget(label(const Color(0xFFEEDDCC)));
expect(painted(), const Color(0xFFEEDDCC));
});
}