mirror of
https://github.com/flutter/packages.git
synced 2025-06-28 22:02:38 +08:00
[various] Prep for more const widgets (#3139)
* [various] Prep for more const widgets * exclude from readme
This commit is contained in:

committed by
GitHub

parent
f14b713e79
commit
e63f3e3fc6
@ -140,6 +140,7 @@ displayed and the entrance animation and exit animation.
|
|||||||
inAnimation: AdaptiveScaffold.leftOutIn,
|
inAnimation: AdaptiveScaffold.leftOutIn,
|
||||||
builder: (_) => AdaptiveScaffold.standardNavigationRail(
|
builder: (_) => AdaptiveScaffold.standardNavigationRail(
|
||||||
extended: true,
|
extended: true,
|
||||||
|
// ···
|
||||||
leading: Row(
|
leading: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||||
children: const <Widget>[
|
children: const <Widget>[
|
||||||
|
@ -45,6 +45,8 @@ class MyHomePage extends StatelessWidget {
|
|||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
const Divider(color: Colors.black),
|
const Divider(color: Colors.black),
|
||||||
const SizedBox(height: 10),
|
const SizedBox(height: 10),
|
||||||
|
// TODO(goderbauer): Make this const when this package requires Flutter 3.8 or later.
|
||||||
|
// ignore: prefer_const_constructors
|
||||||
Row(
|
Row(
|
||||||
children: const <Widget>[
|
children: const <Widget>[
|
||||||
SizedBox(
|
SizedBox(
|
||||||
@ -150,6 +152,10 @@ class MyHomePage extends StatelessWidget {
|
|||||||
inAnimation: AdaptiveScaffold.leftOutIn,
|
inAnimation: AdaptiveScaffold.leftOutIn,
|
||||||
builder: (_) => AdaptiveScaffold.standardNavigationRail(
|
builder: (_) => AdaptiveScaffold.standardNavigationRail(
|
||||||
extended: true,
|
extended: true,
|
||||||
|
// #enddocregion Example
|
||||||
|
// TODO(goderbauer): Make this const when this package requires Flutter 3.8 or later.
|
||||||
|
// ignore: prefer_const_constructors
|
||||||
|
// #docregion Example
|
||||||
leading: Row(
|
leading: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||||
children: const <Widget>[
|
children: const <Widget>[
|
||||||
|
@ -409,6 +409,8 @@ class _LargeComposeIcon extends StatelessWidget {
|
|||||||
child: Column(children: <Widget>[
|
child: Column(children: <Widget>[
|
||||||
Container(
|
Container(
|
||||||
padding: const EdgeInsets.fromLTRB(6, 0, 0, 0),
|
padding: const EdgeInsets.fromLTRB(6, 0, 0, 0),
|
||||||
|
// TODO(goderbauer): Make this const when this package requires Flutter 3.8 or later.
|
||||||
|
// ignore: prefer_const_constructors
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: const <Widget>[
|
children: const <Widget>[
|
||||||
@ -439,8 +441,12 @@ class _LargeComposeIcon extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
width: 200,
|
width: 200,
|
||||||
height: 50,
|
height: 50,
|
||||||
|
// TODO(goderbauer): Make this const when this package requires Flutter 3.8 or later.
|
||||||
|
// ignore: prefer_const_constructors
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.fromLTRB(16.0, 0, 0, 0),
|
padding: const EdgeInsets.fromLTRB(16.0, 0, 0, 0),
|
||||||
|
// TODO(goderbauer): Make this const when this package requires Flutter 3.8 or later.
|
||||||
|
// ignore: prefer_const_constructors
|
||||||
child: Row(
|
child: Row(
|
||||||
children: const <Widget>[
|
children: const <Widget>[
|
||||||
Icon(Icons.edit_outlined),
|
Icon(Icons.edit_outlined),
|
||||||
|
@ -210,6 +210,8 @@ void defineTests() {
|
|||||||
|
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
boilerplate(
|
boilerplate(
|
||||||
|
// TODO(goderbauer): Make this const when this package requires Flutter 3.8 or later.
|
||||||
|
// ignore: prefer_const_constructors
|
||||||
Column(
|
Column(
|
||||||
children: const <Widget>[
|
children: const <Widget>[
|
||||||
MarkdownBody(fitContent: false, data: data),
|
MarkdownBody(fitContent: false, data: data),
|
||||||
@ -233,6 +235,8 @@ void defineTests() {
|
|||||||
|
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
boilerplate(
|
boilerplate(
|
||||||
|
// TODO(goderbauer): Make this const when this package requires Flutter 3.8 or later.
|
||||||
|
// ignore: prefer_const_constructors
|
||||||
Column(
|
Column(
|
||||||
children: const <Widget>[
|
children: const <Widget>[
|
||||||
MarkdownBody(data: data),
|
MarkdownBody(data: data),
|
||||||
|
@ -15,17 +15,21 @@ void defineTests() {
|
|||||||
'Given a MarkdownBody with shrinkWrap=true '
|
'Given a MarkdownBody with shrinkWrap=true '
|
||||||
'Then it wraps its content',
|
'Then it wraps its content',
|
||||||
(WidgetTester tester) async {
|
(WidgetTester tester) async {
|
||||||
await tester.pumpWidget(boilerplate(Stack(
|
await tester.pumpWidget(boilerplate(
|
||||||
children: const <Widget>[
|
// TODO(goderbauer): Make this const when this package requires Flutter 3.8 or later.
|
||||||
Text('shrinkWrap=true'),
|
// ignore: prefer_const_constructors
|
||||||
Align(
|
Stack(
|
||||||
alignment: Alignment.bottomCenter,
|
children: const <Widget>[
|
||||||
child: MarkdownBody(
|
Text('shrinkWrap=true'),
|
||||||
data: 'This is a [link](https://flutter.dev/)',
|
Align(
|
||||||
|
alignment: Alignment.bottomCenter,
|
||||||
|
child: MarkdownBody(
|
||||||
|
data: 'This is a [link](https://flutter.dev/)',
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
],
|
),
|
||||||
)));
|
));
|
||||||
|
|
||||||
final Rect stackRect = tester.getRect(find.byType(Stack));
|
final Rect stackRect = tester.getRect(find.byType(Stack));
|
||||||
final Rect textRect = tester.getRect(find.byType(Text));
|
final Rect textRect = tester.getRect(find.byType(Text));
|
||||||
@ -43,18 +47,22 @@ void defineTests() {
|
|||||||
'Given a MarkdownBody with shrinkWrap=false '
|
'Given a MarkdownBody with shrinkWrap=false '
|
||||||
'Then it expands to the maximum allowed height',
|
'Then it expands to the maximum allowed height',
|
||||||
(WidgetTester tester) async {
|
(WidgetTester tester) async {
|
||||||
await tester.pumpWidget(boilerplate(Stack(
|
await tester.pumpWidget(boilerplate(
|
||||||
children: const <Widget>[
|
// TODO(goderbauer): Make this const when this package requires Flutter 3.8 or later.
|
||||||
Text('shrinkWrap=false test'),
|
// ignore: prefer_const_constructors
|
||||||
Align(
|
Stack(
|
||||||
alignment: Alignment.bottomCenter,
|
children: const <Widget>[
|
||||||
child: MarkdownBody(
|
Text('shrinkWrap=false test'),
|
||||||
data: 'This is a [link](https://flutter.dev/)',
|
Align(
|
||||||
shrinkWrap: false,
|
alignment: Alignment.bottomCenter,
|
||||||
|
child: MarkdownBody(
|
||||||
|
data: 'This is a [link](https://flutter.dev/)',
|
||||||
|
shrinkWrap: false,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
],
|
),
|
||||||
)));
|
));
|
||||||
|
|
||||||
final Rect stackRect = tester.getRect(find.byType(Stack));
|
final Rect stackRect = tester.getRect(find.byType(Stack));
|
||||||
final Rect textRect = tester.getRect(find.byType(Text));
|
final Rect textRect = tester.getRect(find.byType(Text));
|
||||||
|
@ -87,10 +87,18 @@ class _ExampleState extends State<Example> {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
// TODO(goderbauer): Make this const when this package requires Flutter 3.8 or later.
|
||||||
|
// ignore: prefer_const_constructors
|
||||||
result = Material(
|
result = Material(
|
||||||
|
// TODO(goderbauer): Make this const when this package requires Flutter 3.8 or later.
|
||||||
|
// ignore: prefer_const_constructors
|
||||||
child: SafeArea(
|
child: SafeArea(
|
||||||
|
// TODO(goderbauer): Make this const when this package requires Flutter 3.8 or later.
|
||||||
|
// ignore: prefer_const_constructors
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.all(20.0),
|
padding: const EdgeInsets.all(20.0),
|
||||||
|
// TODO(goderbauer): Make this const when this package requires Flutter 3.8 or later.
|
||||||
|
// ignore: prefer_const_constructors
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
children: const <Widget>[
|
children: const <Widget>[
|
||||||
|
Reference in New Issue
Block a user