[M3] Update checkbox shape value (#120976)
* update m3 values * update test formatting * update crswap * update test * update token value * update tests
This commit is contained in:
parent
8d305b605e
commit
ae8d05184e
@ -110,6 +110,11 @@ class _${blockName}DefaultsM3 extends CheckboxThemeData {
|
||||
|
||||
@override
|
||||
VisualDensity get visualDensity => _theme.visualDensity;
|
||||
|
||||
@override
|
||||
OutlinedBorder get shape => RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(${tokens['md.comp.checkbox.unselected.outline.width']}),
|
||||
);
|
||||
}
|
||||
''';
|
||||
}
|
||||
|
@ -305,7 +305,7 @@ class Checkbox extends StatefulWidget {
|
||||
///
|
||||
/// If this property is null then [CheckboxThemeData.shape] of [ThemeData.checkboxTheme]
|
||||
/// is used. If that's null then the shape will be a [RoundedRectangleBorder]
|
||||
/// with a circular corner radius of 1.0.
|
||||
/// with a circular corner radius of 1.0 in Material 2, and 2.0 in Material 3.
|
||||
final OutlinedBorder? shape;
|
||||
|
||||
/// {@template flutter.material.checkbox.side}
|
||||
@ -522,9 +522,7 @@ class _CheckboxState extends State<Checkbox> with TickerProviderStateMixin, Togg
|
||||
..checkColor = effectiveCheckColor
|
||||
..value = value
|
||||
..previousValue = _previousValue
|
||||
..shape = widget.shape ?? checkboxTheme.shape ?? const RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.all(Radius.circular(1.0)),
|
||||
)
|
||||
..shape = widget.shape ?? checkboxTheme.shape ?? defaults.shape!
|
||||
..side = _resolveSide(widget.side) ?? _resolveSide(checkboxTheme.side),
|
||||
),
|
||||
);
|
||||
@ -759,6 +757,11 @@ class _CheckboxDefaultsM2 extends CheckboxThemeData {
|
||||
|
||||
@override
|
||||
VisualDensity get visualDensity => _theme.visualDensity;
|
||||
|
||||
@override
|
||||
OutlinedBorder get shape => const RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.all(Radius.circular(1.0)),
|
||||
);
|
||||
}
|
||||
|
||||
// BEGIN GENERATED TOKEN PROPERTIES - Checkbox
|
||||
@ -869,6 +872,11 @@ class _CheckboxDefaultsM3 extends CheckboxThemeData {
|
||||
|
||||
@override
|
||||
VisualDensity get visualDensity => _theme.visualDensity;
|
||||
|
||||
@override
|
||||
OutlinedBorder get shape => RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(2.0),
|
||||
);
|
||||
}
|
||||
|
||||
// END GENERATED TOKEN PROPERTIES - Checkbox
|
||||
|
@ -1698,7 +1698,7 @@ void main() {
|
||||
paints
|
||||
..drrect(
|
||||
color: borderColor,
|
||||
outer: RRect.fromLTRBR(15, 15, 33, 33, const Radius.circular(1)),
|
||||
outer: RRect.fromLTRBR(15, 15, 33, 33, const Radius.circular(2)),
|
||||
inner: RRect.fromLTRBR(19, 19, 29, 29, Radius.zero),
|
||||
),
|
||||
);
|
||||
@ -1735,6 +1735,41 @@ void main() {
|
||||
await gestureLongPress.up();
|
||||
await tester.pump();
|
||||
});
|
||||
|
||||
testWidgets('Checkbox has correct default shape - M3', (WidgetTester tester) async {
|
||||
final ThemeData themeData = ThemeData(useMaterial3: true);
|
||||
|
||||
Widget buildApp() {
|
||||
return MaterialApp(
|
||||
theme: themeData,
|
||||
home: Material(
|
||||
child: Center(
|
||||
child: StatefulBuilder(builder: (BuildContext context, StateSetter setState) {
|
||||
return Checkbox(
|
||||
value: false,
|
||||
onChanged: (bool? newValue) {},
|
||||
|
||||
);
|
||||
}),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
await tester.pumpWidget(buildApp());
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
final OutlinedBorder? expectedShape = themeData.checkboxTheme.shape;
|
||||
expect(tester.widget<Checkbox>(find.byType(Checkbox)).shape, expectedShape);
|
||||
expect(
|
||||
Material.of(tester.element(find.byType(Checkbox))),
|
||||
paints
|
||||
..drrect(
|
||||
outer: RRect.fromLTRBR(15.0, 15.0, 33.0, 33.0, const Radius.circular(2)),
|
||||
inner: RRect.fromLTRBR(17.0, 17.0, 31.0, 31.0, Radius.zero),
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
class _SelectedGrabMouseCursor extends MaterialStateMouseCursor {
|
||||
|
Loading…
x
Reference in New Issue
Block a user