Commit d0ef46d
fixes [add spacing parameter to Column and Row](flutter#55378)
### `Column.spacing` Code sample
<details>
<summary>expand to view the code sample</summary>
```dart
import 'package:flutter/material.dart';
void main() => runApp(const MyApp());
class MyApp extends StatelessWidget {
const MyApp({super.key});
@OverRide
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: Scaffold(
backgroundColor: Colors.black,
body: Center(
child: Padding(
padding: const EdgeInsets.all(16.0),
child: DecoratedBox(
decoration: BoxDecoration(
border: Border.all(
color: Colors.amber,
)),
child: const Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
Column(
spacing: 40.0,
// ignore: avoid_redundant_argument_values
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
ColoredBox(
color: Color(0xffff0000),
child: SizedBox(
width: 50.0,
height: 75.0,
child: Align(
alignment: Alignment.topCenter,
child: Text(
'RED',
style: TextStyle(color: Colors.white),
),
),
),
),
ColoredBox(
color: Color(0xff00ff00),
child: SizedBox(
width: 50.0,
height: 75.0,
child: Center(
child: Text(
'GREEN',
style: TextStyle(color: Colors.black),
),
),
),
),
ColoredBox(
color: Color(0xff0000ff),
child: SizedBox(
width: 50.0,
height: 75.0,
child: Align(
alignment: Alignment.bottomCenter,
child: Text(
'BLUE',
style: TextStyle(color: Colors.white),
),
),
),
),
],
),
Column(
spacing: 40.0,
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
ColoredBox(
color: Color(0xffff0000),
child: SizedBox(
width: 50.0,
height: 75.0,
child: Align(
alignment: Alignment.topCenter,
child: Text(
'RED',
style: TextStyle(color: Colors.white),
),
),
),
),
ColoredBox(
color: Color(0xff00ff00),
child: SizedBox(
width: 50.0,
height: 75.0,
child: Center(
child: Text(
'GREEN',
style: TextStyle(color: Colors.black),
),
),
),
),
ColoredBox(
color: Color(0xff0000ff),
child: SizedBox(
width: 50.0,
height: 75.0,
child: Align(
alignment: Alignment.bottomCenter,
child: Text(
'BLUE',
style: TextStyle(color: Colors.white),
),
),
),
),
],
),
Column(
spacing: 40.0,
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
ColoredBox(
color: Color(0xffff0000),
child: SizedBox(
width: 50.0,
height: 75.0,
child: Align(
alignment: Alignment.topCenter,
child: Text(
'RED',
style: TextStyle(color: Colors.white),
),
),
),
),
ColoredBox(
color: Color(0xff00ff00),
child: SizedBox(
width: 50.0,
height: 75.0,
child: Center(
child: Text(
'GREEN',
style: TextStyle(color: Colors.black),
),
),
),
),
ColoredBox(
color: Color(0xff0000ff),
child: SizedBox(
width: 50.0,
height: 75.0,
child: Align(
alignment: Alignment.bottomCenter,
child: Text(
'BLUE',
style: TextStyle(color: Colors.white),
),
),
),
),
],
),
Column(
spacing: 40.0,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
ColoredBox(
color: Color(0xffff0000),
child: SizedBox(
width: 50.0,
height: 75.0,
child: Align(
alignment: Alignment.topCenter,
child: Text(
'RED',
style: TextStyle(color: Colors.white),
),
),
),
),
ColoredBox(
color: Color(0xff00ff00),
child: SizedBox(
width: 50.0,
height: 75.0,
child: Center(
child: Text(
'GREEN',
style: TextStyle(color: Colors.black),
),
),
),
),
ColoredBox(
color: Color(0xff0000ff),
child: SizedBox(
width: 50.0,
height: 75.0,
child: Align(
alignment: Alignment.bottomCenter,
child: Text(
'BLUE',
style: TextStyle(color: Colors.white),
),
),
),
),
],
),
Column(
spacing: 40.0,
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: <Widget>[
ColoredBox(
color: Color(0xffff0000),
child: SizedBox(
width: 50.0,
height: 75.0,
child: Align(
alignment: Alignment.topCenter,
child: Text(
'RED',
style: TextStyle(color: Colors.white),
),
),
),
),
ColoredBox(
color: Color(0xff00ff00),
child: SizedBox(
width: 50.0,
height: 75.0,
child: Center(
child: Text(
'GREEN',
style: TextStyle(color: Colors.black),
),
),
),
),
ColoredBox(
color: Color(0xff0000ff),
child: SizedBox(
width: 50.0,
height: 75.0,
child: Align(
alignment: Alignment.bottomCenter,
child: Text(
'BLUE',
style: TextStyle(color: Colors.white),
),
),
),
),
],
),
Column(
spacing: 40.0,
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
ColoredBox(
color: Color(0xffff0000),
child: SizedBox(
width: 50.0,
height: 75.0,
child: Align(
alignment: Alignment.topCenter,
child: Text(
'RED',
style: TextStyle(color: Colors.white),
),
),
),
),
ColoredBox(
color: Color(0xff00ff00),
child: SizedBox(
width: 50.0,
height: 75.0,
child: Center(
child: Text(
'GREEN',
style: TextStyle(color: Colors.black),
),
),
),
),
ColoredBox(
color: Color(0xff0000ff),
child: SizedBox(
width: 50.0,
height: 75.0,
child: Align(
alignment: Alignment.bottomCenter,
child: Text(
'BLUE',
style: TextStyle(color: Colors.white),
),
),
),
),
],
),
],
),
),
),
),
),
);
}
}
```
</details>
### Preview
<img width="1072" alt="Screenshot 2024-07-30 at 15 40 59" src="https://github.com/user-attachments/assets/14f21091-9e46-4a58-8552-1379f4ba9216">
### `Row.spacing` Code sample
<details>
<summary>expand to view the code sample</summary>
```dart
import 'package:flutter/material.dart';
void main() => runApp(const MyApp());
class MyApp extends StatelessWidget {
const MyApp({super.key});
@OverRide
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: Scaffold(
backgroundColor: Colors.black,
body: Center(
child: Padding(
padding: const EdgeInsets.all(16.0),
child: DecoratedBox(
decoration: BoxDecoration(
border: Border.all(
color: Colors.amber,
)),
child: const Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
Row(
spacing: 40.0,
// ignore: avoid_redundant_argument_values
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
ColoredBox(
color: Color(0xffff0000),
child: SizedBox(
width: 50.0,
height: 75.0,
child: Align(
alignment: Alignment.centerLeft,
child: Text(
'RED',
style: TextStyle(color: Colors.white),
),
),
),
),
ColoredBox(
color: Color(0xff00ff00),
child: SizedBox(
width: 50.0,
height: 75.0,
child: Center(
child: Text(
'GREEN',
style: TextStyle(color: Colors.black),
),
),
),
),
ColoredBox(
color: Color(0xff0000ff),
child: SizedBox(
width: 50.0,
height: 75.0,
child: Align(
alignment: Alignment.centerRight,
child: Text(
'BLUE',
style: TextStyle(color: Colors.white),
),
),
),
),
],
),
Row(
spacing: 40.0,
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
ColoredBox(
color: Color(0xffff0000),
child: SizedBox(
width: 50.0,
height: 75.0,
child: Align(
alignment: Alignment.centerLeft,
child: Text(
'RED',
style: TextStyle(color: Colors.white),
),
),
),
),
ColoredBox(
color: Color(0xff00ff00),
child: SizedBox(
width: 50.0,
height: 75.0,
child: Center(
child: Text(
'GREEN',
style: TextStyle(color: Colors.black),
),
),
),
),
ColoredBox(
color: Color(0xff0000ff),
child: SizedBox(
width: 50.0,
height: 75.0,
child: Align(
alignment: Alignment.centerRight,
child: Text(
'BLUE',
style: TextStyle(color: Colors.white),
),
),
),
),
],
),
Row(
spacing: 40.0,
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
ColoredBox(
color: Color(0xffff0000),
child: SizedBox(
width: 50.0,
height: 75.0,
child: Align(
alignment: Alignment.centerLeft,
child: Text(
'RED',
style: TextStyle(color: Colors.white),
),
),
),
),
ColoredBox(
color: Color(0xff00ff00),
child: SizedBox(
width: 50.0,
height: 75.0,
child: Center(
child: Text(
'GREEN',
style: TextStyle(color: Colors.black),
),
),
),
),
ColoredBox(
color: Color(0xff0000ff),
child: SizedBox(
width: 50.0,
height: 75.0,
child: Align(
alignment: Alignment.centerRight,
child: Text(
'BLUE',
style: TextStyle(color: Colors.white),
),
),
),
),
],
),
Row(
spacing: 40.0,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
ColoredBox(
color: Color(0xffff0000),
child: SizedBox(
width: 50.0,
height: 75.0,
child: Align(
alignment: Alignment.centerLeft,
child: Text(
'RED',
style: TextStyle(color: Colors.white),
),
),
),
),
ColoredBox(
color: Color(0xff00ff00),
child: SizedBox(
width: 50.0,
height: 75.0,
child: Center(
child: Text(
'GREEN',
style: TextStyle(color: Colors.black),
),
),
),
),
ColoredBox(
color: Color(0xff0000ff),
child: SizedBox(
width: 50.0,
height: 75.0,
child: Align(
alignment: Alignment.centerRight,
child: Text(
'BLUE',
style: TextStyle(color: Colors.white),
),
),
),
),
],
),
Row(
spacing: 40.0,
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: <Widget>[
ColoredBox(
color: Color(0xffff0000),
child: SizedBox(
width: 50.0,
height: 75.0,
child: Align(
alignment: Alignment.centerLeft,
child: Text(
'RED',
style: TextStyle(color: Colors.white),
),
),
),
),
ColoredBox(
color: Color(0xff00ff00),
child: SizedBox(
width: 50.0,
height: 75.0,
child: Center(
child: Text(
'GREEN',
style: TextStyle(color: Colors.black),
),
),
),
),
ColoredBox(
color: Color(0xff0000ff),
child: SizedBox(
width: 50.0,
height: 75.0,
child: Align(
alignment: Alignment.centerRight,
child: Text(
'BLUE',
style: TextStyle(color: Colors.white),
),
),
),
),
],
),
Row(
spacing: 40.0,
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
ColoredBox(
color: Color(0xffff0000),
child: SizedBox(
width: 50.0,
height: 75.0,
child: Align(
alignment: Alignment.centerLeft,
child: Text(
'RED',
style: TextStyle(color: Colors.white),
),
),
),
),
ColoredBox(
color: Color(0xff00ff00),
child: SizedBox(
width: 50.0,
height: 75.0,
child: Center(
child: Text(
'GREEN',
style: TextStyle(color: Colors.black),
),
),
),
),
ColoredBox(
color: Color(0xff0000ff),
child: SizedBox(
width: 50.0,
height: 75.0,
child: Align(
child: Text(
'BLUE',
style: TextStyle(color: Colors.white),
),
),
),
),
],
),
],
),
),
),
),
),
);
}
}
```
</details>
### Preview
<img width="1072" alt="Screenshot 2024-07-30 at 15 39 42" src="https://github.com/user-attachments/assets/717e9f5e-a491-4853-ba74-e72ec7493363">
1 parent 3c53cde commit d0ef46d
File tree
4 files changed
+617
-18
lines changed- packages/flutter
- lib/src
- rendering
- widgets
- test
- rendering
- widgets
4 files changed
+617
-18
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
215 | 215 | | |
216 | 216 | | |
217 | 217 | | |
218 | | - | |
| 218 | + | |
219 | 219 | | |
220 | 220 | | |
221 | | - | |
| 221 | + | |
222 | 222 | | |
223 | | - | |
224 | | - | |
225 | | - | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
226 | 226 | | |
227 | | - | |
228 | | - | |
229 | | - | |
230 | | - | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
231 | 231 | | |
232 | 232 | | |
233 | 233 | | |
| |||
390 | 390 | | |
391 | 391 | | |
392 | 392 | | |
| 393 | + | |
393 | 394 | | |
394 | 395 | | |
395 | 396 | | |
396 | 397 | | |
397 | 398 | | |
398 | 399 | | |
399 | 400 | | |
400 | | - | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
401 | 404 | | |
402 | 405 | | |
403 | 406 | | |
| |||
588 | 591 | | |
589 | 592 | | |
590 | 593 | | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
591 | 657 | | |
592 | 658 | | |
593 | 659 | | |
| |||
597 | 663 | | |
598 | 664 | | |
599 | 665 | | |
600 | | - | |
601 | | - | |
| 666 | + | |
| 667 | + | |
602 | 668 | | |
603 | 669 | | |
604 | 670 | | |
605 | 671 | | |
606 | 672 | | |
607 | 673 | | |
608 | | - | |
| 674 | + | |
609 | 675 | | |
610 | 676 | | |
611 | 677 | | |
| |||
825 | 891 | | |
826 | 892 | | |
827 | 893 | | |
828 | | - | |
| 894 | + | |
829 | 895 | | |
830 | 896 | | |
831 | 897 | | |
| |||
978 | 1044 | | |
979 | 1045 | | |
980 | 1046 | | |
981 | | - | |
| 1047 | + | |
| 1048 | + | |
982 | 1049 | | |
983 | 1050 | | |
984 | 1051 | | |
| |||
1064 | 1131 | | |
1065 | 1132 | | |
1066 | 1133 | | |
1067 | | - | |
| 1134 | + | |
1068 | 1135 | | |
1069 | 1136 | | |
1070 | 1137 | | |
| |||
1192 | 1259 | | |
1193 | 1260 | | |
1194 | 1261 | | |
| 1262 | + | |
1195 | 1263 | | |
1196 | 1264 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4604 | 4604 | | |
4605 | 4605 | | |
4606 | 4606 | | |
| 4607 | + | |
4607 | 4608 | | |
4608 | 4609 | | |
4609 | 4610 | | |
| |||
4710 | 4711 | | |
4711 | 4712 | | |
4712 | 4713 | | |
| 4714 | + | |
| 4715 | + | |
| 4716 | + | |
4713 | 4717 | | |
4714 | 4718 | | |
4715 | 4719 | | |
| |||
4751 | 4755 | | |
4752 | 4756 | | |
4753 | 4757 | | |
| 4758 | + | |
4754 | 4759 | | |
4755 | 4760 | | |
4756 | 4761 | | |
| |||
4764 | 4769 | | |
4765 | 4770 | | |
4766 | 4771 | | |
4767 | | - | |
| 4772 | + | |
| 4773 | + | |
4768 | 4774 | | |
4769 | 4775 | | |
4770 | 4776 | | |
| |||
4777 | 4783 | | |
4778 | 4784 | | |
4779 | 4785 | | |
| 4786 | + | |
| 4787 | + | |
4780 | 4788 | | |
4781 | 4789 | | |
4782 | 4790 | | |
| |||
4983 | 4991 | | |
4984 | 4992 | | |
4985 | 4993 | | |
| 4994 | + | |
4986 | 4995 | | |
4987 | 4996 | | |
4988 | 4997 | | |
| |||
5174 | 5183 | | |
5175 | 5184 | | |
5176 | 5185 | | |
| 5186 | + | |
5177 | 5187 | | |
5178 | 5188 | | |
5179 | 5189 | | |
| |||
0 commit comments