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
3961a12a
Unverified
Commit
3961a12a
authored
Oct 07, 2020
by
Michael Goderbauer
Committed by
GitHub
Oct 07, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Migrate some material tests to nnbd (#67477)
parent
af0c7aed
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
185 additions
and
256 deletions
+185
-256
popup_menu.dart
packages/flutter/lib/src/material/popup_menu.dart
+1
-2
navigation_rail_test.dart
packages/flutter/test/material/navigation_rail_test.dart
+16
-18
navigation_rail_theme_test.dart
...ges/flutter/test/material/navigation_rail_theme_test.dart
+2
-4
outlined_button_test.dart
packages/flutter/test/material/outlined_button_test.dart
+46
-48
outlined_button_theme_test.dart
...ges/flutter/test/material/outlined_button_theme_test.dart
+12
-14
page_selector_test.dart
packages/flutter/test/material/page_selector_test.dart
+1
-3
page_test.dart
packages/flutter/test/material/page_test.dart
+40
-54
page_transitions_theme_test.dart
...es/flutter/test/material/page_transitions_theme_test.dart
+10
-12
paginated_data_table_test.dart
...ages/flutter/test/material/paginated_data_table_test.dart
+16
-18
persistent_bottom_sheet_test.dart
...s/flutter/test/material/persistent_bottom_sheet_test.dart
+12
-15
popup_menu_test.dart
packages/flutter/test/material/popup_menu_test.dart
+25
-62
popup_menu_theme_test.dart
packages/flutter/test/material/popup_menu_theme_test.dart
+4
-6
No files found.
packages/flutter/lib/src/material/popup_menu.dart
View file @
3961a12a
...
...
@@ -96,8 +96,7 @@ abstract class PopupMenuEntry<T> extends StatefulWidget {
/// * [showMenu], a method to dynamically show a popup menu at a given location.
/// * [PopupMenuButton], an [IconButton] that automatically shows a menu when
/// it is tapped.
// ignore: prefer_void_to_null, https://github.com/dart-lang/sdk/issues/34416
class
PopupMenuDivider
extends
PopupMenuEntry
<
Null
>
{
class
PopupMenuDivider
extends
PopupMenuEntry
<
Never
>
{
/// Creates a horizontal divider for a popup menu.
///
/// By default, the divider has a height of 16 logical pixels.
...
...
packages/flutter/test/material/navigation_rail_test.dart
View file @
3961a12a
...
...
@@ -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'
;
...
...
@@ -26,8 +24,8 @@ void main() {
),
);
final
TextStyle
actualSelectedTextStyle
=
tester
.
renderObject
<
RenderParagraph
>(
find
.
text
(
'Abc'
)).
text
.
style
;
final
TextStyle
actualUnselectedTextStyle
=
tester
.
renderObject
<
RenderParagraph
>(
find
.
text
(
'Def'
)).
text
.
style
;
final
TextStyle
actualSelectedTextStyle
=
tester
.
renderObject
<
RenderParagraph
>(
find
.
text
(
'Abc'
)).
text
.
style
!
;
final
TextStyle
actualUnselectedTextStyle
=
tester
.
renderObject
<
RenderParagraph
>(
find
.
text
(
'Def'
)).
text
.
style
!
;
expect
(
actualSelectedTextStyle
.
fontSize
,
equals
(
selectedTextStyle
.
fontSize
));
expect
(
actualSelectedTextStyle
.
fontWeight
,
equals
(
selectedTextStyle
.
fontWeight
));
expect
(
actualUnselectedTextStyle
.
fontSize
,
equals
(
actualUnselectedTextStyle
.
fontSize
));
...
...
@@ -1416,7 +1414,7 @@ void main() {
testWidgets
(
'Extended rail animates the width and labels appear - [textDirection]=LTR'
,
(
WidgetTester
tester
)
async
{
bool
extended
=
false
;
StateSetter
stateSetter
;
late
StateSetter
stateSetter
;
await
tester
.
pumpWidget
(
MaterialApp
(
...
...
@@ -1553,7 +1551,7 @@ void main() {
testWidgets
(
'Extended rail animates the width and labels appear - [textDirection]=RTL'
,
(
WidgetTester
tester
)
async
{
bool
extended
=
false
;
StateSetter
stateSetter
;
late
StateSetter
stateSetter
;
await
tester
.
pumpWidget
(
MaterialApp
(
...
...
@@ -1697,7 +1695,7 @@ void main() {
testWidgets
(
'Extended rail gets wider with longer labels are larger text scale'
,
(
WidgetTester
tester
)
async
{
bool
extended
=
false
;
StateSetter
stateSetter
;
late
StateSetter
stateSetter
;
await
tester
.
pumpWidget
(
MaterialApp
(
...
...
@@ -1708,7 +1706,7 @@ void main() {
body:
Row
(
children:
<
Widget
>[
MediaQuery
(
data:
MediaQuery
.
of
(
context
).
copyWith
(
textScaleFactor:
3.0
),
data:
MediaQuery
.
of
(
context
)
!
.
copyWith
(
textScaleFactor:
3.0
),
child:
NavigationRail
(
selectedIndex:
0
,
destinations:
const
<
NavigationRailDestination
>[
...
...
@@ -1755,7 +1753,7 @@ void main() {
testWidgets
(
'Extended rail final width can be changed'
,
(
WidgetTester
tester
)
async
{
bool
extended
=
false
;
StateSetter
stateSetter
;
late
StateSetter
stateSetter
;
await
tester
.
pumpWidget
(
MaterialApp
(
...
...
@@ -1797,7 +1795,7 @@ void main() {
/// Regression test for https://github.com/flutter/flutter/issues/65657
testWidgets
(
'Extended rail transition does not jump from the beginning'
,
(
WidgetTester
tester
)
async
{
bool
extended
=
false
;
StateSetter
stateSetter
;
late
StateSetter
stateSetter
;
await
tester
.
pumpWidget
(
MaterialApp
(
...
...
@@ -1855,8 +1853,8 @@ void main() {
testWidgets
(
'Extended rail animation can be consumed'
,
(
WidgetTester
tester
)
async
{
bool
extended
=
false
;
Animation
<
double
>
animation
;
StateSetter
stateSetter
;
late
Animation
<
double
>
animation
;
late
StateSetter
stateSetter
;
await
tester
.
pumpWidget
(
MaterialApp
(
...
...
@@ -1899,7 +1897,7 @@ void main() {
});
testWidgets
(
'onDestinationSelected is called'
,
(
WidgetTester
tester
)
async
{
int
selectedIndex
;
late
int
selectedIndex
;
await
_pumpNavigationRail
(
tester
,
...
...
@@ -2106,14 +2104,14 @@ List<NavigationRailDestination> _destinations() {
Future
<
void
>
_pumpNavigationRail
(
WidgetTester
tester
,
{
double
textScaleFactor
=
1.0
,
NavigationRail
navigationRail
,
required
NavigationRail
navigationRail
,
})
async
{
await
tester
.
pumpWidget
(
MaterialApp
(
home:
Builder
(
builder:
(
BuildContext
context
)
{
return
MediaQuery
(
data:
MediaQuery
.
of
(
context
).
copyWith
(
textScaleFactor:
textScaleFactor
),
data:
MediaQuery
.
of
(
context
)
!
.
copyWith
(
textScaleFactor:
textScaleFactor
),
child:
Scaffold
(
body:
Row
(
children:
<
Widget
>[
...
...
@@ -2131,7 +2129,7 @@ Future<void> _pumpNavigationRail(
);
}
Future
<
void
>
_pumpLocalizedTestRail
(
WidgetTester
tester
,
{
NavigationRailLabelType
labelType
,
bool
extended
=
false
})
async
{
Future
<
void
>
_pumpLocalizedTestRail
(
WidgetTester
tester
,
{
NavigationRailLabelType
?
labelType
,
bool
extended
=
false
})
async
{
await
tester
.
pumpWidget
(
Localizations
(
locale:
const
Locale
(
'en'
,
'US'
),
...
...
@@ -2184,7 +2182,7 @@ TextStyle _iconStyle(WidgetTester tester, IconData icon) {
of:
find
.
byIcon
(
icon
),
matching:
find
.
byType
(
RichText
),
),
).
text
.
style
;
).
text
.
style
!
;
}
Finder
_opacityAboveLabel
(
String
text
)
{
...
...
@@ -2213,4 +2211,4 @@ Material _railMaterial(WidgetTester tester) {
matching:
find
.
byType
(
Material
),
),
);
}
\ No newline at end of file
}
packages/flutter/test/material/navigation_rail_theme_test.dart
View file @
3961a12a
...
...
@@ -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'
;
...
...
@@ -271,7 +269,7 @@ TextStyle _selectedLabelStyle(WidgetTester tester) {
of:
find
.
text
(
'Abc'
),
matching:
find
.
byType
(
RichText
),
),
).
text
.
style
;
).
text
.
style
!
;
}
TextStyle
_unselectedLabelStyle
(
WidgetTester
tester
)
{
...
...
@@ -280,7 +278,7 @@ TextStyle _unselectedLabelStyle(WidgetTester tester) {
of:
find
.
text
(
'Def'
),
matching:
find
.
byType
(
RichText
),
),
).
text
.
style
;
).
text
.
style
!
;
}
Align
_destinationsAlign
(
WidgetTester
tester
)
{
...
...
packages/flutter/test/material/outlined_button_test.dart
View file @
3961a12a
...
...
@@ -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/gestures.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
...
...
@@ -49,10 +47,10 @@ void main() {
),
borderRadius:
BorderRadius
.
circular
(
4.0
),
));
expect
(
material
.
textStyle
.
color
,
colorScheme
.
primary
);
expect
(
material
.
textStyle
.
fontFamily
,
'Roboto'
);
expect
(
material
.
textStyle
.
fontSize
,
14
);
expect
(
material
.
textStyle
.
fontWeight
,
FontWeight
.
w500
);
expect
(
material
.
textStyle
!
.
color
,
colorScheme
.
primary
);
expect
(
material
.
textStyle
!
.
fontFamily
,
'Roboto'
);
expect
(
material
.
textStyle
!
.
fontSize
,
14
);
expect
(
material
.
textStyle
!
.
fontWeight
,
FontWeight
.
w500
);
expect
(
material
.
type
,
MaterialType
.
button
);
final
Offset
center
=
tester
.
getCenter
(
find
.
byType
(
OutlinedButton
));
...
...
@@ -80,10 +78,10 @@ void main() {
),
borderRadius:
BorderRadius
.
circular
(
4.0
),
));
expect
(
material
.
textStyle
.
color
,
colorScheme
.
primary
);
expect
(
material
.
textStyle
.
fontFamily
,
'Roboto'
);
expect
(
material
.
textStyle
.
fontSize
,
14
);
expect
(
material
.
textStyle
.
fontWeight
,
FontWeight
.
w500
);
expect
(
material
.
textStyle
!
.
color
,
colorScheme
.
primary
);
expect
(
material
.
textStyle
!
.
fontFamily
,
'Roboto'
);
expect
(
material
.
textStyle
!
.
fontSize
,
14
);
expect
(
material
.
textStyle
!
.
fontWeight
,
FontWeight
.
w500
);
expect
(
material
.
type
,
MaterialType
.
button
);
// Disabled OutlinedButton
...
...
@@ -114,17 +112,17 @@ void main() {
),
borderRadius:
BorderRadius
.
circular
(
4.0
),
));
expect
(
material
.
textStyle
.
color
,
colorScheme
.
onSurface
.
withOpacity
(
0.38
));
expect
(
material
.
textStyle
.
fontFamily
,
'Roboto'
);
expect
(
material
.
textStyle
.
fontSize
,
14
);
expect
(
material
.
textStyle
.
fontWeight
,
FontWeight
.
w500
);
expect
(
material
.
textStyle
!
.
color
,
colorScheme
.
onSurface
.
withOpacity
(
0.38
));
expect
(
material
.
textStyle
!
.
fontFamily
,
'Roboto'
);
expect
(
material
.
textStyle
!
.
fontSize
,
14
);
expect
(
material
.
textStyle
!
.
fontWeight
,
FontWeight
.
w500
);
expect
(
material
.
type
,
MaterialType
.
button
);
});
testWidgets
(
'Does OutlinedButton work with hover'
,
(
WidgetTester
tester
)
async
{
const
Color
hoverColor
=
Color
(
0xff001122
);
Color
getOverlayColor
(
Set
<
MaterialState
>
states
)
{
Color
?
getOverlayColor
(
Set
<
MaterialState
>
states
)
{
return
states
.
contains
(
MaterialState
.
hovered
)
?
hoverColor
:
null
;
}
...
...
@@ -133,7 +131,7 @@ void main() {
textDirection:
TextDirection
.
ltr
,
child:
OutlinedButton
(
style:
ButtonStyle
(
overlayColor:
MaterialStateProperty
.
resolveWith
<
Color
>(
getOverlayColor
),
overlayColor:
MaterialStateProperty
.
resolveWith
<
Color
?
>(
getOverlayColor
),
),
onPressed:
()
{
},
child:
const
Text
(
'button'
),
...
...
@@ -154,7 +152,7 @@ void main() {
testWidgets
(
'Does OutlinedButton work with focus'
,
(
WidgetTester
tester
)
async
{
const
Color
focusColor
=
Color
(
0xff001122
);
Color
getOverlayColor
(
Set
<
MaterialState
>
states
)
{
Color
?
getOverlayColor
(
Set
<
MaterialState
>
states
)
{
return
states
.
contains
(
MaterialState
.
focused
)
?
focusColor
:
null
;
}
...
...
@@ -164,7 +162,7 @@ void main() {
textDirection:
TextDirection
.
ltr
,
child:
OutlinedButton
(
style:
ButtonStyle
(
overlayColor:
MaterialStateProperty
.
resolveWith
<
Color
>(
getOverlayColor
),
overlayColor:
MaterialStateProperty
.
resolveWith
<
Color
?
>(
getOverlayColor
),
),
focusNode:
focusNode
,
onPressed:
()
{
},
...
...
@@ -184,7 +182,7 @@ void main() {
testWidgets
(
'Does OutlinedButton work with autofocus'
,
(
WidgetTester
tester
)
async
{
const
Color
focusColor
=
Color
(
0xff001122
);
Color
getOverlayColor
(
Set
<
MaterialState
>
states
)
{
Color
?
getOverlayColor
(
Set
<
MaterialState
>
states
)
{
return
states
.
contains
(
MaterialState
.
focused
)
?
focusColor
:
null
;
}
...
...
@@ -195,7 +193,7 @@ void main() {
child:
OutlinedButton
(
autofocus:
true
,
style:
ButtonStyle
(
overlayColor:
MaterialStateProperty
.
resolveWith
<
Color
>(
getOverlayColor
),
overlayColor:
MaterialStateProperty
.
resolveWith
<
Color
?
>(
getOverlayColor
),
),
focusNode:
focusNode
,
onPressed:
()
{
},
...
...
@@ -268,9 +266,9 @@ void main() {
MaterialState
.
focused
,
};
if
(
states
.
any
(
interactiveStates
.
contains
))
{
return
Colors
.
blue
[
900
];
return
Colors
.
blue
[
900
]
!
;
}
return
Colors
.
blue
[
800
];
return
Colors
.
blue
[
800
]
!
;
}
await
tester
.
pumpWidget
(
...
...
@@ -368,7 +366,7 @@ void main() {
);
Color
textColor
()
{
return
tester
.
renderObject
<
RenderParagraph
>(
find
.
text
(
'OutlinedButton'
)).
text
.
style
.
color
;
return
tester
.
renderObject
<
RenderParagraph
>(
find
.
text
(
'OutlinedButton'
)).
text
.
style
!.
color
!
;
}
// Default, not disabled.
...
...
@@ -438,7 +436,7 @@ void main() {
),
);
Color
iconColor
()
=>
_iconStyle
(
tester
,
Icons
.
add
).
color
;
Color
iconColor
()
=>
_iconStyle
(
tester
,
Icons
.
add
).
color
!
;
// Default, not disabled.
expect
(
iconColor
(),
equals
(
defaultColor
));
...
...
@@ -535,7 +533,7 @@ void main() {
bool
wasPressed
;
Finder
outlinedButton
;
Widget
buildFrame
({
VoidCallback
onPressed
,
VoidCallback
onLongPress
})
{
Widget
buildFrame
({
VoidCallback
?
onPressed
,
VoidCallback
?
onLongPress
})
{
return
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
OutlinedButton
(
...
...
@@ -575,7 +573,7 @@ void main() {
});
testWidgets
(
"Outline button doesn't crash if disabled during a gesture"
,
(
WidgetTester
tester
)
async
{
Widget
buildFrame
(
VoidCallback
onPressed
)
{
Widget
buildFrame
(
VoidCallback
?
onPressed
)
{
return
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
Theme
(
...
...
@@ -600,7 +598,7 @@ void main() {
const
BorderSide
enabledBorderSide
=
BorderSide
(
color:
Color
(
0xFFFF00FF
),
width:
4
);
const
BorderSide
pressedBorderSide
=
BorderSide
(
color:
Color
(
0xFF0000FF
),
width:
5
);
Widget
buildFrame
({
VoidCallback
onPressed
})
{
Widget
buildFrame
({
VoidCallback
?
onPressed
})
{
return
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
Theme
(
...
...
@@ -946,7 +944,7 @@ void main() {
const
List
<
double
>
textScaleFactorOptions
=
<
double
>[
0.5
,
1.0
,
1.25
,
1.5
,
2.0
,
2.5
,
3.0
,
4.0
];
const
List
<
TextDirection
>
textDirectionOptions
=
<
TextDirection
>[
TextDirection
.
ltr
,
TextDirection
.
rtl
];
const
List
<
Widget
>
iconOptions
=
<
Widget
>[
null
,
Icon
(
Icons
.
add
,
size:
18
,
key:
iconKey
)];
const
List
<
Widget
?>
iconOptions
=
<
Widget
?
>[
null
,
Icon
(
Icons
.
add
,
size:
18
,
key:
iconKey
)];
// Expected values for each textScaleFactor.
final
Map
<
double
,
double
>
paddingVertical
=
<
double
,
double
>{
...
...
@@ -986,7 +984,7 @@ void main() {
}
/// Computes the padding between two [Rect]s, one inside the other.
EdgeInsets
paddingBetween
({
Rect
parent
,
Rect
child
})
{
EdgeInsets
paddingBetween
({
required
Rect
parent
,
required
Rect
child
})
{
assert
(
parent
.
intersect
(
child
)
==
child
);
return
EdgeInsets
.
fromLTRB
(
child
.
left
-
parent
.
left
,
...
...
@@ -998,7 +996,7 @@ void main() {
for
(
final
double
textScaleFactor
in
textScaleFactorOptions
)
{
for
(
final
TextDirection
textDirection
in
textDirectionOptions
)
{
for
(
final
Widget
icon
in
iconOptions
)
{
for
(
final
Widget
?
icon
in
iconOptions
)
{
final
String
testName
=
'OutlinedButton'
', text scale
$textScaleFactor
'
'
${icon != null ? ", with icon" : ""}
'
...
...
@@ -1011,7 +1009,7 @@ void main() {
home:
Builder
(
builder:
(
BuildContext
context
)
{
return
MediaQuery
(
data:
MediaQuery
.
of
(
context
).
copyWith
(
data:
MediaQuery
.
of
(
context
)
!
.
copyWith
(
textScaleFactor:
textScaleFactor
,
),
child:
Directionality
(
...
...
@@ -1050,9 +1048,9 @@ void main() {
// Compute expected padding, and check.
final
double
expectedPaddingTop
=
paddingVertical
[
textScaleFactor
];
final
double
expectedPaddingBottom
=
paddingVertical
[
textScaleFactor
];
final
double
expectedPaddingStart
=
paddingHorizontal
[
textScaleFactor
];
final
double
expectedPaddingTop
=
paddingVertical
[
textScaleFactor
]
!
;
final
double
expectedPaddingBottom
=
paddingVertical
[
textScaleFactor
]
!
;
final
double
expectedPaddingStart
=
paddingHorizontal
[
textScaleFactor
]
!
;
final
double
expectedPaddingEnd
=
expectedPaddingStart
;
final
EdgeInsets
expectedPadding
=
EdgeInsetsDirectional
.
fromSTEB
(
...
...
@@ -1069,9 +1067,9 @@ void main() {
final
RenderBox
labelRenderBox
=
tester
.
renderObject
<
RenderBox
>(
find
.
byKey
(
labelKey
));
final
Rect
labelBounds
=
globalBounds
(
labelRenderBox
);
final
RenderBox
iconRenderBox
=
icon
==
null
?
null
:
tester
.
renderObject
<
RenderBox
>(
find
.
byKey
(
iconKey
));
final
Rect
iconBounds
=
icon
==
null
?
null
:
globalBounds
(
iconRenderBox
);
final
Rect
childBounds
=
icon
==
null
?
labelBounds
:
labelBounds
.
expandToInclude
(
iconBounds
);
final
RenderBox
?
iconRenderBox
=
icon
==
null
?
null
:
tester
.
renderObject
<
RenderBox
>(
find
.
byKey
(
iconKey
));
final
Rect
?
iconBounds
=
icon
==
null
?
null
:
globalBounds
(
iconRenderBox
!
);
final
Rect
childBounds
=
icon
==
null
?
labelBounds
:
labelBounds
.
expandToInclude
(
iconBounds
!
);
// We measure the `InkResponse` descendant of the button
// element, because the button has a larger `RenderBox`
...
...
@@ -1120,8 +1118,8 @@ void main() {
// Check the gap between the icon and the label
if
(
icon
!=
null
)
{
final
double
gapWidth
=
textDirection
==
TextDirection
.
ltr
?
labelBounds
.
left
-
iconBounds
.
right
:
iconBounds
.
left
-
labelBounds
.
right
;
?
labelBounds
.
left
-
iconBounds
!
.
right
:
iconBounds
!
.
left
-
labelBounds
.
right
;
expect
(
gapWidth
,
paddingWithIconGap
[
textScaleFactor
]);
}
...
...
@@ -1150,7 +1148,7 @@ void main() {
home:
Builder
(
builder:
(
BuildContext
context
)
{
return
MediaQuery
(
data:
MediaQuery
.
of
(
context
).
copyWith
(
data:
MediaQuery
.
of
(
context
)
!
.
copyWith
(
textScaleFactor:
2
,
),
child:
Scaffold
(
...
...
@@ -1180,24 +1178,24 @@ void main() {
PhysicalModelLayer
_findPhysicalLayer
(
Element
element
)
{
expect
(
element
,
isNotNull
);
RenderObject
object
=
element
.
renderObject
;
RenderObject
?
object
=
element
.
renderObject
;
while
(
object
!=
null
&&
object
is
!
RenderRepaintBoundary
&&
object
is
!
RenderView
)
{
object
=
object
.
parent
as
RenderObject
;
}
expect
(
object
.
debugLayer
,
isNotNull
);
expect
(
object
.
debugLayer
.
firstChild
,
isA
<
PhysicalModelLayer
>());
final
PhysicalModelLayer
layer
=
object
.
debugLayer
.
firstChild
as
PhysicalModelLayer
;
final
Layer
child
=
layer
.
firstChild
;
expect
(
object
!
.
debugLayer
,
isNotNull
);
expect
(
object
.
debugLayer
!
.
firstChild
,
isA
<
PhysicalModelLayer
>());
final
PhysicalModelLayer
layer
=
object
.
debugLayer
!
.
firstChild
as
PhysicalModelLayer
;
final
Layer
child
=
layer
.
firstChild
!
;
return
child
is
PhysicalModelLayer
?
child
:
layer
;
}
void
_checkPhysicalLayer
(
Element
element
,
Color
expectedColor
,
{
Path
clipPath
,
Rect
clipRect
})
{
void
_checkPhysicalLayer
(
Element
element
,
Color
expectedColor
,
{
Path
?
clipPath
,
Rect
?
clipRect
})
{
final
PhysicalModelLayer
expectedLayer
=
_findPhysicalLayer
(
element
);
expect
(
expectedLayer
.
elevation
,
0.0
);
expect
(
expectedLayer
.
color
,
expectedColor
);
if
(
clipPath
!=
null
)
{
expect
(
clipRect
,
isNotNull
);
expect
(
expectedLayer
.
clipPath
,
coversSameAreaAs
(
clipPath
,
areaToCompare:
clipRect
.
inflate
(
10.0
)));
expect
(
expectedLayer
.
clipPath
,
coversSameAreaAs
(
clipPath
,
areaToCompare:
clipRect
!
.
inflate
(
10.0
)));
}
}
...
...
@@ -1205,5 +1203,5 @@ 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
!
;
}
packages/flutter/test/material/outlined_button_theme_test.dart
View file @
3961a12a
...
...
@@ -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'
;
...
...
@@ -40,10 +38,10 @@ void main() {
side:
BorderSide
(
width:
1
,
color:
colorScheme
.
onSurface
.
withOpacity
(
0.12
)),
borderRadius:
BorderRadius
.
circular
(
4.0
),
));
expect
(
material
.
textStyle
.
color
,
colorScheme
.
primary
);
expect
(
material
.
textStyle
.
fontFamily
,
'Roboto'
);
expect
(
material
.
textStyle
.
fontSize
,
14
);
expect
(
material
.
textStyle
.
fontWeight
,
FontWeight
.
w500
);
expect
(
material
.
textStyle
!
.
color
,
colorScheme
.
primary
);
expect
(
material
.
textStyle
!
.
fontFamily
,
'Roboto'
);
expect
(
material
.
textStyle
!
.
fontSize
,
14
);
expect
(
material
.
textStyle
!
.
fontWeight
,
FontWeight
.
w500
);
});
group
(
'[Theme, TextTheme, OutlinedButton style overrides]'
,
()
{
...
...
@@ -81,7 +79,7 @@ void main() {
enableFeedback:
enableFeedback
,
);
Widget
buildFrame
({
ButtonStyle
buttonStyle
,
ButtonStyle
themeStyle
,
ButtonStyle
overallStyle
})
{
Widget
buildFrame
({
ButtonStyle
?
buttonStyle
,
ButtonStyle
?
themeStyle
,
ButtonStyle
?
overallStyle
})
{
final
Widget
child
=
Builder
(
builder:
(
BuildContext
context
)
{
return
OutlinedButton
(
...
...
@@ -126,15 +124,15 @@ void main() {
void
checkButton
(
WidgetTester
tester
)
{
final
Material
material
=
tester
.
widget
<
Material
>(
findMaterial
);
final
InkWell
inkWell
=
tester
.
widget
<
InkWell
>(
findInkWell
);
expect
(
material
.
textStyle
.
color
,
primaryColor
);
expect
(
material
.
textStyle
.
fontSize
,
12
);
expect
(
material
.
textStyle
!
.
color
,
primaryColor
);
expect
(
material
.
textStyle
!
.
fontSize
,
12
);
expect
(
material
.
color
,
backgroundColor
);
expect
(
material
.
shadowColor
,
shadowColor
);
expect
(
material
.
elevation
,
elevation
);
expect
(
MaterialStateProperty
.
resolveAs
<
MouseCursor
>(
inkWell
.
mouseCursor
,
enabled
),
enabledMouseCursor
);
expect
(
MaterialStateProperty
.
resolveAs
<
MouseCursor
>(
inkWell
.
mouseCursor
,
disabled
),
disabledMouseCursor
);
expect
(
inkWell
.
overlayColor
.
resolve
(
hovered
),
primaryColor
.
withOpacity
(
0.04
));
expect
(
inkWell
.
overlayColor
.
resolve
(
focused
),
primaryColor
.
withOpacity
(
0.12
));
expect
(
MaterialStateProperty
.
resolveAs
<
MouseCursor
?
>(
inkWell
.
mouseCursor
,
enabled
),
enabledMouseCursor
);
expect
(
MaterialStateProperty
.
resolveAs
<
MouseCursor
?
>(
inkWell
.
mouseCursor
,
disabled
),
disabledMouseCursor
);
expect
(
inkWell
.
overlayColor
!
.
resolve
(
hovered
),
primaryColor
.
withOpacity
(
0.04
));
expect
(
inkWell
.
overlayColor
!
.
resolve
(
focused
),
primaryColor
.
withOpacity
(
0.12
));
expect
(
inkWell
.
enableFeedback
,
enableFeedback
);
expect
(
material
.
borderRadius
,
null
);
expect
(
material
.
shape
,
shape
);
...
...
@@ -186,7 +184,7 @@ void main() {
const
Color
shadowColor
=
Color
(
0xff000001
);
const
Color
overiddenColor
=
Color
(
0xff000002
);
Widget
buildFrame
({
Color
overallShadowColor
,
Color
themeShadowColor
,
Color
shadowColor
})
{
Widget
buildFrame
({
Color
?
overallShadowColor
,
Color
?
themeShadowColor
,
Color
?
shadowColor
})
{
return
MaterialApp
(
theme:
ThemeData
.
from
(
colorScheme:
colorScheme
).
copyWith
(
shadowColor:
overallShadowColor
,
...
...
packages/flutter/test/material/page_selector_test.dart
View file @
3961a12a
...
...
@@ -2,15 +2,13 @@
// 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'
;
const
Color
kSelectedColor
=
Color
(
0xFF00FF00
);
const
Color
kUnselectedColor
=
Colors
.
transparent
;
Widget
buildFrame
(
TabController
tabController
,
{
Color
color
,
Color
selectedColor
,
double
indicatorSize
=
12.0
})
{
Widget
buildFrame
(
TabController
tabController
,
{
Color
?
color
,
Color
?
selectedColor
,
double
indicatorSize
=
12.0
})
{
return
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
Theme
(
...
...
packages/flutter/test/material/page_test.dart
View file @
3961a12a
...
...
@@ -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/cupertino.dart'
show
CupertinoPageRoute
;
...
...
@@ -32,7 +30,7 @@ void main() {
await
tester
.
pump
(
const
Duration
(
milliseconds:
1
));
FadeTransition
widget2Opacity
=
tester
.
element
(
find
.
text
(
'Page 2'
)).
findAncestorWidgetOfExactType
<
FadeTransition
>();
tester
.
element
(
find
.
text
(
'Page 2'
)).
findAncestorWidgetOfExactType
<
FadeTransition
>()
!
;
Offset
widget2TopLeft
=
tester
.
getTopLeft
(
find
.
text
(
'Page 2'
));
final
Size
widget2Size
=
tester
.
getSize
(
find
.
text
(
'Page 2'
));
...
...
@@ -56,7 +54,7 @@ void main() {
await
tester
.
pump
(
const
Duration
(
milliseconds:
1
));
widget2Opacity
=
tester
.
element
(
find
.
text
(
'Page 2'
)).
findAncestorWidgetOfExactType
<
FadeTransition
>();
tester
.
element
(
find
.
text
(
'Page 2'
)).
findAncestorWidgetOfExactType
<
FadeTransition
>()
!
;
widget2TopLeft
=
tester
.
getTopLeft
(
find
.
text
(
'Page 2'
));
// Page 2 starts to move down.
...
...
@@ -96,7 +94,7 @@ void main() {
Offset
widget1TransientTopLeft
=
tester
.
getTopLeft
(
find
.
text
(
'Page 1'
));
Offset
widget2TopLeft
=
tester
.
getTopLeft
(
find
.
text
(
'Page 2'
));
final
RenderDecoratedBox
box
=
tester
.
element
(
find
.
byKey
(
page2Key
))
.
findAncestorRenderObjectOfType
<
RenderDecoratedBox
>();
.
findAncestorRenderObjectOfType
<
RenderDecoratedBox
>()
!
;
// Page 1 is moving to the left.
expect
(
widget1TransientTopLeft
.
dx
<
widget1InitialTopLeft
.
dx
,
true
);
...
...
@@ -284,7 +282,7 @@ void main() {
'/'
:
(
BuildContext
context
)
=>
Material
(
child:
TextButton
(
child:
const
Text
(
'PUSH'
),
onPressed:
()
{
Navigator
.
of
(
context
).
pushNamed
(
'/b'
);
},
onPressed:
()
{
Navigator
.
of
(
context
)
!
.
pushNamed
(
'/b'
);
},
),
),
'/b'
:
(
BuildContext
context
)
=>
Container
(
child:
const
Text
(
'HELLO'
)),
...
...
@@ -311,7 +309,7 @@ void main() {
final
Offset
helloPosition2
=
tester
.
getCenter
(
find
.
text
(
'HELLO'
));
expect
(
helloPosition1
.
dx
,
lessThan
(
helloPosition2
.
dx
));
expect
(
helloPosition1
.
dy
,
helloPosition2
.
dy
);
expect
(
Theme
.
of
(
tester
.
element
(
find
.
text
(
'HELLO'
))).
platform
,
TargetPlatform
.
iOS
);
expect
(
Theme
.
of
(
tester
.
element
(
find
.
text
(
'HELLO'
)))
!
.
platform
,
TargetPlatform
.
iOS
);
await
tester
.
pumpWidget
(
MaterialApp
(
theme:
ThemeData
(
platform:
TargetPlatform
.
android
),
...
...
@@ -327,7 +325,7 @@ void main() {
// frame in which the theme animation ends.
// 3. End all the other animations.
expect
(
await
tester
.
pumpAndSettle
(
const
Duration
(
minutes:
1
)),
2
);
expect
(
Theme
.
of
(
tester
.
element
(
find
.
text
(
'HELLO'
))).
platform
,
TargetPlatform
.
android
);
expect
(
Theme
.
of
(
tester
.
element
(
find
.
text
(
'HELLO'
)))
!
.
platform
,
TargetPlatform
.
android
);
final
Offset
helloPosition3
=
tester
.
getCenter
(
find
.
text
(
'HELLO'
));
expect
(
helloPosition3
,
helloPosition2
);
expect
(
find
.
text
(
'PUSH'
),
findsOneWidget
);
...
...
@@ -367,7 +365,7 @@ void main() {
final
Offset
helloPosition6
=
tester
.
getCenter
(
find
.
text
(
'HELLO'
));
expect
(
helloPosition5
.
dx
,
lessThan
(
helloPosition6
.
dx
));
expect
(
helloPosition5
.
dy
,
helloPosition6
.
dy
);
expect
(
Theme
.
of
(
tester
.
element
(
find
.
text
(
'HELLO'
))).
platform
,
TargetPlatform
.
macOS
);
expect
(
Theme
.
of
(
tester
.
element
(
find
.
text
(
'HELLO'
)))
!
.
platform
,
TargetPlatform
.
macOS
);
});
testWidgets
(
'test no back gesture on fullscreen dialogs'
,
(
WidgetTester
tester
)
async
{
...
...
@@ -481,30 +479,6 @@ void main() {
expect
(
widget1InitialTopLeft
==
widget1TransientTopLeft
,
true
);
},
variant:
const
TargetPlatformVariant
(<
TargetPlatform
>{
TargetPlatform
.
iOS
,
TargetPlatform
.
macOS
}));
testWidgets
(
'throws when builder returns null'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
const
MaterialApp
(
home:
Text
(
'Home'
),
));
// No exceptions yet.
expect
(
tester
.
takeException
(),
isNull
);
tester
.
state
<
NavigatorState
>(
find
.
byType
(
Navigator
))
.
push
(
MaterialPageRoute
<
void
>(
settings:
const
RouteSettings
(
name:
'broken'
),
builder:
(
BuildContext
context
)
=>
null
,
));
await
tester
.
pumpAndSettle
();
// An exception should've been thrown because the `builder` returned null.
final
dynamic
exception
=
tester
.
takeException
();
expect
(
exception
,
isFlutterError
);
expect
(
exception
.
toStringDeep
(),
equalsIgnoringHashCodes
(
'FlutterError
\n
'
' The builder for route "broken" returned null.
\n
'
' Route builders must never return null.
\n
'
));
});
testWidgets
(
'test edge swipe then drop back at starting point works'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
MaterialApp
(
...
...
@@ -584,7 +558,7 @@ void main() {
body:
Center
(
child:
ElevatedButton
(
onPressed:
()
{
Navigator
.
push
<
void
>(
scaffoldKey
.
currentContext
,
MaterialPageRoute
<
void
>(
Navigator
.
push
<
void
>(
scaffoldKey
.
currentContext
!
,
MaterialPageRoute
<
void
>(
builder:
(
BuildContext
context
)
{
return
const
Scaffold
(
body:
Center
(
child:
Text
(
'route'
)),
...
...
@@ -655,7 +629,7 @@ void main() {
// Use the navigator to push a route instead of tapping the 'push' button.
// The topmost route (the one that's animating away), ignores input while
// the pop is underway because route.navigator.userGestureInProgress.
Navigator
.
push
<
void
>(
scaffoldKey
.
currentContext
,
MaterialPageRoute
<
void
>(
Navigator
.
push
<
void
>(
scaffoldKey
.
currentContext
!
,
MaterialPageRoute
<
void
>(
builder:
(
BuildContext
context
)
{
return
const
Scaffold
(
body:
Center
(
child:
Text
(
'route'
)),
...
...
@@ -693,7 +667,7 @@ void main() {
expect
(
homeTapCount
,
1
);
expect
(
pageTapCount
,
0
);
Navigator
.
push
<
void
>(
homeScaffoldKey
.
currentContext
,
MaterialPageRoute
<
void
>(
Navigator
.
push
<
void
>(
homeScaffoldKey
.
currentContext
!
,
MaterialPageRoute
<
void
>(
builder:
(
BuildContext
context
)
{
return
Scaffold
(
key:
pageScaffoldKey
,
...
...
@@ -763,10 +737,10 @@ void main() {
expect
(
homeTapCount
,
1
);
expect
(
pageTapCount
,
0
);
final
ValueNotifier
<
bool
>
notifier
=
Navigator
.
of
(
homeScaffoldKey
.
currentContext
)
.
userGestureInProgressNotifier
;
final
ValueNotifier
<
bool
>
notifier
=
Navigator
.
of
(
homeScaffoldKey
.
currentContext
!)!
.
userGestureInProgressNotifier
;
expect
(
notifier
.
value
,
false
);
Navigator
.
push
<
void
>(
homeScaffoldKey
.
currentContext
,
MaterialPageRoute
<
void
>(
Navigator
.
push
<
void
>(
homeScaffoldKey
.
currentContext
!
,
MaterialPageRoute
<
void
>(
builder:
(
BuildContext
context
)
{
return
Scaffold
(
key:
pageScaffoldKey
,
...
...
@@ -846,7 +820,10 @@ void main() {
await
tester
.
pumpWidget
(
buildNavigator
(
pages:
myPages
,
onPopPage:
(
Route
<
dynamic
>
route
,
dynamic
result
)
=>
null
,
onPopPage:
(
Route
<
dynamic
>
route
,
dynamic
result
)
{
assert
(
false
);
// The test should never execute this.
return
true
;
},
transitionDelegate:
detector
,
)
);
...
...
@@ -861,7 +838,10 @@ void main() {
await
tester
.
pumpWidget
(
buildNavigator
(
pages:
myPages
,
onPopPage:
(
Route
<
dynamic
>
route
,
dynamic
result
)
=>
null
,
onPopPage:
(
Route
<
dynamic
>
route
,
dynamic
result
)
{
assert
(
false
);
// The test should never execute this.
return
true
;
},
transitionDelegate:
detector
,
)
);
...
...
@@ -883,7 +863,10 @@ void main() {
await
tester
.
pumpWidget
(
buildNavigator
(
pages:
myPages
,
onPopPage:
(
Route
<
dynamic
>
route
,
dynamic
result
)
=>
null
,
onPopPage:
(
Route
<
dynamic
>
route
,
dynamic
result
)
{
assert
(
false
);
// The test should never execute this.
return
true
;
},
transitionDelegate:
detector
,
)
);
...
...
@@ -901,7 +884,10 @@ void main() {
await
tester
.
pumpWidget
(
buildNavigator
(
pages:
myPages
,
onPopPage:
(
Route
<
dynamic
>
route
,
dynamic
result
)
=>
null
,
onPopPage:
(
Route
<
dynamic
>
route
,
dynamic
result
)
{
assert
(
false
);
// The test should never execute this.
return
true
;
},
transitionDelegate:
detector
,
)
);
...
...
@@ -919,7 +905,7 @@ void main() {
expect
(
find
.
text
(
'subpage'
),
findsOneWidget
);
expect
(
find
.
text
(
'home'
),
findsNothing
);
navigator
.
currentState
.
pop
();
navigator
.
currentState
!
.
pop
();
await
tester
.
pump
();
expect
(
find
.
text
(
'subpage'
),
findsOneWidget
);
...
...
@@ -931,9 +917,9 @@ class TransitionDetector extends DefaultTransitionDelegate<void> {
bool
hasTransition
=
false
;
@override
Iterable
<
RouteTransitionRecord
>
resolve
({
List
<
RouteTransitionRecord
>
newPageRouteHistory
,
Map
<
RouteTransitionRecord
,
RouteTransitionRecord
>
locationToExitingPageRoute
,
Map
<
RouteTransitionRecord
,
List
<
RouteTransitionRecord
>>
pageRouteToPagelessRoutes
required
List
<
RouteTransitionRecord
>
newPageRouteHistory
,
required
Map
<
RouteTransitionRecord
?
,
RouteTransitionRecord
>
locationToExitingPageRoute
,
required
Map
<
RouteTransitionRecord
?
,
List
<
RouteTransitionRecord
>>
pageRouteToPagelessRoutes
})
{
hasTransition
=
true
;
return
super
.
resolve
(
...
...
@@ -945,13 +931,13 @@ class TransitionDetector extends DefaultTransitionDelegate<void> {
}
Widget
buildNavigator
(
{
List
<
Page
<
dynamic
>>
pages
,
PopPageCallback
onPopPage
,
GlobalKey
<
NavigatorState
>
key
,
TransitionDelegate
<
dynamic
>
transitionDelegate
required
List
<
Page
<
dynamic
>>
pages
,
required
PopPageCallback
onPopPage
,
GlobalKey
<
NavigatorState
>
?
key
,
TransitionDelegate
<
dynamic
>
?
transitionDelegate
})
{
return
MediaQuery
(
data:
MediaQueryData
.
fromWindow
(
WidgetsBinding
.
instance
.
window
),
data:
MediaQueryData
.
fromWindow
(
WidgetsBinding
.
instance
!
.
window
),
child:
Localizations
(
locale:
const
Locale
(
'en'
,
'US'
),
delegates:
const
<
LocalizationsDelegate
<
dynamic
>>[
...
...
@@ -974,14 +960,14 @@ Widget buildNavigator({
class
KeepsStateTestWidget
extends
StatefulWidget
{
const
KeepsStateTestWidget
({
this
.
navigatorKey
});
final
Key
navigatorKey
;
final
Key
?
navigatorKey
;
@override
State
<
KeepsStateTestWidget
>
createState
()
=>
_KeepsStateTestWidgetState
();
}
class
_KeepsStateTestWidgetState
extends
State
<
KeepsStateTestWidget
>
{
String
_subpage
=
'subpage'
;
String
?
_subpage
=
'subpage'
;
@override
Widget
build
(
BuildContext
context
)
{
...
...
@@ -990,7 +976,7 @@ class _KeepsStateTestWidgetState extends State<KeepsStateTestWidget> {
key:
widget
.
navigatorKey
,
pages:
<
Page
<
void
>>[
const
MaterialPage
<
void
>(
child:
Text
(
'home'
)),
if
(
_subpage
!=
null
)
MaterialPage
<
void
>(
child:
Text
(
_subpage
)),
if
(
_subpage
!=
null
)
MaterialPage
<
void
>(
child:
Text
(
_subpage
!
)),
],
onPopPage:
(
Route
<
dynamic
>
route
,
dynamic
result
)
{
if
(!
route
.
didPop
(
result
))
{
...
...
packages/flutter/test/material/page_transitions_theme_test.dart
View file @
3961a12a
...
...
@@ -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/cupertino.dart'
;
import
'package:flutter/foundation.dart'
;
import
'package:flutter/material.dart'
;
...
...
@@ -12,7 +10,7 @@ import 'package:flutter_test/flutter_test.dart';
void
main
(
)
{
testWidgets
(
'Default PageTransitionsTheme platform'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
const
MaterialApp
(
home:
Text
(
'home'
)));
final
PageTransitionsTheme
theme
=
Theme
.
of
(
tester
.
element
(
find
.
text
(
'home'
))).
pageTransitionsTheme
;
final
PageTransitionsTheme
theme
=
Theme
.
of
(
tester
.
element
(
find
.
text
(
'home'
)))
!
.
pageTransitionsTheme
;
expect
(
theme
.
builders
,
isNotNull
);
for
(
final
TargetPlatform
platform
in
TargetPlatform
.
values
)
{
if
(
platform
==
TargetPlatform
.
fuchsia
)
{
...
...
@@ -28,7 +26,7 @@ void main() {
'/'
:
(
BuildContext
context
)
=>
Material
(
child:
TextButton
(
child:
const
Text
(
'push'
),
onPressed:
()
{
Navigator
.
of
(
context
).
pushNamed
(
'/b'
);
},
onPressed:
()
{
Navigator
.
of
(
context
)
!
.
pushNamed
(
'/b'
);
},
),
),
'/b'
:
(
BuildContext
context
)
=>
const
Text
(
'page b'
),
...
...
@@ -40,7 +38,7 @@ void main() {
),
);
expect
(
Theme
.
of
(
tester
.
element
(
find
.
text
(
'push'
))).
platform
,
debugDefaultTargetPlatformOverride
);
expect
(
Theme
.
of
(
tester
.
element
(
find
.
text
(
'push'
)))
!
.
platform
,
debugDefaultTargetPlatformOverride
);
expect
(
find
.
byType
(
CupertinoPageTransition
),
findsOneWidget
);
await
tester
.
tap
(
find
.
text
(
'push'
));
...
...
@@ -54,7 +52,7 @@ void main() {
'/'
:
(
BuildContext
context
)
=>
Material
(
child:
TextButton
(
child:
const
Text
(
'push'
),
onPressed:
()
{
Navigator
.
of
(
context
).
pushNamed
(
'/b'
);
},
onPressed:
()
{
Navigator
.
of
(
context
)
!
.
pushNamed
(
'/b'
);
},
),
),
'/b'
:
(
BuildContext
context
)
=>
const
Text
(
'page b'
),
...
...
@@ -73,7 +71,7 @@ void main() {
);
}
expect
(
Theme
.
of
(
tester
.
element
(
find
.
text
(
'push'
))).
platform
,
debugDefaultTargetPlatformOverride
);
expect
(
Theme
.
of
(
tester
.
element
(
find
.
text
(
'push'
)))
!
.
platform
,
debugDefaultTargetPlatformOverride
);
expect
(
findFadeUpwardsPageTransition
(),
findsOneWidget
);
await
tester
.
tap
(
find
.
text
(
'push'
));
...
...
@@ -87,7 +85,7 @@ void main() {
'/'
:
(
BuildContext
context
)
=>
Material
(
child:
TextButton
(
child:
const
Text
(
'push'
),
onPressed:
()
{
Navigator
.
of
(
context
).
pushNamed
(
'/b'
);
},
onPressed:
()
{
Navigator
.
of
(
context
)
!
.
pushNamed
(
'/b'
);
},
),
),
'/b'
:
(
BuildContext
context
)
=>
const
Text
(
'page b'
),
...
...
@@ -113,7 +111,7 @@ void main() {
);
}
expect
(
Theme
.
of
(
tester
.
element
(
find
.
text
(
'push'
))).
platform
,
debugDefaultTargetPlatformOverride
);
expect
(
Theme
.
of
(
tester
.
element
(
find
.
text
(
'push'
)))
!
.
platform
,
debugDefaultTargetPlatformOverride
);
expect
(
findOpenUpwardsPageTransition
(),
findsOneWidget
);
await
tester
.
tap
(
find
.
text
(
'push'
));
...
...
@@ -127,7 +125,7 @@ void main() {
'/'
:
(
BuildContext
context
)
=>
Material
(
child:
TextButton
(
child:
const
Text
(
'push'
),
onPressed:
()
{
Navigator
.
of
(
context
).
pushNamed
(
'/b'
);
},
onPressed:
()
{
Navigator
.
of
(
context
)
!
.
pushNamed
(
'/b'
);
},
),
),
'/b'
:
(
BuildContext
context
)
=>
const
Text
(
'page b'
),
...
...
@@ -153,7 +151,7 @@ void main() {
);
}
expect
(
Theme
.
of
(
tester
.
element
(
find
.
text
(
'push'
))).
platform
,
debugDefaultTargetPlatformOverride
);
expect
(
Theme
.
of
(
tester
.
element
(
find
.
text
(
'push'
)))
!
.
platform
,
debugDefaultTargetPlatformOverride
);
expect
(
findZoomPageTransition
(),
findsOneWidget
);
await
tester
.
tap
(
find
.
text
(
'push'
));
...
...
@@ -171,7 +169,7 @@ void main() {
'/'
:
(
BuildContext
context
)
=>
Material
(
child:
TextButton
(
child:
const
Text
(
'push'
),
onPressed:
()
{
Navigator
.
of
(
context
).
pushNamed
(
'/b'
);
},
onPressed:
()
{
Navigator
.
of
(
context
)
!
.
pushNamed
(
'/b'
);
},
),
),
'/b'
:
(
BuildContext
context
)
=>
StatefulBuilder
(
...
...
packages/flutter/test/material/paginated_data_table_test.dart
View file @
3961a12a
...
...
@@ -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'
;
import
'package:flutter/gestures.dart'
show
DragStartBehavior
;
...
...
@@ -15,7 +13,7 @@ class TestDataSource extends DataTableSource {
this
.
onSelectChanged
,
});
final
void
Function
(
bool
)
onSelectChanged
;
final
void
Function
(
bool
?)?
onSelectChanged
;
int
get
generation
=>
_generation
;
int
_generation
=
0
;
...
...
@@ -68,7 +66,7 @@ void main() {
availableRowsPerPage:
const
<
int
>[
2
,
4
,
8
,
16
,
],
onRowsPerPageChanged:
(
int
rowsPerPage
)
{
onRowsPerPageChanged:
(
int
?
rowsPerPage
)
{
log
.
add
(
'rows-per-page-changed:
$rowsPerPage
'
);
},
onPageChanged:
(
int
rowIndex
)
{
...
...
@@ -218,7 +216,7 @@ void main() {
availableRowsPerPage:
const
<
int
>[
8
,
9
,
],
onRowsPerPageChanged:
(
int
rowsPerPage
)
{
},
onRowsPerPageChanged:
(
int
?
rowsPerPage
)
{
},
columns:
const
<
DataColumn
>[
DataColumn
(
label:
Text
(
'COL1'
)),
DataColumn
(
label:
Text
(
'COL2'
)),
...
...
@@ -243,7 +241,7 @@ void main() {
source
:
source
,
rowsPerPage:
501
,
availableRowsPerPage:
const
<
int
>[
501
],
onRowsPerPageChanged:
(
int
rowsPerPage
)
{
},
onRowsPerPageChanged:
(
int
?
rowsPerPage
)
{
},
columns:
const
<
DataColumn
>[
DataColumn
(
label:
Text
(
'COL1'
)),
DataColumn
(
label:
Text
(
'COL2'
)),
...
...
@@ -280,7 +278,7 @@ void main() {
rowsPerPage:
5
,
dragStartBehavior:
DragStartBehavior
.
down
,
availableRowsPerPage:
const
<
int
>[
5
],
onRowsPerPageChanged:
(
int
rowsPerPage
)
{
},
onRowsPerPageChanged:
(
int
?
rowsPerPage
)
{
},
columns:
const
<
DataColumn
>[
DataColumn
(
label:
Text
(
'COL1'
)),
DataColumn
(
label:
Text
(
'COL2'
)),
...
...
@@ -315,7 +313,7 @@ void main() {
availableRowsPerPage:
const
<
int
>[
2
,
4
,
8
,
16
,
],
onRowsPerPageChanged:
(
int
rowsPerPage
)
{},
onRowsPerPageChanged:
(
int
?
rowsPerPage
)
{},
onPageChanged:
(
int
rowIndex
)
{},
columns:
const
<
DataColumn
>[
DataColumn
(
label:
Text
(
'Name'
)),
...
...
@@ -336,7 +334,7 @@ void main() {
availableRowsPerPage:
const
<
int
>[
2
,
4
,
8
,
16
,
],
onRowsPerPageChanged:
(
int
rowsPerPage
)
{},
onRowsPerPageChanged:
(
int
?
rowsPerPage
)
{},
onPageChanged:
(
int
rowIndex
)
{},
columns:
const
<
DataColumn
>[
DataColumn
(
label:
Text
(
'Name'
)),
...
...
@@ -398,7 +396,7 @@ void main() {
await
binding
.
setSurfaceSize
(
const
Size
(
_width
,
_height
));
final
TestDataSource
source
=
TestDataSource
(
onSelectChanged:
(
bool
value
)
{},
onSelectChanged:
(
bool
?
value
)
{},
);
Finder
cellContent
;
Finder
checkbox
;
...
...
@@ -412,9 +410,9 @@ void main() {
availableRowsPerPage:
const
<
int
>[
2
,
4
,
],
onRowsPerPageChanged:
(
int
rowsPerPage
)
{},
onRowsPerPageChanged:
(
int
?
rowsPerPage
)
{},
onPageChanged:
(
int
rowIndex
)
{},
onSelectAll:
(
bool
value
)
{},
onSelectAll:
(
bool
?
value
)
{},
columns:
const
<
DataColumn
>[
DataColumn
(
label:
Text
(
'Name'
)),
DataColumn
(
label:
Text
(
'Calories'
),
numeric:
true
),
...
...
@@ -481,9 +479,9 @@ void main() {
availableRowsPerPage:
const
<
int
>[
2
,
4
,
],
onRowsPerPageChanged:
(
int
rowsPerPage
)
{},
onRowsPerPageChanged:
(
int
?
rowsPerPage
)
{},
onPageChanged:
(
int
rowIndex
)
{},
onSelectAll:
(
bool
value
)
{},
onSelectAll:
(
bool
?
value
)
{},
columns:
const
<
DataColumn
>[
DataColumn
(
label:
Text
(
'Name'
)),
DataColumn
(
label:
Text
(
'Calories'
),
numeric:
true
),
...
...
@@ -564,7 +562,7 @@ void main() {
availableRowsPerPage:
const
<
int
>[
2
,
4
,
8
,
16
,
],
onRowsPerPageChanged:
(
int
rowsPerPage
)
{},
onRowsPerPageChanged:
(
int
?
rowsPerPage
)
{},
onPageChanged:
(
int
rowIndex
)
{},
columns:
const
<
DataColumn
>[
DataColumn
(
label:
Text
(
'Name'
)),
...
...
@@ -620,7 +618,7 @@ void main() {
availableRowsPerPage:
const
<
int
>[
2
,
4
,
8
,
16
,
],
onRowsPerPageChanged:
(
int
rowsPerPage
)
{},
onRowsPerPageChanged:
(
int
?
rowsPerPage
)
{},
onPageChanged:
(
int
rowIndex
)
{},
columns:
const
<
DataColumn
>[
DataColumn
(
label:
Text
(
'Name'
)),
...
...
@@ -691,7 +689,7 @@ void main() {
availableRowsPerPage:
const
<
int
>[
2
,
4
,
8
,
16
,
],
onRowsPerPageChanged:
(
int
rowsPerPage
)
{},
onRowsPerPageChanged:
(
int
?
rowsPerPage
)
{},
onPageChanged:
(
int
rowIndex
)
{},
columns:
const
<
DataColumn
>[
DataColumn
(
label:
Text
(
'Name'
)),
...
...
@@ -735,7 +733,7 @@ void main() {
Widget
buildTable
(
bool
checkbox
)
=>
MaterialApp
(
home:
PaginatedDataTable
(
header:
const
Text
(
'Test table'
),
source
:
TestDataSource
(
onSelectChanged:
(
bool
value
)
{}),
source
:
TestDataSource
(
onSelectChanged:
(
bool
?
value
)
{}),
showCheckboxColumn:
checkbox
,
columns:
const
<
DataColumn
>[
DataColumn
(
label:
Text
(
'Name'
)),
...
...
packages/flutter/test/material/persistent_bottom_sheet_test.dart
View file @
3961a12a
...
...
@@ -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'
;
...
...
@@ -25,7 +23,6 @@ void main() {
testWidgets
(
'Verify that a BottomSheet can be rebuilt with ScaffoldFeatureController.setState()'
,
(
WidgetTester
tester
)
async
{
final
GlobalKey
<
ScaffoldState
>
scaffoldKey
=
GlobalKey
<
ScaffoldState
>();
PersistentBottomSheetController
<
void
>
bottomSheet
;
int
buildCount
=
0
;
await
tester
.
pumpWidget
(
MaterialApp
(
...
...
@@ -35,7 +32,7 @@ void main() {
),
));
bottomSheet
=
scaffoldKey
.
currentState
.
showBottomSheet
<
void
>((
_
)
{
final
PersistentBottomSheetController
<
void
>
bottomSheet
=
scaffoldKey
.
currentState
!
.
showBottomSheet
<
void
>((
_
)
{
return
Builder
(
builder:
(
BuildContext
context
)
{
buildCount
+=
1
;
...
...
@@ -46,7 +43,7 @@ void main() {
await
tester
.
pump
();
expect
(
buildCount
,
equals
(
1
));
bottomSheet
.
setState
(()
{
});
bottomSheet
.
setState
!
(()
{
});
await
tester
.
pump
();
expect
(
buildCount
,
equals
(
2
));
});
...
...
@@ -92,7 +89,7 @@ void main() {
),
));
scaffoldKey
.
currentState
.
showBottomSheet
<
void
>((
BuildContext
context
)
{
scaffoldKey
.
currentState
!
.
showBottomSheet
<
void
>((
BuildContext
context
)
{
return
ListView
(
shrinkWrap:
true
,
primary:
false
,
...
...
@@ -124,7 +121,7 @@ void main() {
),
));
scaffoldKey
.
currentState
.
showBottomSheet
<
void
>((
BuildContext
context
)
{
scaffoldKey
.
currentState
!
.
showBottomSheet
<
void
>((
BuildContext
context
)
{
return
ListView
(
shrinkWrap:
true
,
primary:
false
,
...
...
@@ -159,7 +156,7 @@ void main() {
),
));
scaffoldKey
.
currentState
.
showBottomSheet
<
void
>(
scaffoldKey
.
currentState
!
.
showBottomSheet
<
void
>(
(
BuildContext
context
)
{
return
DraggableScrollableSheet
(
expand:
false
,
...
...
@@ -313,7 +310,7 @@ void main() {
),
));
scaffoldKey
.
currentState
.
showBottomSheet
<
void
>(
scaffoldKey
.
currentState
!
.
showBottomSheet
<
void
>(
(
BuildContext
context
)
{
return
DraggableScrollableSheet
(
expand:
false
,
...
...
@@ -363,7 +360,7 @@ void main() {
int
buildCount
=
0
;
showBottomSheet
<
void
>(
context:
key
.
currentContext
,
context:
key
.
currentContext
!
,
builder:
(
BuildContext
context
)
{
return
Builder
(
builder:
(
BuildContext
context
)
{
...
...
@@ -378,8 +375,8 @@ void main() {
});
testWidgets
(
'Scaffold removes top MediaQuery padding'
,
(
WidgetTester
tester
)
async
{
BuildContext
scaffoldContext
;
BuildContext
bottomSheetContext
;
late
BuildContext
scaffoldContext
;
late
BuildContext
bottomSheetContext
;
await
tester
.
pumpWidget
(
MaterialApp
(
home:
MediaQuery
(
...
...
@@ -411,7 +408,7 @@ void main() {
await
tester
.
pump
();
expect
(
MediaQuery
.
of
(
bottomSheetContext
).
padding
,
MediaQuery
.
of
(
bottomSheetContext
)
!
.
padding
,
const
EdgeInsets
.
only
(
bottom:
50.0
,
left:
50.0
,
...
...
@@ -492,7 +489,7 @@ void main() {
),
));
scaffoldKey
.
currentState
.
showBottomSheet
<
void
>((
BuildContext
context
)
{
scaffoldKey
.
currentState
!
.
showBottomSheet
<
void
>((
BuildContext
context
)
{
return
ListView
(
shrinkWrap:
true
,
primary:
false
,
...
...
@@ -522,7 +519,7 @@ void main() {
),
));
final
PersistentBottomSheetController
<
void
>
bottomSheet
=
scaffoldKey
.
currentState
.
showBottomSheet
<
void
>((
_
)
{
final
PersistentBottomSheetController
<
void
>
bottomSheet
=
scaffoldKey
.
currentState
!
.
showBottomSheet
<
void
>((
_
)
{
return
Builder
(
builder:
(
BuildContext
context
)
{
return
Container
(
height:
200.0
);
...
...
packages/flutter/test/material/popup_menu_test.dart
View file @
3961a12a
...
...
@@ -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'
show
window
,
SemanticsFlag
;
import
'package:flutter_test/flutter_test.dart'
;
...
...
@@ -66,7 +64,7 @@ void main() {
testWidgets
(
'PopupMenuButton calls onCanceled callback when an item is not selected'
,
(
WidgetTester
tester
)
async
{
int
cancels
=
0
;
BuildContext
popupContext
;
late
BuildContext
popupContext
;
final
Key
noCallbackKey
=
UniqueKey
();
final
Key
withCallbackKey
=
UniqueKey
();
...
...
@@ -125,7 +123,7 @@ void main() {
await
tester
.
tap
(
find
.
byKey
(
withCallbackKey
));
await
tester
.
pump
();
await
tester
.
pump
(
const
Duration
(
seconds:
1
));
Navigator
.
of
(
popupContext
).
pop
();
Navigator
.
of
(
popupContext
)
!
.
pop
();
await
tester
.
pump
();
expect
(
cancels
,
equals
(
2
));
});
...
...
@@ -140,7 +138,7 @@ void main() {
return
MaterialApp
(
home:
Builder
(
builder:
(
BuildContext
context
)
{
return
MediaQuery
(
data:
MediaQuery
.
of
(
context
).
copyWith
(
data:
MediaQuery
.
of
(
context
)
!
.
copyWith
(
navigationMode:
NavigationMode
.
directional
,
),
child:
Material
(
...
...
@@ -191,7 +189,7 @@ void main() {
await
tester
.
pumpWidget
(
buildApp
(
directional:
true
));
// Try to bring up the popup menu and select the first item from it
Focus
.
of
(
popupButtonKey
.
currentContext
)
.
requestFocus
();
Focus
.
of
(
popupButtonKey
.
currentContext
!)!
.
requestFocus
();
await
tester
.
pumpAndSettle
();
await
tester
.
tap
(
find
.
byKey
(
popupButtonKey
));
await
tester
.
pumpAndSettle
();
...
...
@@ -240,10 +238,10 @@ void main() {
),
),
);
Focus
.
of
(
childKey
.
currentContext
,
nullOk:
true
)
.
requestFocus
();
Focus
.
of
(
childKey
.
currentContext
!)!
.
requestFocus
();
await
tester
.
pump
();
expect
(
Focus
.
of
(
childKey
.
currentContext
,
nullOk:
true
)
.
hasPrimaryFocus
,
isFalse
);
expect
(
Focus
.
of
(
childKey
.
currentContext
!)!
.
hasPrimaryFocus
,
isFalse
);
expect
(
itemBuilderCalled
,
isFalse
);
expect
(
onSelectedCalled
,
isFalse
);
});
...
...
@@ -256,7 +254,7 @@ void main() {
MaterialApp
(
home:
Builder
(
builder:
(
BuildContext
context
)
{
return
MediaQuery
(
data:
MediaQuery
.
of
(
context
).
copyWith
(
data:
MediaQuery
.
of
(
context
)
!
.
copyWith
(
navigationMode:
NavigationMode
.
directional
,
),
child:
Material
(
...
...
@@ -283,10 +281,10 @@ void main() {
}),
),
);
Focus
.
of
(
childKey
.
currentContext
,
nullOk:
true
)
.
requestFocus
();
Focus
.
of
(
childKey
.
currentContext
!)!
.
requestFocus
();
await
tester
.
pump
();
expect
(
Focus
.
of
(
childKey
.
currentContext
,
nullOk:
true
)
.
hasPrimaryFocus
,
isTrue
);
expect
(
Focus
.
of
(
childKey
.
currentContext
!)!
.
hasPrimaryFocus
,
isTrue
);
});
testWidgets
(
'PopupMenuItem is only focusable when enabled'
,
(
WidgetTester
tester
)
async
{
...
...
@@ -321,7 +319,7 @@ void main() {
// Open the popup to build and show the menu contents.
await
tester
.
tap
(
find
.
byKey
(
popupButtonKey
));
await
tester
.
pumpAndSettle
();
final
FocusNode
childNode
=
Focus
.
of
(
childKey
.
currentContext
,
nullOk:
true
)
;
final
FocusNode
childNode
=
Focus
.
of
(
childKey
.
currentContext
!)!
;
// Now that the contents are shown, request focus on the child text.
childNode
.
requestFocus
();
await
tester
.
pumpAndSettle
();
...
...
@@ -364,7 +362,7 @@ void main() {
await
tester
.
pumpAndSettle
();
expect
(
itemBuilderCalled
,
isTrue
);
expect
(
Focus
.
of
(
childKey
.
currentContext
,
nullOk:
true
)
.
hasPrimaryFocus
,
isFalse
);
expect
(
Focus
.
of
(
childKey
.
currentContext
!)!
.
hasPrimaryFocus
,
isFalse
);
});
testWidgets
(
'PopupMenuButton is horizontal on iOS'
,
(
WidgetTester
tester
)
async
{
...
...
@@ -637,7 +635,7 @@ void main() {
});
testWidgets
(
'PopupMenu removes MediaQuery padding'
,
(
WidgetTester
tester
)
async
{
BuildContext
popupContext
;
late
BuildContext
popupContext
;
await
tester
.
pumpWidget
(
MaterialApp
(
home:
MediaQuery
(
...
...
@@ -674,7 +672,7 @@ void main() {
await
tester
.
pump
();
expect
(
MediaQuery
.
of
(
popupContext
).
padding
,
EdgeInsets
.
zero
);
expect
(
MediaQuery
.
of
(
popupContext
)
!
.
padding
,
EdgeInsets
.
zero
);
});
testWidgets
(
'Popup Menu Offset Test'
,
(
WidgetTester
tester
)
async
{
...
...
@@ -1042,7 +1040,7 @@ void main() {
testWidgets
(
'PopupMenuButton PopupMenuDivider'
,
(
WidgetTester
tester
)
async
{
// Regression test for https://github.com/flutter/flutter/issues/27072
String
selectedValue
;
late
String
selectedValue
;
await
tester
.
pumpWidget
(
MaterialApp
(
home:
Scaffold
(
...
...
@@ -1093,41 +1091,6 @@ void main() {
expect
(
selectedValue
,
'2'
);
});
testWidgets
(
'showMenu position required'
,
(
WidgetTester
tester
)
async
{
// Test for https://github.com/flutter/flutter/issues/22256
await
tester
.
pumpWidget
(
MaterialApp
(
home:
Material
(
child:
Center
(
child:
Builder
(
builder:
(
BuildContext
context
)
{
return
ElevatedButton
(
onPressed:
()
{
// Ensure showMenu throws an assertion without a position
expect
(()
{
// ignore: missing_required_param
showMenu
<
int
>(
context:
context
,
items:
<
PopupMenuItem
<
int
>>[
const
PopupMenuItem
<
int
>(
value:
1
,
child:
Text
(
'1'
),
),
],
);
},
throwsAssertionError
);
},
child:
const
Text
(
'Menu Button'
),
);
},
),
),
),
),
);
await
tester
.
tap
(
find
.
text
(
'Menu Button'
));
});
testWidgets
(
'PopupMenuItem child height is a minimum, child is vertically centered'
,
(
WidgetTester
tester
)
async
{
final
Key
popupMenuButtonKey
=
UniqueKey
();
final
Type
menuItemType
=
const
PopupMenuItem
<
String
>(
child:
Text
(
'item'
)).
runtimeType
;
...
...
@@ -1219,14 +1182,14 @@ void main() {
double
fontSize
=
24
,
})
{
return
MaterialApp
(
builder:
(
BuildContext
context
,
Widget
child
)
{
builder:
(
BuildContext
context
,
Widget
?
child
)
{
return
Directionality
(
textDirection:
textDirection
,
child:
PopupMenuTheme
(
data:
PopupMenuTheme
.
of
(
context
).
copyWith
(
textStyle:
Theme
.
of
(
context
)
.
textTheme
.
subtitle1
.
copyWith
(
fontSize:
fontSize
),
textStyle:
Theme
.
of
(
context
)
!.
textTheme
.
subtitle1
!
.
copyWith
(
fontSize:
fontSize
),
),
child:
child
,
child:
child
!
,
),
);
},
...
...
@@ -1533,7 +1496,7 @@ void main() {
expect
(
find
.
text
(
'Tap me please!'
),
findsNothing
);
globalKey
.
currentState
.
showButtonMenu
();
globalKey
.
currentState
!
.
showButtonMenu
();
// The PopupMenuItem will appear after an animation, hence,
// we have to first wait for the tester to settle.
await
tester
.
pumpAndSettle
();
...
...
@@ -1571,7 +1534,7 @@ void main() {
await
tester
.
pump
();
expect
(
RendererBinding
.
instance
.
mouseTracker
.
debugDeviceActiveCursor
(
1
),
SystemMouseCursors
.
text
);
expect
(
RendererBinding
.
instance
!
.
mouseTracker
.
debugDeviceActiveCursor
(
1
),
SystemMouseCursors
.
text
);
// Test default cursor
await
tester
.
pumpWidget
(
...
...
@@ -1594,7 +1557,7 @@ void main() {
),
);
expect
(
RendererBinding
.
instance
.
mouseTracker
.
debugDeviceActiveCursor
(
1
),
SystemMouseCursors
.
click
);
expect
(
RendererBinding
.
instance
!
.
mouseTracker
.
debugDeviceActiveCursor
(
1
),
SystemMouseCursors
.
click
);
// Test default cursor when disabled
await
tester
.
pumpWidget
(
...
...
@@ -1618,19 +1581,19 @@ void main() {
),
);
expect
(
RendererBinding
.
instance
.
mouseTracker
.
debugDeviceActiveCursor
(
1
),
SystemMouseCursors
.
basic
);
expect
(
RendererBinding
.
instance
!
.
mouseTracker
.
debugDeviceActiveCursor
(
1
),
SystemMouseCursors
.
basic
);
});
}
class
TestApp
extends
StatefulWidget
{
const
TestApp
({
Key
key
,
this
.
textDirection
,
Key
?
key
,
required
this
.
textDirection
,
this
.
child
,
})
:
super
(
key:
key
);
final
TextDirection
textDirection
;
final
Widget
child
;
final
Widget
?
child
;
@override
_TestAppState
createState
()
=>
_TestAppState
();
...
...
@@ -1670,7 +1633,7 @@ class MenuObserver extends NavigatorObserver {
int
menuCount
=
0
;
@override
void
didPush
(
Route
<
dynamic
>
route
,
Route
<
dynamic
>
previousRoute
)
{
void
didPush
(
Route
<
dynamic
>
route
,
Route
<
dynamic
>
?
previousRoute
)
{
if
(
route
.
toString
().
contains
(
'_PopupMenuRoute'
))
{
menuCount
++;
}
...
...
packages/flutter/test/material/popup_menu_theme_test.dart
View file @
3961a12a
...
...
@@ -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'
;
...
...
@@ -79,7 +77,7 @@ void main() {
PopupMenuButton
<
void
>(
key:
popupButtonKey
,
itemBuilder:
(
BuildContext
context
)
{
return
<
PopupMenuEntry
<
Object
>>[
return
<
PopupMenuEntry
<
void
>>[
PopupMenuItem
<
void
>(
key:
popupItemKey
,
child:
const
Text
(
'Example'
),
...
...
@@ -139,7 +137,7 @@ void main() {
key:
popupButtonKey
,
itemBuilder:
(
BuildContext
context
)
{
return
<
PopupMenuEntry
<
Object
>>[
PopupMenuItem
<
void
>(
PopupMenuItem
<
Object
>(
key:
popupItemKey
,
child:
const
Text
(
'Example'
),
),
...
...
@@ -206,7 +204,7 @@ void main() {
color:
color
,
shape:
shape
,
itemBuilder:
(
BuildContext
context
)
{
return
<
PopupMenuEntry
<
Object
>>[
return
<
PopupMenuEntry
<
void
>>[
PopupMenuItem
<
void
>(
key:
popupItemKey
,
textStyle:
textStyle
,
...
...
@@ -270,7 +268,7 @@ void main() {
child:
PopupMenuButton
<
void
>(
key:
popupButtonKey
,
itemBuilder:
(
BuildContext
context
)
{
return
<
PopupMenuEntry
<
Object
>>[
return
<
PopupMenuEntry
<
void
>>[
PopupMenuItem
<
void
>(
key:
popupItemKey
,
child:
const
Text
(
'Example'
),
...
...
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