Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
c083f02f
Unverified
Commit
c083f02f
authored
Oct 09, 2020
by
Greg Spencer
Committed by
GitHub
Oct 09, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Migrate more material tests to NNBD (#67674)
This migrates more material tests to NNBD.
parent
dcb5975d
Changes
17
Show whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
183 additions
and
230 deletions
+183
-230
about_test.dart
packages/flutter/test/material/about_test.dart
+2
-4
animated_icons_test.dart
packages/flutter/test/material/animated_icons_test.dart
+14
-16
app_bar_test.dart
packages/flutter/test/material/app_bar_test.dart
+18
-33
app_bar_theme_test.dart
packages/flutter/test/material/app_bar_theme_test.dart
+15
-17
app_builder_test.dart
packages/flutter/test/material/app_builder_test.dart
+5
-7
app_test.dart
packages/flutter/test/material/app_test.dart
+51
-53
arc_test.dart
packages/flutter/test/material/arc_test.dart
+0
-2
back_button_test.dart
packages/flutter/test/material/back_button_test.dart
+2
-4
banner_test.dart
packages/flutter/test/material/banner_test.dart
+1
-3
banner_theme_test.dart
packages/flutter/test/material/banner_theme_test.dart
+2
-4
bottom_app_bar_test.dart
packages/flutter/test/material/bottom_app_bar_test.dart
+11
-13
bottom_app_bar_theme_test.dart
...ages/flutter/test/material/bottom_app_bar_theme_test.dart
+0
-2
bottom_navigation_bar_test.dart
...ges/flutter/test/material/bottom_navigation_bar_test.dart
+30
-32
bottom_navigation_bar_theme_test.dart
...utter/test/material/bottom_navigation_bar_theme_test.dart
+5
-7
bottom_sheet_test.dart
packages/flutter/test/material/bottom_sheet_test.dart
+24
-26
bottom_sheet_theme_test.dart
packages/flutter/test/material/bottom_sheet_theme_test.dart
+0
-2
button_bar_test.dart
packages/flutter/test/material/button_bar_test.dart
+3
-5
No files found.
packages/flutter/test/material/about_test.dart
View file @
c083f02f
...
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import
'dart:async'
;
import
'package:flutter/foundation.dart'
;
...
...
@@ -733,7 +731,7 @@ class LicensePageObserver extends NavigatorObserver {
int
licensePageCount
=
0
;
@override
void
didPush
(
Route
<
dynamic
>
route
,
Route
<
dynamic
>
previousRoute
)
{
void
didPush
(
Route
<
dynamic
>
route
,
Route
<
dynamic
>
?
previousRoute
)
{
if
(
route
is
MaterialPageRoute
<
dynamic
>)
{
licensePageCount
++;
}
...
...
@@ -745,7 +743,7 @@ class AboutDialogObserver extends NavigatorObserver {
int
dialogCount
=
0
;
@override
void
didPush
(
Route
<
dynamic
>
route
,
Route
<
dynamic
>
previousRoute
)
{
void
didPush
(
Route
<
dynamic
>
route
,
Route
<
dynamic
>
?
previousRoute
)
{
if
(
route
.
toString
().
contains
(
'_DialogRoute'
))
{
dialogCount
++;
}
...
...
packages/flutter/test/material/animated_icons_test.dart
View file @
c083f02f
...
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import
'dart:math'
as
math
show
pi
;
import
'package:flutter/material.dart'
;
...
...
@@ -13,8 +11,8 @@ import '../flutter_test_alternative.dart' show Fake;
import
'../widgets/semantics_tester.dart'
;
class
MockCanvas
extends
Fake
implements
Canvas
{
Path
capturedPath
;
Paint
capturedPaint
;
late
Path
capturedPath
;
late
Paint
capturedPaint
;
@override
void
drawPath
(
Path
path
,
Paint
paint
)
{
...
...
@@ -22,13 +20,13 @@ class MockCanvas extends Fake implements Canvas {
capturedPaint
=
paint
;
}
double
capturedSx
;
double
capturedSy
;
late
double
capturedSx
;
late
double
capturedSy
;
@override
void
scale
(
double
sx
,
[
double
sy
])
{
void
scale
(
double
sx
,
[
double
?
sy
])
{
capturedSx
=
sx
;
capturedSy
=
sy
;
capturedSy
=
sy
!
;
}
final
List
<
RecordedCanvasCall
>
invocations
=
<
RecordedCanvasCall
>[];
...
...
@@ -96,7 +94,7 @@ void main() {
);
final
CustomPaint
customPaint
=
tester
.
widget
(
find
.
byType
(
CustomPaint
));
final
MockCanvas
canvas
=
MockCanvas
();
customPaint
.
painter
.
paint
(
canvas
,
const
Size
(
48.0
,
48.0
));
customPaint
.
painter
!
.
paint
(
canvas
,
const
Size
(
48.0
,
48.0
));
expect
(
canvas
.
capturedPaint
,
hasColor
(
0xFF666666
));
});
...
...
@@ -118,7 +116,7 @@ void main() {
);
final
CustomPaint
customPaint
=
tester
.
widget
(
find
.
byType
(
CustomPaint
));
final
MockCanvas
canvas
=
MockCanvas
();
customPaint
.
painter
.
paint
(
canvas
,
const
Size
(
48.0
,
48.0
));
customPaint
.
painter
!
.
paint
(
canvas
,
const
Size
(
48.0
,
48.0
));
expect
(
canvas
.
capturedPaint
,
hasColor
(
0x80666666
));
});
...
...
@@ -140,7 +138,7 @@ void main() {
);
final
CustomPaint
customPaint
=
tester
.
widget
(
find
.
byType
(
CustomPaint
));
final
MockCanvas
canvas
=
MockCanvas
();
customPaint
.
painter
.
paint
(
canvas
,
const
Size
(
48.0
,
48.0
));
customPaint
.
painter
!
.
paint
(
canvas
,
const
Size
(
48.0
,
48.0
));
expect
(
canvas
.
capturedPaint
,
hasColor
(
0xFF0000FF
));
});
...
...
@@ -162,7 +160,7 @@ void main() {
);
final
CustomPaint
customPaint
=
tester
.
widget
(
find
.
byType
(
CustomPaint
));
final
MockCanvas
canvas
=
MockCanvas
();
customPaint
.
painter
.
paint
(
canvas
,
const
Size
(
12.0
,
12.0
));
customPaint
.
painter
!
.
paint
(
canvas
,
const
Size
(
12.0
,
12.0
));
// arrow_menu default size is 48x48 so we expect it to be scaled by 0.25.
expect
(
canvas
.
capturedSx
,
0.25
);
expect
(
canvas
.
capturedSy
,
0.25
);
...
...
@@ -187,7 +185,7 @@ void main() {
);
final
CustomPaint
customPaint
=
tester
.
widget
(
find
.
byType
(
CustomPaint
));
final
MockCanvas
canvas
=
MockCanvas
();
customPaint
.
painter
.
paint
(
canvas
,
const
Size
(
12.0
,
12.0
));
customPaint
.
painter
!
.
paint
(
canvas
,
const
Size
(
12.0
,
12.0
));
// arrow_menu default size is 48x48 so we expect it to be scaled by 2.
expect
(
canvas
.
capturedSx
,
2
);
expect
(
canvas
.
capturedSy
,
2
);
...
...
@@ -230,7 +228,7 @@ void main() {
);
final
CustomPaint
customPaint
=
tester
.
widget
(
find
.
byType
(
CustomPaint
));
final
MockCanvas
canvas
=
MockCanvas
();
customPaint
.
painter
.
paint
(
canvas
,
const
Size
(
48.0
,
48.0
));
customPaint
.
painter
!
.
paint
(
canvas
,
const
Size
(
48.0
,
48.0
));
expect
(
canvas
.
invocations
,
const
<
RecordedCanvasCall
>[
RecordedRotate
(
math
.
pi
),
RecordedTranslate
(-
48
,
-
48
),
...
...
@@ -254,7 +252,7 @@ void main() {
);
final
CustomPaint
customPaint
=
tester
.
widget
(
find
.
byType
(
CustomPaint
));
final
MockCanvas
canvas
=
MockCanvas
();
customPaint
.
painter
.
paint
(
canvas
,
const
Size
(
48.0
,
48.0
));
customPaint
.
painter
!
.
paint
(
canvas
,
const
Size
(
48.0
,
48.0
));
expect
(
canvas
.
invocations
,
isEmpty
);
});
...
...
@@ -276,7 +274,7 @@ void main() {
);
final
CustomPaint
customPaint
=
tester
.
widget
(
find
.
byType
(
CustomPaint
));
final
MockCanvas
canvas
=
MockCanvas
();
customPaint
.
painter
.
paint
(
canvas
,
const
Size
(
48.0
,
48.0
));
customPaint
.
painter
!
.
paint
(
canvas
,
const
Size
(
48.0
,
48.0
));
expect
(
canvas
.
invocations
,
const
<
RecordedCanvasCall
>[
RecordedRotate
(
math
.
pi
),
RecordedTranslate
(-
48
,
-
48
),
...
...
packages/flutter/test/material/app_bar_test.dart
View file @
c083f02f
...
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import
'package:flutter/foundation.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/rendering.dart'
;
...
...
@@ -14,10 +12,10 @@ import '../rendering/mock_canvas.dart';
import
'../widgets/semantics_tester.dart'
;
Widget
buildSliverAppBarApp
(
{
bool
floating
,
bool
pinned
,
double
collapsedHeight
,
double
expandedHeight
,
bool
floating
=
false
,
bool
pinned
=
false
,
double
?
collapsedHeight
,
double
?
expandedHeight
,
bool
snap
=
false
,
double
toolbarHeight
=
kToolbarHeight
,
})
{
...
...
@@ -65,7 +63,7 @@ Widget buildSliverAppBarApp({
}
ScrollController
primaryScrollController
(
WidgetTester
tester
)
{
return
PrimaryScrollController
.
of
(
tester
.
element
(
find
.
byType
(
CustomScrollView
)));
return
PrimaryScrollController
.
of
(
tester
.
element
(
find
.
byType
(
CustomScrollView
)))
!
;
}
double
appBarHeight
(
WidgetTester
tester
)
=>
tester
.
getSize
(
find
.
byType
(
AppBar
,
skipOffstage:
false
)).
height
;
...
...
@@ -303,7 +301,7 @@ void main() {
final
Key
titleKey
=
UniqueKey
();
Widget
leading
=
Container
();
List
<
Widget
>
actions
;
List
<
Widget
>
actions
=
<
Widget
>[]
;
Widget
buildApp
()
{
return
MaterialApp
(
...
...
@@ -360,8 +358,8 @@ void main() {
final
Key
titleKey
=
UniqueKey
();
double
titleWidth
=
700.0
;
Widget
leading
=
Container
();
List
<
Widget
>
actions
;
Widget
?
leading
=
Container
();
List
<
Widget
>
actions
=
<
Widget
>[]
;
Widget
buildApp
()
{
return
MaterialApp
(
...
...
@@ -412,8 +410,8 @@ void main() {
final
Key
titleKey
=
UniqueKey
();
double
titleWidth
=
700.0
;
Widget
leading
=
Container
();
List
<
Widget
>
actions
;
Widget
?
leading
=
Container
();
List
<
Widget
>
actions
=
<
Widget
>[]
;
Widget
buildApp
()
{
return
MaterialApp
(
...
...
@@ -1952,14 +1950,14 @@ void main() {
});
testWidgets
(
'AppBars title has upper limit on text scaling, textScaleFactor = 1, 1.34, 2'
,
(
WidgetTester
tester
)
async
{
double
textScaleFactor
;
late
double
textScaleFactor
;
Widget
buildFrame
()
{
return
MaterialApp
(
home:
Builder
(
builder:
(
BuildContext
context
)
{
return
MediaQuery
(
data:
MediaQuery
.
of
(
context
).
copyWith
(
textScaleFactor:
textScaleFactor
),
data:
MediaQuery
.
of
(
context
)
!
.
copyWith
(
textScaleFactor:
textScaleFactor
),
child:
Scaffold
(
appBar:
AppBar
(
centerTitle:
false
,
...
...
@@ -1988,9 +1986,9 @@ void main() {
});
testWidgets
(
'AppBars with jumbo titles, textScaleFactor = 3, 3.5, 4'
,
(
WidgetTester
tester
)
async
{
double
textScaleFactor
;
TextDirection
textDirection
;
bool
centerTitle
;
double
textScaleFactor
=
1.0
;
TextDirection
textDirection
=
TextDirection
.
ltr
;
bool
centerTitle
=
false
;
Widget
buildFrame
()
{
return
MaterialApp
(
...
...
@@ -2004,7 +2002,7 @@ void main() {
appBar:
AppBar
(
centerTitle:
centerTitle
,
title:
MediaQuery
(
data:
MediaQuery
.
of
(
context
).
copyWith
(
textScaleFactor:
textScaleFactor
),
data:
MediaQuery
.
of
(
context
)
!
.
copyWith
(
textScaleFactor:
textScaleFactor
),
child:
const
Text
(
'Jumbo'
),
),
),
...
...
@@ -2023,10 +2021,8 @@ void main() {
// Overall screen size is 800x600
// Left or right justified title is padded by 16 on the "start" side.
// Toolbar height is 56.
// "Jumbo" title is 100x20.
textScaleFactor
=
1
;
// "Jumbo" title is 100x20.
textDirection
=
TextDirection
.
ltr
;
centerTitle
=
false
;
await
tester
.
pumpWidget
(
buildFrame
());
expect
(
tester
.
getRect
(
appBarTitle
),
const
Rect
.
fromLTRB
(
16
,
18
,
116
,
38
));
expect
(
tester
.
getCenter
(
appBarTitle
).
dy
,
tester
.
getCenter
(
toolbar
).
dy
);
...
...
@@ -2058,7 +2054,7 @@ void main() {
});
testWidgets
(
'SliverAppBar configures the delegate properly'
,
(
WidgetTester
tester
)
async
{
Future
<
void
>
buildAndVerifyDelegate
({
bool
pinned
,
bool
floating
,
bool
snap
})
async
{
Future
<
void
>
buildAndVerifyDelegate
({
required
bool
pinned
,
required
bool
floating
,
required
bool
snap
})
async
{
await
tester
.
pumpWidget
(
MaterialApp
(
home:
CustomScrollView
(
...
...
@@ -2150,17 +2146,6 @@ void main() {
expect
(
appBarHeight
(
tester
),
collapsedHeight
+
initialTabBarHeight
);
});
test
(
'SliverApp toolbarHeight cannot be null'
,
()
{
try
{
SliverAppBar
(
toolbarHeight:
null
,
);
}
on
AssertionError
catch
(
error
)
{
expect
(
error
.
toString
(),
contains
(
'toolbarHeight != null'
));
expect
(
error
.
toString
(),
contains
(
'is not true'
));
}
});
testWidgets
(
'AppBar respects leadingWidth'
,
(
WidgetTester
tester
)
async
{
const
Key
key
=
Key
(
'leading'
);
await
tester
.
pumpWidget
(
MaterialApp
(
...
...
packages/flutter/test/material/app_bar_theme_test.dart
View file @
c083f02f
...
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import
'package:flutter/material.dart'
;
import
'package:flutter/rendering.dart'
;
import
'package:flutter/services.dart'
;
...
...
@@ -31,14 +29,14 @@ void main() {
final
RichText
actionIconText
=
_getAppBarIconRichText
(
tester
);
final
DefaultTextStyle
text
=
_getAppBarText
(
tester
);
expect
(
SystemChrome
.
latestStyle
.
statusBarBrightness
,
Brightness
.
dark
);
expect
(
SystemChrome
.
latestStyle
!
.
statusBarBrightness
,
Brightness
.
dark
);
expect
(
widget
.
color
,
Colors
.
blue
);
expect
(
widget
.
elevation
,
4.0
);
expect
(
widget
.
shadowColor
,
Colors
.
black
);
expect
(
iconTheme
.
data
,
const
IconThemeData
(
color:
Colors
.
white
));
expect
(
actionsIconTheme
.
data
,
const
IconThemeData
(
color:
Colors
.
white
));
expect
(
actionIconText
.
text
.
style
.
color
,
Colors
.
white
);
expect
(
text
.
style
,
Typography
.
material2014
().
englishLike
.
bodyText2
.
merge
(
Typography
.
material2014
().
white
.
bodyText2
));
expect
(
actionIconText
.
text
.
style
!
.
color
,
Colors
.
white
);
expect
(
text
.
style
,
Typography
.
material2014
().
englishLike
.
bodyText2
!
.
merge
(
Typography
.
material2014
().
white
.
bodyText2
));
});
testWidgets
(
'AppBar uses values from AppBarTheme'
,
(
WidgetTester
tester
)
async
{
...
...
@@ -60,14 +58,14 @@ void main() {
final
RichText
actionIconText
=
_getAppBarIconRichText
(
tester
);
final
DefaultTextStyle
text
=
_getAppBarText
(
tester
);
expect
(
SystemChrome
.
latestStyle
.
statusBarBrightness
,
appBarTheme
.
brightness
);
expect
(
SystemChrome
.
latestStyle
!
.
statusBarBrightness
,
appBarTheme
.
brightness
);
expect
(
widget
.
color
,
appBarTheme
.
color
);
expect
(
widget
.
elevation
,
appBarTheme
.
elevation
);
expect
(
widget
.
shadowColor
,
appBarTheme
.
shadowColor
);
expect
(
iconTheme
.
data
,
appBarTheme
.
iconTheme
);
expect
(
actionsIconTheme
.
data
,
appBarTheme
.
actionsIconTheme
);
expect
(
actionIconText
.
text
.
style
.
color
,
appBarTheme
.
actionsIconTheme
.
color
);
expect
(
text
.
style
,
appBarTheme
.
textTheme
.
bodyText2
);
expect
(
actionIconText
.
text
.
style
!.
color
,
appBarTheme
.
actionsIconTheme
!
.
color
);
expect
(
text
.
style
,
appBarTheme
.
textTheme
!
.
bodyText2
);
});
testWidgets
(
'AppBar widget properties take priority over theme'
,
(
WidgetTester
tester
)
async
{
...
...
@@ -103,13 +101,13 @@ void main() {
final
RichText
actionIconText
=
_getAppBarIconRichText
(
tester
);
final
DefaultTextStyle
text
=
_getAppBarText
(
tester
);
expect
(
SystemChrome
.
latestStyle
.
statusBarBrightness
,
brightness
);
expect
(
SystemChrome
.
latestStyle
!
.
statusBarBrightness
,
brightness
);
expect
(
widget
.
color
,
color
);
expect
(
widget
.
elevation
,
elevation
);
expect
(
widget
.
shadowColor
,
shadowColor
);
expect
(
iconTheme
.
data
,
iconThemeData
);
expect
(
actionsIconTheme
.
data
,
actionsIconThemeData
);
expect
(
actionIconText
.
text
.
style
.
color
,
actionsIconThemeData
.
color
);
expect
(
actionIconText
.
text
.
style
!
.
color
,
actionsIconThemeData
.
color
);
expect
(
text
.
style
,
textTheme
.
bodyText2
);
});
...
...
@@ -132,7 +130,7 @@ void main() {
));
final
RichText
actionIconText
=
_getAppBarIconRichText
(
tester
);
expect
(
actionIconText
.
text
.
style
.
color
,
color
);
expect
(
actionIconText
.
text
.
style
!
.
color
,
color
);
});
testWidgets
(
'AppBarTheme properties take priority over ThemeData properties'
,
(
WidgetTester
tester
)
async
{
...
...
@@ -154,14 +152,14 @@ void main() {
final
RichText
actionIconText
=
_getAppBarIconRichText
(
tester
);
final
DefaultTextStyle
text
=
_getAppBarText
(
tester
);
expect
(
SystemChrome
.
latestStyle
.
statusBarBrightness
,
appBarTheme
.
brightness
);
expect
(
SystemChrome
.
latestStyle
!
.
statusBarBrightness
,
appBarTheme
.
brightness
);
expect
(
widget
.
color
,
appBarTheme
.
color
);
expect
(
widget
.
elevation
,
appBarTheme
.
elevation
);
expect
(
widget
.
shadowColor
,
appBarTheme
.
shadowColor
);
expect
(
iconTheme
.
data
,
appBarTheme
.
iconTheme
);
expect
(
actionsIconTheme
.
data
,
appBarTheme
.
actionsIconTheme
);
expect
(
actionIconText
.
text
.
style
.
color
,
appBarTheme
.
actionsIconTheme
.
color
);
expect
(
text
.
style
,
appBarTheme
.
textTheme
.
bodyText2
);
expect
(
actionIconText
.
text
.
style
!.
color
,
appBarTheme
.
actionsIconTheme
!
.
color
);
expect
(
text
.
style
,
appBarTheme
.
textTheme
!
.
bodyText2
);
});
testWidgets
(
'ThemeData properties are used when no AppBarTheme is set'
,
(
WidgetTester
tester
)
async
{
...
...
@@ -182,15 +180,15 @@ void main() {
final
RichText
actionIconText
=
_getAppBarIconRichText
(
tester
);
final
DefaultTextStyle
text
=
_getAppBarText
(
tester
);
expect
(
SystemChrome
.
latestStyle
.
statusBarBrightness
,
themeData
.
brightness
);
expect
(
SystemChrome
.
latestStyle
!
.
statusBarBrightness
,
themeData
.
brightness
);
expect
(
widget
.
color
,
themeData
.
primaryColor
);
expect
(
widget
.
elevation
,
4.0
);
expect
(
widget
.
shadowColor
,
Colors
.
black
);
expect
(
iconTheme
.
data
,
themeData
.
primaryIconTheme
);
expect
(
actionsIconTheme
.
data
,
themeData
.
primaryIconTheme
);
expect
(
actionIconText
.
text
.
style
.
color
,
themeData
.
primaryIconTheme
.
color
);
expect
(
actionIconText
.
text
.
style
!
.
color
,
themeData
.
primaryIconTheme
.
color
);
// Default value for ThemeData.typography is Typography.material2014()
expect
(
text
.
style
,
Typography
.
material2014
().
englishLike
.
bodyText2
.
merge
(
Typography
.
material2014
().
white
.
bodyText2
).
merge
(
themeData
.
primaryTextTheme
.
bodyText2
));
expect
(
text
.
style
,
Typography
.
material2014
().
englishLike
.
bodyText2
!
.
merge
(
Typography
.
material2014
().
white
.
bodyText2
).
merge
(
themeData
.
primaryTextTheme
.
bodyText2
));
});
testWidgets
(
'AppBar uses AppBarTheme.centerTitle when centerTitle is null'
,
(
WidgetTester
tester
)
async
{
...
...
packages/flutter/test/material/app_builder_test.dart
View file @
c083f02f
...
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter/material.dart'
;
...
...
@@ -15,9 +13,9 @@ void main() {
primarySwatch:
Colors
.
green
,
),
home:
const
Placeholder
(),
builder:
(
BuildContext
context
,
Widget
child
)
{
builder:
(
BuildContext
context
,
Widget
?
child
)
{
log
.
add
(
'build'
);
expect
(
Theme
.
of
(
context
).
primaryColor
,
Colors
.
green
);
expect
(
Theme
.
of
(
context
)
!
.
primaryColor
,
Colors
.
green
);
expect
(
Directionality
.
of
(
context
),
TextDirection
.
ltr
);
expect
(
child
,
isA
<
Navigator
>());
return
const
Placeholder
();
...
...
@@ -49,15 +47,15 @@ void main() {
home:
Builder
(
builder:
(
BuildContext
context
)
{
log
.
add
(
'build'
);
expect
(
Theme
.
of
(
context
).
primaryColor
,
Colors
.
yellow
);
expect
(
Theme
.
of
(
context
)
!
.
primaryColor
,
Colors
.
yellow
);
expect
(
Directionality
.
of
(
context
),
TextDirection
.
rtl
);
return
const
Placeholder
();
},
),
builder:
(
BuildContext
context
,
Widget
child
)
{
builder:
(
BuildContext
context
,
Widget
?
child
)
{
return
Directionality
(
textDirection:
TextDirection
.
rtl
,
child:
child
,
child:
child
!
,
);
},
),
...
...
packages/flutter/test/material/app_test.dart
View file @
c083f02f
...
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import
'package:flutter/foundation.dart'
;
import
'package:flutter/semantics.dart'
;
import
'package:flutter/services.dart'
;
...
...
@@ -12,21 +10,21 @@ import 'package:flutter/cupertino.dart';
import
'package:flutter/material.dart'
;
class
StateMarker
extends
StatefulWidget
{
const
StateMarker
({
Key
key
,
this
.
child
})
:
super
(
key:
key
);
const
StateMarker
({
Key
?
key
,
this
.
child
})
:
super
(
key:
key
);
final
Widget
child
;
final
Widget
?
child
;
@override
StateMarkerState
createState
()
=>
StateMarkerState
();
}
class
StateMarkerState
extends
State
<
StateMarker
>
{
String
marker
;
late
String
marker
;
@override
Widget
build
(
BuildContext
context
)
{
if
(
widget
.
child
!=
null
)
return
widget
.
child
;
return
widget
.
child
!
;
return
Container
();
}
}
...
...
@@ -102,7 +100,7 @@ void main() {
return
Material
(
child:
ElevatedButton
(
child:
const
Text
(
'X'
),
onPressed:
()
{
Navigator
.
of
(
context
).
pushNamed
(
'/next'
);
},
onPressed:
()
{
Navigator
.
of
(
context
)
!
.
pushNamed
(
'/next'
);
},
),
);
}
...
...
@@ -251,7 +249,7 @@ void main() {
});
testWidgets
(
'Return value from pop is correct'
,
(
WidgetTester
tester
)
async
{
Future
<
Object
>
result
;
late
Future
<
Object
>
result
;
await
tester
.
pumpWidget
(
MaterialApp
(
home:
Builder
(
...
...
@@ -260,7 +258,7 @@ void main() {
child:
ElevatedButton
(
child:
const
Text
(
'X'
),
onPressed:
()
async
{
result
=
Navigator
.
of
(
context
).
pushNamed
(
'/a'
);
result
=
Navigator
.
of
(
context
)
!
.
pushNamed
(
'/a'
);
},
),
);
...
...
@@ -272,7 +270,7 @@ void main() {
child:
ElevatedButton
(
child:
const
Text
(
'Y'
),
onPressed:
()
{
Navigator
.
of
(
context
).
pop
(
'all done'
);
Navigator
.
of
(
context
)
!
.
pop
(
'all done'
);
},
),
);
...
...
@@ -394,7 +392,7 @@ void main() {
// Regression test for https://github.com/flutter/flutter/issues/18904
await
tester
.
pumpWidget
(
MaterialApp
(
builder:
(
BuildContext
context
,
Widget
child
)
{
builder:
(
BuildContext
context
,
Widget
?
child
)
{
return
const
SizedBox
();
},
),
...
...
@@ -463,10 +461,10 @@ void main() {
});
testWidgets
(
'Can get text scale from media query'
,
(
WidgetTester
tester
)
async
{
double
textScaleFactor
;
double
?
textScaleFactor
;
await
tester
.
pumpWidget
(
MaterialApp
(
home:
Builder
(
builder:
(
BuildContext
context
)
{
textScaleFactor
=
MediaQuery
.
of
(
context
).
textScaleFactor
;
textScaleFactor
=
MediaQuery
.
of
(
context
)
!
.
textScaleFactor
;
return
Container
();
}),
));
...
...
@@ -502,8 +500,8 @@ void main() {
builder:
(
BuildContext
context
)
{
return
Column
(
children:
<
Widget
>[
Text
(
MaterialLocalizations
.
of
(
context
).
selectAllButtonLabel
),
Text
(
CupertinoLocalizations
.
of
(
context
).
selectAllButtonLabel
),
Text
(
MaterialLocalizations
.
of
(
context
)
!
.
selectAllButtonLabel
),
Text
(
CupertinoLocalizations
.
of
(
context
)
!
.
selectAllButtonLabel
),
],
);
},
...
...
@@ -521,7 +519,7 @@ void main() {
// Mock the Window to explicitly report a light platformBrightness.
tester
.
binding
.
window
.
platformBrightnessTestValue
=
Brightness
.
light
;
ThemeData
appliedTheme
;
late
ThemeData
appliedTheme
;
await
tester
.
pumpWidget
(
MaterialApp
(
theme:
ThemeData
(
...
...
@@ -533,7 +531,7 @@ void main() {
themeMode:
ThemeMode
.
light
,
home:
Builder
(
builder:
(
BuildContext
context
)
{
appliedTheme
=
Theme
.
of
(
context
);
appliedTheme
=
Theme
.
of
(
context
)
!
;
return
const
SizedBox
();
},
),
...
...
@@ -554,7 +552,7 @@ void main() {
themeMode:
ThemeMode
.
light
,
home:
Builder
(
builder:
(
BuildContext
context
)
{
appliedTheme
=
Theme
.
of
(
context
);
appliedTheme
=
Theme
.
of
(
context
)
!
;
return
const
SizedBox
();
},
),
...
...
@@ -567,7 +565,7 @@ void main() {
// Mock the Window to explicitly report a light platformBrightness.
tester
.
binding
.
window
.
platformBrightnessTestValue
=
Brightness
.
light
;
ThemeData
appliedTheme
;
late
ThemeData
appliedTheme
;
await
tester
.
pumpWidget
(
MaterialApp
(
theme:
ThemeData
(
...
...
@@ -579,7 +577,7 @@ void main() {
themeMode:
ThemeMode
.
dark
,
home:
Builder
(
builder:
(
BuildContext
context
)
{
appliedTheme
=
Theme
.
of
(
context
);
appliedTheme
=
Theme
.
of
(
context
)
!
;
return
const
SizedBox
();
},
),
...
...
@@ -600,7 +598,7 @@ void main() {
themeMode:
ThemeMode
.
dark
,
home:
Builder
(
builder:
(
BuildContext
context
)
{
appliedTheme
=
Theme
.
of
(
context
);
appliedTheme
=
Theme
.
of
(
context
)
!
;
return
const
SizedBox
();
},
),
...
...
@@ -614,7 +612,7 @@ void main() {
final
TestWidgetsFlutterBinding
binding
=
tester
.
binding
;
binding
.
window
.
platformBrightnessTestValue
=
Brightness
.
light
;
ThemeData
appliedTheme
;
late
ThemeData
appliedTheme
;
await
tester
.
pumpWidget
(
MaterialApp
(
...
...
@@ -627,7 +625,7 @@ void main() {
themeMode:
ThemeMode
.
system
,
home:
Builder
(
builder:
(
BuildContext
context
)
{
appliedTheme
=
Theme
.
of
(
context
);
appliedTheme
=
Theme
.
of
(
context
)
!
;
return
const
SizedBox
();
},
),
...
...
@@ -641,7 +639,7 @@ void main() {
// Mock the Window to explicitly report a dark platformBrightness.
tester
.
binding
.
window
.
platformBrightnessTestValue
=
Brightness
.
dark
;
ThemeData
appliedTheme
;
late
ThemeData
appliedTheme
;
await
tester
.
pumpWidget
(
MaterialApp
(
theme:
ThemeData
(
...
...
@@ -653,7 +651,7 @@ void main() {
themeMode:
ThemeMode
.
system
,
home:
Builder
(
builder:
(
BuildContext
context
)
{
appliedTheme
=
Theme
.
of
(
context
);
appliedTheme
=
Theme
.
of
(
context
)
!
;
return
const
SizedBox
();
},
),
...
...
@@ -667,7 +665,7 @@ void main() {
final
TestWidgetsFlutterBinding
binding
=
tester
.
binding
;
binding
.
window
.
platformBrightnessTestValue
=
Brightness
.
dark
;
ThemeData
appliedTheme
;
late
ThemeData
appliedTheme
;
await
tester
.
pumpWidget
(
MaterialApp
(
...
...
@@ -676,7 +674,7 @@ void main() {
),
home:
Builder
(
builder:
(
BuildContext
context
)
{
appliedTheme
=
Theme
.
of
(
context
);
appliedTheme
=
Theme
.
of
(
context
)
!
;
return
const
SizedBox
();
},
),
...
...
@@ -691,13 +689,13 @@ void main() {
final
TestWidgetsFlutterBinding
binding
=
tester
.
binding
;
binding
.
window
.
platformBrightnessTestValue
=
Brightness
.
dark
;
ThemeData
appliedTheme
;
late
ThemeData
appliedTheme
;
await
tester
.
pumpWidget
(
MaterialApp
(
home:
Builder
(
builder:
(
BuildContext
context
)
{
appliedTheme
=
Theme
.
of
(
context
);
appliedTheme
=
Theme
.
of
(
context
)
!
;
return
const
SizedBox
();
},
),
...
...
@@ -712,7 +710,7 @@ void main() {
final
TestWidgetsFlutterBinding
binding
=
tester
.
binding
;
binding
.
window
.
platformBrightnessTestValue
=
Brightness
.
light
;
ThemeData
appliedTheme
;
late
ThemeData
appliedTheme
;
await
tester
.
pumpWidget
(
MaterialApp
(
...
...
@@ -721,7 +719,7 @@ void main() {
),
home:
Builder
(
builder:
(
BuildContext
context
)
{
appliedTheme
=
Theme
.
of
(
context
);
appliedTheme
=
Theme
.
of
(
context
)
!
;
return
const
SizedBox
();
},
),
...
...
@@ -736,7 +734,7 @@ void main() {
final
TestWidgetsFlutterBinding
binding
=
tester
.
binding
;
binding
.
window
.
platformBrightnessTestValue
=
Brightness
.
dark
;
ThemeData
appliedTheme
;
late
ThemeData
appliedTheme
;
await
tester
.
pumpWidget
(
MaterialApp
(
...
...
@@ -748,7 +746,7 @@ void main() {
),
home:
Builder
(
builder:
(
BuildContext
context
)
{
appliedTheme
=
Theme
.
of
(
context
);
appliedTheme
=
Theme
.
of
(
context
)
!
;
return
const
SizedBox
();
},
),
...
...
@@ -762,7 +760,7 @@ void main() {
tester
.
binding
.
window
.
platformBrightnessTestValue
=
Brightness
.
light
;
tester
.
binding
.
window
.
accessibilityFeaturesTestValue
=
MockAccessibilityFeature
();
ThemeData
appliedTheme
;
late
ThemeData
appliedTheme
;
await
tester
.
pumpWidget
(
MaterialApp
(
...
...
@@ -774,7 +772,7 @@ void main() {
),
home:
Builder
(
builder:
(
BuildContext
context
)
{
appliedTheme
=
Theme
.
of
(
context
);
appliedTheme
=
Theme
.
of
(
context
)
!
;
return
const
SizedBox
();
},
),
...
...
@@ -789,7 +787,7 @@ void main() {
tester
.
binding
.
window
.
platformBrightnessTestValue
=
Brightness
.
dark
;
tester
.
binding
.
window
.
accessibilityFeaturesTestValue
=
MockAccessibilityFeature
();
ThemeData
appliedTheme
;
late
ThemeData
appliedTheme
;
await
tester
.
pumpWidget
(
MaterialApp
(
...
...
@@ -807,7 +805,7 @@ void main() {
),
home:
Builder
(
builder:
(
BuildContext
context
)
{
appliedTheme
=
Theme
.
of
(
context
);
appliedTheme
=
Theme
.
of
(
context
)
!
;
return
const
SizedBox
();
},
),
...
...
@@ -822,7 +820,7 @@ void main() {
tester
.
binding
.
window
.
platformBrightnessTestValue
=
Brightness
.
dark
;
tester
.
binding
.
window
.
accessibilityFeaturesTestValue
=
MockAccessibilityFeature
();
ThemeData
appliedTheme
;
late
ThemeData
appliedTheme
;
await
tester
.
pumpWidget
(
MaterialApp
(
...
...
@@ -834,7 +832,7 @@ void main() {
),
home:
Builder
(
builder:
(
BuildContext
context
)
{
appliedTheme
=
Theme
.
of
(
context
);
appliedTheme
=
Theme
.
of
(
context
)
!
;
return
const
SizedBox
();
},
),
...
...
@@ -851,8 +849,8 @@ void main() {
final
TestWidgetsFlutterBinding
binding
=
tester
.
binding
;
binding
.
window
.
platformBrightnessTestValue
=
Brightness
.
light
;
ThemeData
themeBeforeBrightnessChange
;
ThemeData
themeAfterBrightnessChange
;
ThemeData
?
themeBeforeBrightnessChange
;
ThemeData
?
themeAfterBrightnessChange
;
await
tester
.
pumpWidget
(
MaterialApp
(
...
...
@@ -880,8 +878,8 @@ void main() {
binding
.
window
.
platformBrightnessTestValue
=
Brightness
.
dark
;
await
tester
.
pumpAndSettle
();
expect
(
themeBeforeBrightnessChange
.
brightness
,
Brightness
.
light
);
expect
(
themeAfterBrightnessChange
.
brightness
,
Brightness
.
dark
);
expect
(
themeBeforeBrightnessChange
!
.
brightness
,
Brightness
.
light
);
expect
(
themeAfterBrightnessChange
!
.
brightness
,
Brightness
.
dark
);
});
testWidgets
(
'MaterialApp can customize initial routes'
,
(
WidgetTester
tester
)
async
{
...
...
@@ -921,7 +919,7 @@ void main() {
expect
(
find
.
text
(
'non-regular page one'
),
findsNothing
);
expect
(
find
.
text
(
'regular page one'
),
findsNothing
);
expect
(
find
.
text
(
'regular page two'
),
findsNothing
);
navigatorKey
.
currentState
.
pop
();
navigatorKey
.
currentState
!
.
pop
();
await
tester
.
pumpAndSettle
();
expect
(
find
.
text
(
'non-regular page two'
),
findsNothing
);
expect
(
find
.
text
(
'non-regular page one'
),
findsOneWidget
);
...
...
@@ -931,7 +929,7 @@ void main() {
testWidgets
(
'MaterialApp does create HeroController with the MaterialRectArcTween'
,
(
WidgetTester
tester
)
async
{
final
HeroController
controller
=
MaterialApp
.
createMaterialHeroController
();
final
Tween
<
Rect
>
tween
=
controller
.
createRectTween
(
final
Tween
<
Rect
?>
tween
=
controller
.
createRectTween
!
(
const
Rect
.
fromLTRB
(
0.0
,
0.0
,
10.0
,
10.0
),
const
Rect
.
fromLTRB
(
0.0
,
0.0
,
20.0
,
20.0
)
);
...
...
@@ -962,7 +960,7 @@ void main() {
);
final
SimpleNavigatorRouterDelegate
delegate
=
SimpleNavigatorRouterDelegate
(
builder:
(
BuildContext
context
,
RouteInformation
information
)
{
return
Text
(
information
.
location
);
return
Text
(
information
.
location
!
);
},
onPopPage:
(
Route
<
void
>
route
,
void
result
,
SimpleNavigatorRouterDelegate
delegate
)
{
delegate
.
routeInformation
=
const
RouteInformation
(
...
...
@@ -980,15 +978,15 @@ void main() {
// Simulate android back button intent.
final
ByteData
message
=
const
JSONMethodCodec
().
encodeMethodCall
(
const
MethodCall
(
'popRoute'
));
await
ServicesBinding
.
instance
.
defaultBinaryMessenger
.
handlePlatformMessage
(
'flutter/navigation'
,
message
,
(
_
)
{
});
await
ServicesBinding
.
instance
!
.
defaultBinaryMessenger
.
handlePlatformMessage
(
'flutter/navigation'
,
message
,
(
_
)
{
});
await
tester
.
pumpAndSettle
();
expect
(
find
.
text
(
'popped'
),
findsOneWidget
);
});
testWidgets
(
'MaterialApp.builder can build app without a Navigator'
,
(
WidgetTester
tester
)
async
{
Widget
builderChild
;
Widget
?
builderChild
;
await
tester
.
pumpWidget
(
MaterialApp
(
builder:
(
BuildContext
context
,
Widget
child
)
{
builder:
(
BuildContext
context
,
Widget
?
child
)
{
builderChild
=
child
;
return
Container
();
},
...
...
@@ -1036,15 +1034,15 @@ class SimpleRouteInformationParser extends RouteInformationParser<RouteInformati
class
SimpleNavigatorRouterDelegate
extends
RouterDelegate
<
RouteInformation
>
with
PopNavigatorRouterDelegateMixin
<
RouteInformation
>,
ChangeNotifier
{
SimpleNavigatorRouterDelegate
({
@
required
this
.
builder
,
this
.
onPopPage
,
required
this
.
builder
,
required
this
.
onPopPage
,
});
@override
GlobalKey
<
NavigatorState
>
navigatorKey
=
GlobalKey
<
NavigatorState
>();
RouteInformation
get
routeInformation
=>
_routeInformation
;
RouteInformation
_routeInformation
;
late
RouteInformation
_routeInformation
;
set
routeInformation
(
RouteInformation
newValue
)
{
_routeInformation
=
newValue
;
notifyListeners
();
...
...
@@ -1075,7 +1073,7 @@ class SimpleNavigatorRouterDelegate extends RouterDelegate<RouteInformation> wit
child:
Text
(
'base'
),
),
MaterialPage
<
void
>(
key:
ValueKey
<
String
>(
routeInformation
?.
location
),
key:
ValueKey
<
String
>(
routeInformation
.
location
!
),
child:
builder
(
context
,
routeInformation
),
)
],
...
...
packages/flutter/test/material/arc_test.dart
View file @
c083f02f
...
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter/material.dart'
;
...
...
packages/flutter/test/material/back_button_test.dart
View file @
c083f02f
...
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import
'package:flutter/material.dart'
;
import
'package:flutter/rendering.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
...
...
@@ -132,7 +130,7 @@ void main() {
of:
find
.
byType
(
BackButton
),
matching:
find
.
byType
(
RichText
)
));
expect
(
iconText
.
text
.
style
.
color
,
Colors
.
blue
);
expect
(
iconText
.
text
.
style
!
.
color
,
Colors
.
blue
);
});
testWidgets
(
'BackButton semantics'
,
(
WidgetTester
tester
)
async
{
...
...
@@ -182,7 +180,7 @@ void main() {
of:
find
.
byType
(
CloseButton
),
matching:
find
.
byType
(
RichText
)
));
expect
(
iconText
.
text
.
style
.
color
,
Colors
.
red
);
expect
(
iconText
.
text
.
style
!
.
color
,
Colors
.
red
);
});
testWidgets
(
'CloseButton onPressed overrides default pop behavior'
,
(
WidgetTester
tester
)
async
{
...
...
packages/flutter/test/material/banner_test.dart
View file @
c083f02f
...
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import
'package:flutter/material.dart'
;
import
'package:flutter/rendering.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
...
...
@@ -260,5 +258,5 @@ Container _getContainerFromBanner(WidgetTester tester) {
}
RenderParagraph
_getTextRenderObjectFromDialog
(
WidgetTester
tester
,
String
text
)
{
return
tester
.
element
<
StatelessElement
>(
find
.
descendant
(
of:
find
.
byType
(
MaterialBanner
),
matching:
find
.
text
(
text
))).
renderObject
as
RenderParagraph
;
return
tester
.
element
<
StatelessElement
>(
find
.
descendant
(
of:
find
.
byType
(
MaterialBanner
),
matching:
find
.
text
(
text
))).
renderObject
!
as
RenderParagraph
;
}
packages/flutter/test/material/banner_theme_test.dart
View file @
c083f02f
...
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import
'package:flutter/material.dart'
;
import
'package:flutter/rendering.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
...
...
@@ -70,7 +68,7 @@ void main() {
final
RenderParagraph
content
=
_getTextRenderObjectFromDialog
(
tester
,
contentText
);
expect
(
container
.
color
,
const
Color
(
0xffffffff
));
// Default value for ThemeData.typography is Typography.material2014()
expect
(
content
.
text
.
style
,
Typography
.
material2014
().
englishLike
.
bodyText2
.
merge
(
Typography
.
material2014
().
black
.
bodyText2
));
expect
(
content
.
text
.
style
,
Typography
.
material2014
().
englishLike
.
bodyText2
!
.
merge
(
Typography
.
material2014
().
black
.
bodyText2
));
});
testWidgets
(
'MaterialBanner uses values from MaterialBannerThemeData'
,
(
WidgetTester
tester
)
async
{
...
...
@@ -185,7 +183,7 @@ Finder _containerFinder() {
}
RenderParagraph
_getTextRenderObjectFromDialog
(
WidgetTester
tester
,
String
text
)
{
return
tester
.
element
<
StatelessElement
>(
_textFinder
(
text
)).
renderObject
as
RenderParagraph
;
return
tester
.
element
<
StatelessElement
>(
_textFinder
(
text
)).
renderObject
!
as
RenderParagraph
;
}
Finder
_textFinder
(
String
text
)
{
...
...
packages/flutter/test/material/bottom_app_bar_test.dart
View file @
c083f02f
...
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/rendering.dart'
;
...
...
@@ -90,7 +88,7 @@ void main() {
home:
Builder
(
builder:
(
BuildContext
context
)
{
return
Theme
(
data:
Theme
.
of
(
context
).
copyWith
(
bottomAppBarColor:
const
Color
(
0xffffff00
)),
data:
Theme
.
of
(
context
)
!
.
copyWith
(
bottomAppBarColor:
const
Color
(
0xffffff00
)),
child:
const
Scaffold
(
floatingActionButton:
FloatingActionButton
(
onPressed:
null
,
...
...
@@ -115,7 +113,7 @@ void main() {
home:
Builder
(
builder:
(
BuildContext
context
)
{
return
Theme
(
data:
Theme
.
of
(
context
).
copyWith
(
bottomAppBarColor:
const
Color
(
0xffffff00
)),
data:
Theme
.
of
(
context
)
!
.
copyWith
(
bottomAppBarColor:
const
Color
(
0xffffff00
)),
child:
const
Scaffold
(
floatingActionButton:
FloatingActionButton
(
onPressed:
null
,
...
...
@@ -392,19 +390,19 @@ void main() {
class
ClipCachePainter
extends
CustomPainter
{
ClipCachePainter
(
this
.
context
);
Path
value
;
late
Path
value
;
BuildContext
context
;
@override
void
paint
(
Canvas
canvas
,
Size
size
)
{
final
RenderPhysicalShape
physicalShape
=
findPhysicalShapeChild
(
context
);
value
=
physicalShape
.
clipper
.
getClip
(
size
);
final
RenderPhysicalShape
physicalShape
=
findPhysicalShapeChild
(
context
)
!
;
value
=
physicalShape
.
clipper
!
.
getClip
(
size
);
}
RenderPhysicalShape
findPhysicalShapeChild
(
BuildContext
context
)
{
RenderPhysicalShape
result
;
RenderPhysicalShape
?
findPhysicalShapeChild
(
BuildContext
context
)
{
RenderPhysicalShape
?
result
;
context
.
visitChildElements
((
Element
e
)
{
final
RenderObject
renderObject
=
e
.
findRenderObject
();
final
RenderObject
renderObject
=
e
.
findRenderObject
()
!
;
if
(
renderObject
.
runtimeType
==
RenderPhysicalShape
)
{
assert
(
result
==
null
);
result
=
renderObject
as
RenderPhysicalShape
;
...
...
@@ -422,7 +420,7 @@ class ClipCachePainter extends CustomPainter {
}
class
ShapeListener
extends
StatefulWidget
{
const
ShapeListener
(
this
.
child
,
{
Key
key
})
:
super
(
key:
key
);
const
ShapeListener
(
this
.
child
,
{
Key
?
key
})
:
super
(
key:
key
);
final
Widget
child
;
...
...
@@ -440,7 +438,7 @@ class ShapeListenerState extends State<ShapeListener> {
);
}
ClipCachePainter
cache
;
late
ClipCachePainter
cache
;
@override
void
didChangeDependencies
()
{
...
...
@@ -454,7 +452,7 @@ class RectangularNotch extends NotchedShape {
const
RectangularNotch
();
@override
Path
getOuterPath
(
Rect
host
,
Rect
guest
)
{
Path
getOuterPath
(
Rect
host
,
Rect
?
guest
)
{
if
(
guest
==
null
)
return
Path
()..
addRect
(
host
);
return
Path
()
...
...
packages/flutter/test/material/bottom_app_bar_theme_test.dart
View file @
c083f02f
...
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import
'package:flutter/material.dart'
;
import
'package:flutter/rendering.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
...
...
packages/flutter/test/material/bottom_navigation_bar_test.dart
View file @
c083f02f
...
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import
'dart:ui'
;
import
'package:flutter/material.dart'
;
...
...
@@ -15,7 +13,7 @@ import '../rendering/mock_canvas.dart';
void
main
(
)
{
testWidgets
(
'BottomNavigationBar callback test'
,
(
WidgetTester
tester
)
async
{
int
mutatedIndex
;
late
int
mutatedIndex
;
await
tester
.
pumpWidget
(
MaterialApp
(
...
...
@@ -100,8 +98,8 @@ void main() {
const
double
selectedFontSize
=
14.0
;
const
double
unselectedFontSize
=
12.0
;
final
TextStyle
selectedFontStyle
=
tester
.
renderObject
<
RenderParagraph
>(
find
.
text
(
'AC'
)).
text
.
style
;
final
TextStyle
unselectedFontStyle
=
tester
.
renderObject
<
RenderParagraph
>(
find
.
text
(
'Alarm'
)).
text
.
style
;
final
TextStyle
selectedFontStyle
=
tester
.
renderObject
<
RenderParagraph
>(
find
.
text
(
'AC'
)).
text
.
style
!
;
final
TextStyle
unselectedFontStyle
=
tester
.
renderObject
<
RenderParagraph
>(
find
.
text
(
'Alarm'
)).
text
.
style
!
;
final
TextStyle
selectedIcon
=
_iconStyle
(
tester
,
Icons
.
ac_unit
);
final
TextStyle
unselectedIcon
=
_iconStyle
(
tester
,
Icons
.
access_alarm
);
expect
(
selectedFontStyle
.
color
,
equals
(
primaryColor
));
...
...
@@ -161,13 +159,13 @@ void main() {
),
);
final
TextStyle
selectedFontStyle
=
tester
.
renderObject
<
RenderParagraph
>(
find
.
text
(
'AC'
)).
text
.
style
;
final
TextStyle
unselectedFontStyle
=
tester
.
renderObject
<
RenderParagraph
>(
find
.
text
(
'Alarm'
)).
text
.
style
;
final
TextStyle
selectedFontStyle
=
tester
.
renderObject
<
RenderParagraph
>(
find
.
text
(
'AC'
)).
text
.
style
!
;
final
TextStyle
unselectedFontStyle
=
tester
.
renderObject
<
RenderParagraph
>(
find
.
text
(
'Alarm'
)).
text
.
style
!
;
expect
(
selectedFontStyle
.
fontSize
,
equals
(
selectedTextStyle
.
fontSize
));
expect
(
selectedFontStyle
.
fontWeight
,
equals
(
selectedTextStyle
.
fontWeight
));
expect
(
tester
.
firstWidget
<
Transform
>(
find
.
ancestor
(
of:
find
.
text
(
'Alarm'
),
matching:
find
.
byType
(
Transform
))).
transform
,
equals
(
Matrix4
.
diagonal3
(
Vector3
.
all
(
unselectedTextStyle
.
fontSize
/
selectedTextStyle
.
fontSize
))),
equals
(
Matrix4
.
diagonal3
(
Vector3
.
all
(
unselectedTextStyle
.
fontSize
!
/
selectedTextStyle
.
fontSize
!
))),
);
expect
(
unselectedFontStyle
.
fontWeight
,
equals
(
unselectedTextStyle
.
fontWeight
));
});
...
...
@@ -202,11 +200,11 @@ void main() {
),
);
final
TextStyle
selectedFontStyle
=
tester
.
renderObject
<
RenderParagraph
>(
find
.
text
(
'AC'
)).
text
.
style
;
final
TextStyle
selectedFontStyle
=
tester
.
renderObject
<
RenderParagraph
>(
find
.
text
(
'AC'
)).
text
.
style
!
;
expect
(
selectedFontStyle
.
fontSize
,
equals
(
selectedTextStyle
.
fontSize
));
expect
(
tester
.
firstWidget
<
Transform
>(
find
.
ancestor
(
of:
find
.
text
(
'Alarm'
),
matching:
find
.
byType
(
Transform
))).
transform
,
equals
(
Matrix4
.
diagonal3
(
Vector3
.
all
(
unselectedTextStyle
.
fontSize
/
selectedTextStyle
.
fontSize
))),
equals
(
Matrix4
.
diagonal3
(
Vector3
.
all
(
unselectedTextStyle
.
fontSize
!
/
selectedTextStyle
.
fontSize
!
))),
);
});
...
...
@@ -274,8 +272,8 @@ void main() {
),
);
final
TextStyle
selectedFontStyle
=
tester
.
renderObject
<
RenderParagraph
>(
find
.
text
(
'AC'
)).
text
.
style
;
final
TextStyle
unselectedFontStyle
=
tester
.
renderObject
<
RenderParagraph
>(
find
.
text
(
'Alarm'
)).
text
.
style
;
final
TextStyle
selectedFontStyle
=
tester
.
renderObject
<
RenderParagraph
>(
find
.
text
(
'AC'
)).
text
.
style
!
;
final
TextStyle
unselectedFontStyle
=
tester
.
renderObject
<
RenderParagraph
>(
find
.
text
(
'Alarm'
)).
text
.
style
!
;
final
TextStyle
selectedIcon
=
_iconStyle
(
tester
,
Icons
.
ac_unit
);
final
TextStyle
unselectedIcon
=
_iconStyle
(
tester
,
Icons
.
access_alarm
);
expect
(
selectedIcon
.
color
,
equals
(
selectedIconTheme
.
color
));
...
...
@@ -433,8 +431,8 @@ void main() {
);
const
double
selectedFontSize
=
14.0
;
expect
(
tester
.
renderObject
<
RenderParagraph
>(
find
.
text
(
'AC'
)).
text
.
style
.
fontSize
,
selectedFontSize
);
expect
(
tester
.
renderObject
<
RenderParagraph
>(
find
.
text
(
'AC'
)).
text
.
style
.
color
,
equals
(
Colors
.
white
));
expect
(
tester
.
renderObject
<
RenderParagraph
>(
find
.
text
(
'AC'
)).
text
.
style
!
.
fontSize
,
selectedFontSize
);
expect
(
tester
.
renderObject
<
RenderParagraph
>(
find
.
text
(
'AC'
)).
text
.
style
!
.
color
,
equals
(
Colors
.
white
));
expect
(
_getOpacity
(
tester
,
'Alarm'
),
equals
(
0.0
));
expect
(
_getMaterial
(
tester
).
elevation
,
equals
(
8.0
));
});
...
...
@@ -475,15 +473,15 @@ void main() {
),
);
expect
(
tester
.
renderObject
<
RenderParagraph
>(
find
.
text
(
'AC'
)).
text
.
style
.
fontSize
,
selectedFontSize
);
expect
(
tester
.
renderObject
<
RenderParagraph
>(
find
.
text
(
'AC'
)).
text
.
style
!
.
fontSize
,
selectedFontSize
);
// Unselected label has a font size of 18 but is scaled down to be font size 14.
expect
(
tester
.
renderObject
<
RenderParagraph
>(
find
.
text
(
'Alarm'
)).
text
.
style
.
fontSize
,
selectedFontSize
);
expect
(
tester
.
renderObject
<
RenderParagraph
>(
find
.
text
(
'Alarm'
)).
text
.
style
!
.
fontSize
,
selectedFontSize
);
expect
(
tester
.
firstWidget
<
Transform
>(
find
.
ancestor
(
of:
find
.
text
(
'Alarm'
),
matching:
find
.
byType
(
Transform
))).
transform
,
equals
(
Matrix4
.
diagonal3
(
Vector3
.
all
(
unselectedFontSize
/
selectedFontSize
))),
);
expect
(
tester
.
renderObject
<
RenderParagraph
>(
find
.
text
(
'AC'
)).
text
.
style
.
color
,
equals
(
selectedColor
));
expect
(
tester
.
renderObject
<
RenderParagraph
>(
find
.
text
(
'Alarm'
)).
text
.
style
.
color
,
equals
(
unselectedColor
));
expect
(
tester
.
renderObject
<
RenderParagraph
>(
find
.
text
(
'AC'
)).
text
.
style
!
.
color
,
equals
(
selectedColor
));
expect
(
tester
.
renderObject
<
RenderParagraph
>(
find
.
text
(
'Alarm'
)).
text
.
style
!
.
color
,
equals
(
unselectedColor
));
// There should not be any [Opacity] or [FadeTransition] widgets
// since showUnselectedLabels and showSelectedLabels are true.
final
Finder
findOpacity
=
find
.
descendant
(
...
...
@@ -535,8 +533,8 @@ void main() {
),
);
expect
(
tester
.
renderObject
<
RenderParagraph
>(
find
.
text
(
'AC'
)).
text
.
style
.
fontSize
,
selectedFontSize
);
expect
(
tester
.
renderObject
<
RenderParagraph
>(
find
.
text
(
'AC'
)).
text
.
style
.
color
,
equals
(
selectedColor
));
expect
(
tester
.
renderObject
<
RenderParagraph
>(
find
.
text
(
'AC'
)).
text
.
style
!
.
fontSize
,
selectedFontSize
);
expect
(
tester
.
renderObject
<
RenderParagraph
>(
find
.
text
(
'AC'
)).
text
.
style
!
.
color
,
equals
(
selectedColor
));
expect
(
_getOpacity
(
tester
,
'Alarm'
),
equals
(
0.0
));
});
...
...
@@ -668,7 +666,7 @@ void main() {
),
);
expect
(
tester
.
renderObject
<
RenderParagraph
>(
find
.
text
(
'AC'
)).
text
.
style
.
color
,
equals
(
fixedColor
));
expect
(
tester
.
renderObject
<
RenderParagraph
>(
find
.
text
(
'AC'
)).
text
.
style
!
.
color
,
equals
(
fixedColor
));
});
testWidgets
(
'setting selectedFontSize to zero hides all labels'
,
(
WidgetTester
tester
)
async
{
...
...
@@ -875,7 +873,7 @@ void main() {
await
tester
.
tap
(
find
.
text
(
'Alarm'
));
await
tester
.
pump
(
const
Duration
(
seconds:
1
));
expect
(
Theme
.
of
(
tester
.
element
(
find
.
text
(
'Alarm'
))).
brightness
,
equals
(
Brightness
.
dark
));
expect
(
Theme
.
of
(
tester
.
element
(
find
.
text
(
'Alarm'
)))
!
.
brightness
,
equals
(
Brightness
.
dark
));
});
testWidgets
(
'BottomNavigationBar inherits shadowed app theme for fixed navbar'
,
(
WidgetTester
tester
)
async
{
...
...
@@ -913,11 +911,11 @@ void main() {
await
tester
.
tap
(
find
.
text
(
'Alarm'
));
await
tester
.
pump
(
const
Duration
(
seconds:
1
));
expect
(
Theme
.
of
(
tester
.
element
(
find
.
text
(
'Alarm'
))).
brightness
,
equals
(
Brightness
.
dark
));
expect
(
Theme
.
of
(
tester
.
element
(
find
.
text
(
'Alarm'
)))
!
.
brightness
,
equals
(
Brightness
.
dark
));
});
testWidgets
(
'BottomNavigationBar iconSize test'
,
(
WidgetTester
tester
)
async
{
double
builderIconSize
;
late
double
builderIconSize
;
await
tester
.
pumpWidget
(
MaterialApp
(
home:
Scaffold
(
...
...
@@ -932,7 +930,7 @@ void main() {
label:
'B'
,
icon:
Builder
(
builder:
(
BuildContext
context
)
{
builderIconSize
=
IconTheme
.
of
(
context
).
size
;
builderIconSize
=
IconTheme
.
of
(
context
).
size
!
;
return
SizedBox
(
width:
builderIconSize
,
height:
builderIconSize
,
...
...
@@ -1101,7 +1099,7 @@ void main() {
testWidgets
(
'BottomNavigationBar shows tool tips with text scaling on long press when labels are provided'
,
(
WidgetTester
tester
)
async
{
const
String
label
=
'Foo'
;
Widget
buildApp
({
double
textScaleFactor
})
{
Widget
buildApp
({
required
double
textScaleFactor
})
{
return
MediaQuery
(
data:
MediaQueryData
(
textScaleFactor:
textScaleFactor
),
child:
Localizations
(
...
...
@@ -1178,9 +1176,9 @@ void main() {
final
RenderBox
box
=
tester
.
renderObject
(
find
.
byType
(
BottomNavigationBar
));
expect
(
box
.
size
.
height
,
equals
(
kBottomNavigationBarHeight
));
final
RenderBox
itemBoxA
=
tester
.
renderObject
(
find
.
text
(
longTextA
.
data
));
final
RenderBox
itemBoxA
=
tester
.
renderObject
(
find
.
text
(
longTextA
.
data
!
));
expect
(
itemBoxA
.
size
,
equals
(
const
Size
(
400.0
,
14.0
)));
final
RenderBox
itemBoxB
=
tester
.
renderObject
(
find
.
text
(
longTextB
.
data
));
final
RenderBox
itemBoxB
=
tester
.
renderObject
(
find
.
text
(
longTextB
.
data
!
));
expect
(
itemBoxB
.
size
,
equals
(
const
Size
(
400.0
,
14.0
)));
});
...
...
@@ -1767,7 +1765,7 @@ void main() {
await
tester
.
pumpAndSettle
();
expect
(
RendererBinding
.
instance
.
mouseTracker
.
debugDeviceActiveCursor
(
1
),
SystemMouseCursors
.
text
);
expect
(
RendererBinding
.
instance
!
.
mouseTracker
.
debugDeviceActiveCursor
(
1
),
SystemMouseCursors
.
text
);
// Test default cursor
await
tester
.
pumpWidget
(
...
...
@@ -1786,11 +1784,11 @@ void main() {
),
);
expect
(
RendererBinding
.
instance
.
mouseTracker
.
debugDeviceActiveCursor
(
1
),
SystemMouseCursors
.
click
);
expect
(
RendererBinding
.
instance
!
.
mouseTracker
.
debugDeviceActiveCursor
(
1
),
SystemMouseCursors
.
click
);
});
}
Widget
boilerplate
(
{
Widget
bottomNavigationBar
,
@
required
TextDirection
textDirection
})
{
Widget
boilerplate
(
{
Widget
?
bottomNavigationBar
,
required
TextDirection
textDirection
})
{
assert
(
textDirection
!=
null
);
return
MaterialApp
(
home:
Localizations
(
...
...
@@ -1834,7 +1832,7 @@ TextStyle _iconStyle(WidgetTester tester, IconData icon) {
final
RichText
iconRichText
=
tester
.
widget
<
RichText
>(
find
.
descendant
(
of:
find
.
byIcon
(
icon
),
matching:
find
.
byType
(
RichText
)),
);
return
iconRichText
.
text
.
style
;
return
iconRichText
.
text
.
style
!
;
}
EdgeInsets
_itemPadding
(
WidgetTester
tester
,
IconData
icon
)
{
...
...
packages/flutter/test/material/bottom_navigation_bar_theme_test.dart
View file @
c083f02f
...
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import
'package:flutter/material.dart'
;
import
'package:flutter/rendering.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
...
...
@@ -139,14 +137,14 @@ void main() {
),
);
final
TextStyle
selectedFontStyle
=
tester
.
renderObject
<
RenderParagraph
>(
find
.
text
(
'AC'
)).
text
.
style
;
final
TextStyle
selectedFontStyle
=
tester
.
renderObject
<
RenderParagraph
>(
find
.
text
(
'AC'
)).
text
.
style
!
;
final
TextStyle
selectedIcon
=
_iconStyle
(
tester
,
Icons
.
ac_unit
);
final
TextStyle
unselectedIcon
=
_iconStyle
(
tester
,
Icons
.
access_alarm
);
expect
(
selectedFontStyle
.
fontSize
,
selectedFontStyle
.
fontSize
);
// Unselected label has a font size of 22 but is scaled down to be font size 21.
expect
(
tester
.
firstWidget
<
Transform
>(
find
.
ancestor
(
of:
find
.
text
(
'Alarm'
),
matching:
find
.
byType
(
Transform
))).
transform
,
equals
(
Matrix4
.
diagonal3
(
Vector3
.
all
(
unselectedTextStyle
.
fontSize
/
selectedTextStyle
.
fontSize
))),
equals
(
Matrix4
.
diagonal3
(
Vector3
.
all
(
unselectedTextStyle
.
fontSize
!
/
selectedTextStyle
.
fontSize
!
))),
);
expect
(
selectedIcon
.
color
,
equals
(
selectedItemColor
));
expect
(
selectedIcon
.
fontSize
,
equals
(
selectedIconTheme
.
size
));
...
...
@@ -232,14 +230,14 @@ void main() {
),
);
final
TextStyle
selectedFontStyle
=
tester
.
renderObject
<
RenderParagraph
>(
find
.
text
(
'AC'
)).
text
.
style
;
final
TextStyle
selectedFontStyle
=
tester
.
renderObject
<
RenderParagraph
>(
find
.
text
(
'AC'
)).
text
.
style
!
;
final
TextStyle
selectedIcon
=
_iconStyle
(
tester
,
Icons
.
ac_unit
);
final
TextStyle
unselectedIcon
=
_iconStyle
(
tester
,
Icons
.
access_alarm
);
expect
(
selectedFontStyle
.
fontSize
,
selectedFontStyle
.
fontSize
);
// Unselected label has a font size of 22 but is scaled down to be font size 21.
expect
(
tester
.
firstWidget
<
Transform
>(
find
.
ancestor
(
of:
find
.
text
(
'Alarm'
),
matching:
find
.
byType
(
Transform
))).
transform
,
equals
(
Matrix4
.
diagonal3
(
Vector3
.
all
(
unselectedTextStyle
.
fontSize
/
selectedTextStyle
.
fontSize
))),
equals
(
Matrix4
.
diagonal3
(
Vector3
.
all
(
unselectedTextStyle
.
fontSize
!
/
selectedTextStyle
.
fontSize
!
))),
);
expect
(
selectedIcon
.
color
,
equals
(
selectedItemColor
));
expect
(
selectedIcon
.
fontSize
,
equals
(
selectedIconTheme
.
size
));
...
...
@@ -266,7 +264,7 @@ TextStyle _iconStyle(WidgetTester tester, IconData icon) {
final
RichText
iconRichText
=
tester
.
widget
<
RichText
>(
find
.
descendant
(
of:
find
.
byIcon
(
icon
),
matching:
find
.
byType
(
RichText
)),
);
return
iconRichText
.
text
.
style
;
return
iconRichText
.
text
.
style
!
;
}
Material
_material
(
WidgetTester
tester
)
{
...
...
packages/flutter/test/material/bottom_sheet_test.dart
View file @
c083f02f
...
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/widgets.dart'
;
...
...
@@ -28,7 +26,7 @@ void main() {
}
testWidgets
(
'Tapping on a modal BottomSheet should not dismiss it'
,
(
WidgetTester
tester
)
async
{
BuildContext
savedContext
;
late
BuildContext
savedContext
;
await
tester
.
pumpWidget
(
MaterialApp
(
...
...
@@ -64,7 +62,7 @@ void main() {
});
testWidgets
(
'Tapping outside a modal BottomSheet should dismiss it by default'
,
(
WidgetTester
tester
)
async
{
BuildContext
savedContext
;
late
BuildContext
savedContext
;
await
tester
.
pumpWidget
(
MaterialApp
(
home:
Builder
(
...
...
@@ -98,7 +96,7 @@ void main() {
});
testWidgets
(
'Tapping outside a modal BottomSheet should dismiss it when isDismissible=true'
,
(
WidgetTester
tester
)
async
{
BuildContext
savedContext
;
late
BuildContext
savedContext
;
await
tester
.
pumpWidget
(
MaterialApp
(
home:
Builder
(
...
...
@@ -133,7 +131,7 @@ void main() {
});
testWidgets
(
'Verify that the BottomSheet animates non-linearly'
,
(
WidgetTester
tester
)
async
{
BuildContext
savedContext
;
late
BuildContext
savedContext
;
await
tester
.
pumpWidget
(
MaterialApp
(
home:
Builder
(
...
...
@@ -165,7 +163,7 @@ void main() {
});
testWidgets
(
'Tapping outside a modal BottomSheet should not dismiss it when isDismissible=false'
,
(
WidgetTester
tester
)
async
{
BuildContext
savedContext
;
late
BuildContext
savedContext
;
await
tester
.
pumpWidget
(
MaterialApp
(
...
...
@@ -202,7 +200,7 @@ void main() {
});
testWidgets
(
'Swiping down a modal BottomSheet should dismiss it by default'
,
(
WidgetTester
tester
)
async
{
BuildContext
savedContext
;
late
BuildContext
savedContext
;
await
tester
.
pumpWidget
(
MaterialApp
(
home:
Builder
(
...
...
@@ -237,7 +235,7 @@ void main() {
});
testWidgets
(
'Swiping down a modal BottomSheet should not dismiss it when enableDrag is false'
,
(
WidgetTester
tester
)
async
{
BuildContext
savedContext
;
late
BuildContext
savedContext
;
await
tester
.
pumpWidget
(
MaterialApp
(
home:
Builder
(
...
...
@@ -273,7 +271,7 @@ void main() {
});
testWidgets
(
'Swiping down a modal BottomSheet should dismiss it when enableDrag is true'
,
(
WidgetTester
tester
)
async
{
BuildContext
savedContext
;
late
BuildContext
savedContext
;
await
tester
.
pumpWidget
(
MaterialApp
(
home:
Builder
(
...
...
@@ -309,7 +307,7 @@ void main() {
});
testWidgets
(
'Modal BottomSheet builder should only be called once'
,
(
WidgetTester
tester
)
async
{
BuildContext
savedContext
;
late
BuildContext
savedContext
;
await
tester
.
pumpWidget
(
MaterialApp
(
home:
Builder
(
...
...
@@ -354,7 +352,7 @@ void main() {
expect
(
showBottomSheetThenCalled
,
isFalse
);
expect
(
find
.
text
(
'BottomSheet'
),
findsNothing
);
scaffoldKey
.
currentState
.
showBottomSheet
<
void
>((
BuildContext
context
)
{
scaffoldKey
.
currentState
!
.
showBottomSheet
<
void
>((
BuildContext
context
)
{
return
Container
(
margin:
const
EdgeInsets
.
all
(
40.0
),
child:
const
Text
(
'BottomSheet'
),
...
...
@@ -408,7 +406,7 @@ void main() {
),
));
scaffoldKey
.
currentState
.
showBottomSheet
<
void
>((
BuildContext
context
)
{
scaffoldKey
.
currentState
!
.
showBottomSheet
<
void
>((
BuildContext
context
)
{
return
Container
(
margin:
const
EdgeInsets
.
all
(
40.0
),
child:
const
Text
(
'BottomSheet'
),
...
...
@@ -428,8 +426,8 @@ void main() {
});
testWidgets
(
'modal BottomSheet has no top MediaQuery'
,
(
WidgetTester
tester
)
async
{
BuildContext
outerContext
;
BuildContext
innerContext
;
late
BuildContext
outerContext
;
late
BuildContext
innerContext
;
await
tester
.
pumpWidget
(
Localizations
(
locale:
const
Locale
(
'en'
,
'US'
),
...
...
@@ -469,11 +467,11 @@ void main() {
await
tester
.
pump
(
const
Duration
(
seconds:
1
));
expect
(
MediaQuery
.
of
(
outerContext
).
padding
,
MediaQuery
.
of
(
outerContext
)
!
.
padding
,
const
EdgeInsets
.
all
(
50.0
),
);
expect
(
MediaQuery
.
of
(
innerContext
).
padding
,
MediaQuery
.
of
(
innerContext
)
!
.
padding
,
const
EdgeInsets
.
only
(
left:
50.0
,
right:
50.0
,
bottom:
50.0
),
);
});
...
...
@@ -490,7 +488,7 @@ void main() {
));
showModalBottomSheet
<
void
>(
context:
scaffoldKey
.
currentContext
,
builder:
(
BuildContext
context
)
{
showModalBottomSheet
<
void
>(
context:
scaffoldKey
.
currentContext
!
,
builder:
(
BuildContext
context
)
{
return
Container
(
child:
const
Text
(
'BottomSheet'
),
);
...
...
@@ -545,7 +543,7 @@ void main() {
));
showModalBottomSheet
<
void
>(
context:
scaffoldKey
.
currentContext
,
context:
scaffoldKey
.
currentContext
!
,
backgroundColor:
color
,
barrierColor:
barrierColor
,
elevation:
elevation
,
...
...
@@ -584,7 +582,7 @@ void main() {
showModalBottomSheet
<
void
>(
context:
scaffoldKey
.
currentContext
,
context:
scaffoldKey
.
currentContext
!
,
builder:
(
BuildContext
context
)
{
return
DraggableScrollableSheet
(
expand:
false
,
...
...
@@ -710,13 +708,13 @@ void main() {
),
));
RouteSettings
retrievedRouteSettings
;
late
RouteSettings
retrievedRouteSettings
;
showModalBottomSheet
<
void
>(
context:
scaffoldKey
.
currentContext
,
context:
scaffoldKey
.
currentContext
!
,
routeSettings:
routeSettings
,
builder:
(
BuildContext
context
)
{
retrievedRouteSettings
=
ModalRoute
.
of
(
context
).
settings
;
retrievedRouteSettings
=
ModalRoute
.
of
(
context
)
!
.
settings
;
return
Container
(
child:
const
Text
(
'BottomSheet'
),
);
...
...
@@ -731,9 +729,9 @@ void main() {
}
class
_TestPage
extends
StatelessWidget
{
const
_TestPage
({
Key
key
,
this
.
useRootNavigator
})
:
super
(
key:
key
);
const
_TestPage
({
Key
?
key
,
this
.
useRootNavigator
})
:
super
(
key:
key
);
final
bool
useRootNavigator
;
final
bool
?
useRootNavigator
;
@override
Widget
build
(
BuildContext
context
)
{
...
...
@@ -743,7 +741,7 @@ class _TestPage extends StatelessWidget {
onPressed:
()
{
if
(
useRootNavigator
!=
null
)
{
showModalBottomSheet
<
void
>(
useRootNavigator:
useRootNavigator
,
useRootNavigator:
useRootNavigator
!
,
context:
context
,
builder:
(
_
)
=>
const
Text
(
'Modal bottom sheet'
),
);
...
...
packages/flutter/test/material/bottom_sheet_theme_test.dart
View file @
c083f02f
...
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import
'package:flutter/material.dart'
;
import
'package:flutter/rendering.dart'
;
import
'package:flutter/services.dart'
;
...
...
packages/flutter/test/material/button_bar_test.dart
View file @
c083f02f
...
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import
'package:flutter/material.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
...
...
@@ -243,7 +241,7 @@ void main() {
group
(
'button properties override ButtonTheme'
,
()
{
testWidgets
(
'default button properties override ButtonTheme properties'
,
(
WidgetTester
tester
)
async
{
BuildContext
capturedContext
;
late
BuildContext
capturedContext
;
await
tester
.
pumpWidget
(
MaterialApp
(
home:
ButtonBar
(
...
...
@@ -266,7 +264,7 @@ void main() {
});
testWidgets
(
'ButtonBarTheme button properties override defaults and ButtonTheme properties'
,
(
WidgetTester
tester
)
async
{
BuildContext
capturedContext
;
late
BuildContext
capturedContext
;
await
tester
.
pumpWidget
(
MaterialApp
(
home:
ButtonBarTheme
(
...
...
@@ -299,7 +297,7 @@ void main() {
});
testWidgets
(
'ButtonBar button properties override ButtonBarTheme, defaults and ButtonTheme properties'
,
(
WidgetTester
tester
)
async
{
BuildContext
capturedContext
;
late
BuildContext
capturedContext
;
await
tester
.
pumpWidget
(
MaterialApp
(
home:
ButtonBarTheme
(
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment