Added ButtonStyle.fixedSize (#74773)
This commit is contained in:
@@ -24,6 +24,7 @@ void main() {
|
||||
expect(style.elevation, null);
|
||||
expect(style.padding, null);
|
||||
expect(style.minimumSize, null);
|
||||
expect(style.fixedSize, null);
|
||||
expect(style.side, null);
|
||||
expect(style.shape, null);
|
||||
expect(style.mouseCursor, null);
|
||||
@@ -93,6 +94,7 @@ void main() {
|
||||
final MaterialStateProperty<double> elevation = MaterialStateProperty.all<double>(1);
|
||||
final MaterialStateProperty<EdgeInsets> padding = MaterialStateProperty.all<EdgeInsets>(const EdgeInsets.all(1));
|
||||
final MaterialStateProperty<Size> minimumSize = MaterialStateProperty.all<Size>(const Size(1, 2));
|
||||
final MaterialStateProperty<Size> fixedSize = MaterialStateProperty.all<Size>(const Size(3, 4));
|
||||
final MaterialStateProperty<BorderSide> side = MaterialStateProperty.all<BorderSide>(const BorderSide());
|
||||
final MaterialStateProperty<OutlinedBorder> shape = MaterialStateProperty.all<OutlinedBorder>(const StadiumBorder());
|
||||
final MaterialStateProperty<MouseCursor> mouseCursor = MaterialStateProperty.all<MouseCursor>(SystemMouseCursors.forbidden);
|
||||
@@ -109,6 +111,7 @@ void main() {
|
||||
elevation: elevation,
|
||||
padding: padding,
|
||||
minimumSize: minimumSize,
|
||||
fixedSize: fixedSize,
|
||||
side: side,
|
||||
shape: shape,
|
||||
mouseCursor: mouseCursor,
|
||||
@@ -128,6 +131,7 @@ void main() {
|
||||
elevation: elevation,
|
||||
padding: padding,
|
||||
minimumSize: minimumSize,
|
||||
fixedSize: fixedSize,
|
||||
side: side,
|
||||
shape: shape,
|
||||
mouseCursor: mouseCursor,
|
||||
|
||||
@@ -1039,6 +1039,39 @@ void main() {
|
||||
|
||||
expect(find.byType(ElevatedButton), paints ..path(strokeWidth: 4) ..drrect(color: borderColor));
|
||||
});
|
||||
|
||||
testWidgets('Fixed size ElevatedButtons', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Scaffold(
|
||||
body: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(fixedSize: const Size(100, 100)),
|
||||
onPressed: () {},
|
||||
child: const Text('100x100'),
|
||||
),
|
||||
ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(fixedSize: const Size.fromWidth(200)),
|
||||
onPressed: () {},
|
||||
child: const Text('200xh'),
|
||||
),
|
||||
ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(fixedSize: const Size.fromHeight(200)),
|
||||
onPressed: () {},
|
||||
child: const Text('wx200'),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
expect(tester.getSize(find.widgetWithText(ElevatedButton, '100x100')), const Size(100, 100));
|
||||
expect(tester.getSize(find.widgetWithText(ElevatedButton, '200xh')).width, 200);
|
||||
expect(tester.getSize(find.widgetWithText(ElevatedButton, 'wx200')).height, 200);
|
||||
});
|
||||
}
|
||||
|
||||
TextStyle _iconStyle(WidgetTester tester, IconData icon) {
|
||||
|
||||
@@ -1215,6 +1215,39 @@ void main() {
|
||||
);
|
||||
expect(paddingWidget.padding, const EdgeInsets.all(22));
|
||||
});
|
||||
|
||||
testWidgets('Fixed size OutlinedButtons', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Scaffold(
|
||||
body: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
OutlinedButton(
|
||||
style: OutlinedButton.styleFrom(fixedSize: const Size(100, 100)),
|
||||
onPressed: () {},
|
||||
child: const Text('100x100'),
|
||||
),
|
||||
OutlinedButton(
|
||||
style: OutlinedButton.styleFrom(fixedSize: const Size.fromWidth(200)),
|
||||
onPressed: () {},
|
||||
child: const Text('200xh'),
|
||||
),
|
||||
OutlinedButton(
|
||||
style: OutlinedButton.styleFrom(fixedSize: const Size.fromHeight(200)),
|
||||
onPressed: () {},
|
||||
child: const Text('wx200'),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
expect(tester.getSize(find.widgetWithText(OutlinedButton, '100x100')), const Size(100, 100));
|
||||
expect(tester.getSize(find.widgetWithText(OutlinedButton, '200xh')).width, 200);
|
||||
expect(tester.getSize(find.widgetWithText(OutlinedButton, 'wx200')).height, 200);
|
||||
});
|
||||
}
|
||||
|
||||
PhysicalModelLayer _findPhysicalLayer(Element element) {
|
||||
|
||||
@@ -1012,8 +1012,39 @@ void main() {
|
||||
expect(paddingWidget.padding, const EdgeInsets.all(22));
|
||||
});
|
||||
|
||||
}
|
||||
testWidgets('Fixed size TextButtons', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Scaffold(
|
||||
body: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
TextButton(
|
||||
style: TextButton.styleFrom(fixedSize: const Size(100, 100)),
|
||||
onPressed: () {},
|
||||
child: const Text('100x100'),
|
||||
),
|
||||
TextButton(
|
||||
style: TextButton.styleFrom(fixedSize: const Size.fromWidth(200)),
|
||||
onPressed: () {},
|
||||
child: const Text('200xh'),
|
||||
),
|
||||
TextButton(
|
||||
style: TextButton.styleFrom(fixedSize: const Size.fromHeight(200)),
|
||||
onPressed: () {},
|
||||
child: const Text('wx200'),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
expect(tester.getSize(find.widgetWithText(TextButton, '100x100')), const Size(100, 100));
|
||||
expect(tester.getSize(find.widgetWithText(TextButton, '200xh')).width, 200);
|
||||
expect(tester.getSize(find.widgetWithText(TextButton, 'wx200')).height, 200);
|
||||
});
|
||||
}
|
||||
|
||||
TextStyle? _iconStyle(WidgetTester tester, IconData icon) {
|
||||
final RichText iconRichText = tester.widget<RichText>(
|
||||
|
||||
Reference in New Issue
Block a user