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
9bf8502f
Unverified
Commit
9bf8502f
authored
Sep 13, 2018
by
Jonah Williams
Committed by
GitHub
Sep 13, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add debug check for localization parent (#20787)
parent
199422cd
Changes
26
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
26 changed files
with
621 additions
and
354 deletions
+621
-354
about.dart
packages/flutter/lib/src/material/about.dart
+3
-0
app_bar.dart
packages/flutter/lib/src/material/app_bar.dart
+2
-0
back_button.dart
packages/flutter/lib/src/material/back_button.dart
+2
-0
bottom_navigation_bar.dart
packages/flutter/lib/src/material/bottom_navigation_bar.dart
+2
-0
bottom_sheet.dart
packages/flutter/lib/src/material/bottom_sheet.dart
+2
-0
chip.dart
packages/flutter/lib/src/material/chip.dart
+1
-0
date_picker.dart
packages/flutter/lib/src/material/date_picker.dart
+1
-0
debug.dart
packages/flutter/lib/src/material/debug.dart
+61
-0
dialog.dart
packages/flutter/lib/src/material/dialog.dart
+4
-0
drawer.dart
packages/flutter/lib/src/material/drawer.dart
+3
-0
dropdown.dart
packages/flutter/lib/src/material/dropdown.dart
+2
-0
expand_icon.dart
packages/flutter/lib/src/material/expand_icon.dart
+1
-0
paginated_data_table.dart
packages/flutter/lib/src/material/paginated_data_table.dart
+2
-0
popup_menu.dart
packages/flutter/lib/src/material/popup_menu.dart
+3
-0
reorderable_list.dart
packages/flutter/lib/src/material/reorderable_list.dart
+2
-0
search.dart
packages/flutter/lib/src/material/search.dart
+2
-0
text_field.dart
packages/flutter/lib/src/material/text_field.dart
+2
-0
user_accounts_drawer_header.dart
...flutter/lib/src/material/user_accounts_drawer_header.dart
+2
-0
app_bar_test.dart
packages/flutter/test/material/app_bar_test.dart
+85
-36
chip_theme_test.dart
packages/flutter/test/material/chip_theme_test.dart
+7
-4
floating_action_button_location_test.dart
...r/test/material/floating_action_button_location_test.dart
+8
-2
scaffold_test.dart
packages/flutter/test/material/scaffold_test.dart
+152
-124
nested_scroll_view_test.dart
packages/flutter/test/widgets/nested_scroll_view_test.dart
+20
-13
scrollable_semantics_test.dart
packages/flutter/test/widgets/scrollable_semantics_test.dart
+50
-36
sliver_semantics_test.dart
packages/flutter/test/widgets/sliver_semantics_test.dart
+175
-119
slivers_appbar_floating_pinned_test.dart
...ter/test/widgets/slivers_appbar_floating_pinned_test.dart
+27
-20
No files found.
packages/flutter/lib/src/material/about.dart
View file @
9bf8502f
...
...
@@ -109,6 +109,7 @@ class AboutListTile extends StatelessWidget {
@override
Widget
build
(
BuildContext
context
)
{
assert
(
debugCheckHasMaterial
(
context
));
assert
(
debugCheckHasMaterialLocalizations
(
context
));
return
ListTile
(
leading:
icon
,
title:
child
??
...
...
@@ -263,6 +264,7 @@ class AboutDialog extends StatelessWidget {
@override
Widget
build
(
BuildContext
context
)
{
assert
(
debugCheckHasMaterialLocalizations
(
context
));
final
String
name
=
applicationName
??
_defaultApplicationName
(
context
);
final
String
version
=
applicationVersion
??
_defaultApplicationVersion
(
context
);
final
Widget
icon
=
applicationIcon
??
_defaultApplicationIcon
(
context
);
...
...
@@ -437,6 +439,7 @@ class _LicensePageState extends State<LicensePage> {
@override
Widget
build
(
BuildContext
context
)
{
assert
(
debugCheckHasMaterialLocalizations
(
context
));
final
String
name
=
widget
.
applicationName
??
_defaultApplicationName
(
context
);
final
String
version
=
widget
.
applicationVersion
??
_defaultApplicationVersion
(
context
);
final
MaterialLocalizations
localizations
=
MaterialLocalizations
.
of
(
context
);
...
...
packages/flutter/lib/src/material/app_bar.dart
View file @
9bf8502f
...
...
@@ -11,6 +11,7 @@ import 'package:flutter/widgets.dart';
import
'back_button.dart'
;
import
'constants.dart'
;
import
'debug.dart'
;
import
'flexible_space_bar.dart'
;
import
'icon_button.dart'
;
import
'icons.dart'
;
...
...
@@ -332,6 +333,7 @@ class _AppBarState extends State<AppBar> {
@override
Widget
build
(
BuildContext
context
)
{
assert
(!
widget
.
primary
||
debugCheckHasMediaQuery
(
context
));
assert
(
debugCheckHasMaterialLocalizations
(
context
));
final
ThemeData
themeData
=
Theme
.
of
(
context
);
final
ScaffoldState
scaffold
=
Scaffold
.
of
(
context
,
nullOk:
true
);
final
ModalRoute
<
dynamic
>
parentRoute
=
ModalRoute
.
of
(
context
);
...
...
packages/flutter/lib/src/material/back_button.dart
View file @
9bf8502f
...
...
@@ -4,6 +4,7 @@
import
'package:flutter/widgets.dart'
;
import
'debug.dart'
;
import
'icon_button.dart'
;
import
'icons.dart'
;
import
'material_localizations.dart'
;
...
...
@@ -81,6 +82,7 @@ class BackButton extends StatelessWidget {
@override
Widget
build
(
BuildContext
context
)
{
assert
(
debugCheckHasMaterialLocalizations
(
context
));
return
IconButton
(
icon:
const
BackButtonIcon
(),
color:
color
,
...
...
packages/flutter/lib/src/material/bottom_navigation_bar.dart
View file @
9bf8502f
...
...
@@ -10,6 +10,7 @@ import 'package:vector_math/vector_math_64.dart' show Vector3;
import
'colors.dart'
;
import
'constants.dart'
;
import
'debug.dart'
;
import
'ink_well.dart'
;
import
'material.dart'
;
import
'material_localizations.dart'
;
...
...
@@ -495,6 +496,7 @@ class _BottomNavigationBarState extends State<BottomNavigationBar> with TickerPr
@override
Widget
build
(
BuildContext
context
)
{
assert
(
debugCheckHasDirectionality
(
context
));
assert
(
debugCheckHasMaterialLocalizations
(
context
));
// Labels apply up to _bottomMargin padding. Remainder is media padding.
final
double
additionalBottomPadding
=
math
.
max
(
MediaQuery
.
of
(
context
).
padding
.
bottom
-
_kBottomMargin
,
0.0
);
...
...
packages/flutter/lib/src/material/bottom_sheet.dart
View file @
9bf8502f
...
...
@@ -8,6 +8,7 @@ import 'package:flutter/foundation.dart';
import
'package:flutter/widgets.dart'
;
import
'colors.dart'
;
import
'debug.dart'
;
import
'material.dart'
;
import
'material_localizations.dart'
;
import
'scaffold.dart'
;
...
...
@@ -315,6 +316,7 @@ Future<T> showModalBottomSheet<T>({
})
{
assert
(
context
!=
null
);
assert
(
builder
!=
null
);
assert
(
debugCheckHasMaterialLocalizations
(
context
));
return
Navigator
.
push
(
context
,
_ModalBottomSheetRoute
<
T
>(
builder:
builder
,
theme:
Theme
.
of
(
context
,
shadowThemeOnly:
true
),
...
...
packages/flutter/lib/src/material/chip.dart
View file @
9bf8502f
...
...
@@ -1429,6 +1429,7 @@ class _RawChipState extends State<RawChip> with TickerProviderStateMixin<RawChip
assert
(
debugCheckHasMaterial
(
context
));
assert
(
debugCheckHasMediaQuery
(
context
));
assert
(
debugCheckHasDirectionality
(
context
));
assert
(
debugCheckHasMaterialLocalizations
(
context
));
final
ThemeData
theme
=
Theme
.
of
(
context
);
final
ChipThemeData
chipTheme
=
ChipTheme
.
of
(
context
);
...
...
packages/flutter/lib/src/material/date_picker.dart
View file @
9bf8502f
...
...
@@ -945,6 +945,7 @@ class _DatePickerDialogState extends State<_DatePickerDialog> {
@override
Widget
build
(
BuildContext
context
)
{
assert
(
debugCheckHasMaterialLocalizations
(
context
));
final
ThemeData
theme
=
Theme
.
of
(
context
);
final
Widget
picker
=
Flexible
(
child:
SizedBox
(
...
...
packages/flutter/lib/src/material/debug.dart
View file @
9bf8502f
...
...
@@ -5,6 +5,7 @@
import
'package:flutter/widgets.dart'
;
import
'material.dart'
;
import
'material_localizations.dart'
;
/// Asserts that the given context has a [Material] ancestor.
///
...
...
@@ -66,3 +67,63 @@ bool debugCheckHasMaterial(BuildContext context) {
}());
return
true
;
}
/// Asserts that the given context has a [Localizations] ancestor that contains
/// a [MaterialLocalizations] delegate.
///
/// Used by many material design widgets to make sure that they are
/// only used in contexts where they have access to localizations.
///
/// To call this function, use the following pattern, typically in the
/// relevant Widget's build method:
///
/// ```dart
/// assert(debugCheckHasMaterialLocalizations(context));
/// ```
///
/// Does nothing if asserts are disabled. Always returns true.
bool
debugCheckHasMaterialLocalizations
(
BuildContext
context
)
{
assert
(()
{
if
(
Localizations
.
of
<
MaterialLocalizations
>(
context
,
MaterialLocalizations
)
==
null
)
{
final
StringBuffer
message
=
StringBuffer
();
message
.
writeln
(
'No MaterialLocalizations found.'
);
message
.
writeln
(
'
${context.widget.runtimeType}
widgets require MaterialLocalizations '
'to be provided by a Localizations widget ancestor.'
);
message
.
writeln
(
'Localizations are used to generate many different messages, labels,'
'and abbreviations which are used by the material library. '
);
message
.
writeln
(
'To introduce a MaterialLocalizations, either use a '
' MaterialApp at the root of your application to include them '
'automatically, or add a Localization widget with a '
'MaterialLocalizations delegate.'
);
message
.
writeln
(
'The specific widget that could not find a MaterialLocalizations ancestor was:'
);
message
.
writeln
(
'
${context.widget}
'
);
final
List
<
Widget
>
ancestors
=
<
Widget
>[];
context
.
visitAncestorElements
((
Element
element
)
{
ancestors
.
add
(
element
.
widget
);
return
true
;
});
if
(
ancestors
.
isNotEmpty
)
{
message
.
write
(
'The ancestors of this widget were:'
);
for
(
Widget
ancestor
in
ancestors
)
message
.
write
(
'
\n
$ancestor
'
);
}
else
{
message
.
writeln
(
'This widget is the root of the tree, so it has no '
'ancestors, let alone a "Localizations" ancestor.'
);
}
throw
FlutterError
(
message
.
toString
());
}
return
true
;
}());
return
true
;
}
packages/flutter/lib/src/material/dialog.dart
View file @
9bf8502f
...
...
@@ -11,6 +11,7 @@ import 'package:flutter/widgets.dart';
import
'button_bar.dart'
;
import
'button_theme.dart'
;
import
'colors.dart'
;
import
'debug.dart'
;
import
'ink_well.dart'
;
import
'material.dart'
;
import
'material_localizations.dart'
;
...
...
@@ -232,6 +233,7 @@ class AlertDialog extends StatelessWidget {
@override
Widget
build
(
BuildContext
context
)
{
assert
(
debugCheckHasMaterialLocalizations
(
context
));
final
List
<
Widget
>
children
=
<
Widget
>[];
String
label
=
semanticLabel
;
...
...
@@ -490,6 +492,7 @@ class SimpleDialog extends StatelessWidget {
@override
Widget
build
(
BuildContext
context
)
{
assert
(
debugCheckHasMaterialLocalizations
(
context
));
final
List
<
Widget
>
body
=
<
Widget
>[];
String
label
=
semanticLabel
;
...
...
@@ -596,6 +599,7 @@ Future<T> showDialog<T>({
WidgetBuilder
builder
,
})
{
assert
(
child
==
null
||
builder
==
null
);
assert
(
debugCheckHasMaterialLocalizations
(
context
));
return
showGeneralDialog
(
context:
context
,
pageBuilder:
(
BuildContext
buildContext
,
Animation
<
double
>
animation
,
Animation
<
double
>
secondaryAnimation
)
{
...
...
packages/flutter/lib/src/material/drawer.dart
View file @
9bf8502f
...
...
@@ -6,6 +6,7 @@ import 'package:flutter/foundation.dart';
import
'package:flutter/widgets.dart'
;
import
'colors.dart'
;
import
'debug.dart'
;
import
'list_tile.dart'
;
import
'material.dart'
;
import
'material_localizations.dart'
;
...
...
@@ -116,6 +117,7 @@ class Drawer extends StatelessWidget {
@override
Widget
build
(
BuildContext
context
)
{
assert
(
debugCheckHasMaterialLocalizations
(
context
));
String
label
=
semanticLabel
;
switch
(
defaultTargetPlatform
)
{
case
TargetPlatform
.
iOS
:
...
...
@@ -431,6 +433,7 @@ class DrawerControllerState extends State<DrawerController> with SingleTickerPro
}
@override
Widget
build
(
BuildContext
context
)
{
assert
(
debugCheckHasMaterialLocalizations
(
context
));
return
ListTileTheme
(
style:
ListTileStyle
.
drawer
,
child:
_buildDrawer
(
context
),
...
...
packages/flutter/lib/src/material/dropdown.dart
View file @
9bf8502f
...
...
@@ -139,6 +139,7 @@ class _DropdownMenuState<T> extends State<_DropdownMenu<T>> {
//
// When the menu is dismissed we just fade the entire thing out
// in the first 0.25s.
assert
(
debugCheckHasMaterialLocalizations
(
context
));
final
MaterialLocalizations
localizations
=
MaterialLocalizations
.
of
(
context
);
final
_DropdownRoute
<
T
>
route
=
widget
.
route
;
final
double
unit
=
0.5
/
(
route
.
items
.
length
+
1.5
);
...
...
@@ -631,6 +632,7 @@ class _DropdownButtonState<T> extends State<DropdownButton<T>> with WidgetsBindi
@override
Widget
build
(
BuildContext
context
)
{
assert
(
debugCheckHasMaterial
(
context
));
assert
(
debugCheckHasMaterialLocalizations
(
context
));
// The width of the button and the menu are defined by the widest
// item and the width of the hint.
...
...
packages/flutter/lib/src/material/expand_icon.dart
View file @
9bf8502f
...
...
@@ -109,6 +109,7 @@ class _ExpandIconState extends State<ExpandIcon> with SingleTickerProviderStateM
@override
Widget
build
(
BuildContext
context
)
{
assert
(
debugCheckHasMaterial
(
context
));
assert
(
debugCheckHasMaterialLocalizations
(
context
));
final
MaterialLocalizations
localizations
=
MaterialLocalizations
.
of
(
context
);
final
ThemeData
theme
=
Theme
.
of
(
context
);
final
String
onTapHint
=
widget
.
isExpanded
?
localizations
.
expandedIconTapHint
:
localizations
.
collapsedIconTapHint
;
...
...
packages/flutter/lib/src/material/paginated_data_table.dart
View file @
9bf8502f
...
...
@@ -12,6 +12,7 @@ import 'button_theme.dart';
import
'card.dart'
;
import
'data_table.dart'
;
import
'data_table_source.dart'
;
import
'debug.dart'
;
import
'dropdown.dart'
;
import
'icon_button.dart'
;
import
'icons.dart'
;
...
...
@@ -286,6 +287,7 @@ class PaginatedDataTableState extends State<PaginatedDataTable> {
@override
Widget
build
(
BuildContext
context
)
{
// TODO(ianh): This whole build function doesn't handle RTL yet.
assert
(
debugCheckHasMaterialLocalizations
(
context
));
final
ThemeData
themeData
=
Theme
.
of
(
context
);
final
MaterialLocalizations
localizations
=
MaterialLocalizations
.
of
(
context
);
// HEADER
...
...
packages/flutter/lib/src/material/popup_menu.dart
View file @
9bf8502f
...
...
@@ -8,6 +8,7 @@ import 'package:flutter/foundation.dart';
import
'package:flutter/widgets.dart'
;
import
'constants.dart'
;
import
'debug.dart'
;
import
'divider.dart'
;
import
'icon_button.dart'
;
import
'icons.dart'
;
...
...
@@ -713,6 +714,7 @@ Future<T> showMenu<T>({
})
{
assert
(
context
!=
null
);
assert
(
items
!=
null
&&
items
.
isNotEmpty
);
assert
(
debugCheckHasMaterialLocalizations
(
context
));
String
label
=
semanticLabel
;
switch
(
defaultTargetPlatform
)
{
case
TargetPlatform
.
iOS
:
...
...
@@ -911,6 +913,7 @@ class _PopupMenuButtonState<T> extends State<PopupMenuButton<T>> {
@override
Widget
build
(
BuildContext
context
)
{
assert
(
debugCheckHasMaterialLocalizations
(
context
));
return
widget
.
child
!=
null
?
InkWell
(
onTap:
showButtonMenu
,
...
...
packages/flutter/lib/src/material/reorderable_list.dart
View file @
9bf8502f
...
...
@@ -7,6 +7,7 @@ import 'dart:math';
import
'package:flutter/widgets.dart'
;
import
'package:flutter/rendering.dart'
;
import
'debug.dart'
;
import
'material.dart'
;
import
'material_localizations.dart'
;
...
...
@@ -510,6 +511,7 @@ class _ReorderableListContentState extends State<_ReorderableListContent> with T
@override
Widget
build
(
BuildContext
context
)
{
assert
(
debugCheckHasMaterialLocalizations
(
context
));
// We use the layout builder to constrain the cross-axis size of dragging child widgets.
return
LayoutBuilder
(
builder:
(
BuildContext
context
,
BoxConstraints
constraints
)
{
final
List
<
Widget
>
wrappedChildren
=
<
Widget
>[];
...
...
packages/flutter/lib/src/material/search.dart
View file @
9bf8502f
...
...
@@ -9,6 +9,7 @@ import 'package:flutter/widgets.dart';
import
'app_bar.dart'
;
import
'colors.dart'
;
import
'debug.dart'
;
import
'input_border.dart'
;
import
'input_decorator.dart'
;
import
'material_localizations.dart'
;
...
...
@@ -389,6 +390,7 @@ class _SearchPageState<T> extends State<_SearchPage<T>> {
@override
Widget
build
(
BuildContext
context
)
{
assert
(
debugCheckHasMaterialLocalizations
(
context
));
final
ThemeData
theme
=
widget
.
delegate
.
appBarTheme
(
context
);
final
String
searchFieldLabel
=
MaterialLocalizations
.
of
(
context
).
searchFieldLabel
;
Widget
body
;
...
...
packages/flutter/lib/src/material/text_field.dart
View file @
9bf8502f
...
...
@@ -540,6 +540,8 @@ class _TextFieldState extends State<TextField> with AutomaticKeepAliveClientMixi
Widget
build
(
BuildContext
context
)
{
super
.
build
(
context
);
// See AutomaticKeepAliveClientMixin.
assert
(
debugCheckHasMaterial
(
context
));
// TODO(jonahwilliams): uncomment out this check once we have migrated tests.
// assert(debugCheckHasMaterialLocalizations(context));
assert
(
debugCheckHasDirectionality
(
context
));
final
ThemeData
themeData
=
Theme
.
of
(
context
);
final
TextStyle
style
=
widget
.
style
??
themeData
.
textTheme
.
subhead
;
...
...
packages/flutter/lib/src/material/user_accounts_drawer_header.dart
View file @
9bf8502f
...
...
@@ -79,6 +79,7 @@ class _AccountDetails extends StatelessWidget {
@override
Widget
build
(
BuildContext
context
)
{
assert
(
debugCheckHasDirectionality
(
context
));
assert
(
debugCheckHasMaterialLocalizations
(
context
));
final
ThemeData
theme
=
Theme
.
of
(
context
);
final
List
<
Widget
>
children
=
<
Widget
>[];
...
...
@@ -308,6 +309,7 @@ class _UserAccountsDrawerHeaderState extends State<UserAccountsDrawerHeader> {
@override
Widget
build
(
BuildContext
context
)
{
assert
(
debugCheckHasMaterial
(
context
));
assert
(
debugCheckHasMaterialLocalizations
(
context
));
return
Semantics
(
container:
true
,
label:
MaterialLocalizations
.
of
(
context
).
signedInLabel
,
...
...
packages/flutter/test/material/app_bar_test.dart
View file @
9bf8502f
...
...
@@ -845,7 +845,13 @@ void main() {
const
MediaQueryData
topPadding100
=
MediaQueryData
(
padding:
EdgeInsets
.
only
(
top:
100.0
));
await
tester
.
pumpWidget
(
Directionality
(
Localizations
(
locale:
const
Locale
(
'en'
,
'US'
),
delegates:
const
<
LocalizationsDelegate
<
dynamic
>>[
DefaultMaterialLocalizations
.
delegate
,
DefaultWidgetsLocalizations
.
delegate
,
],
child:
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
MediaQuery
(
data:
topPadding100
,
...
...
@@ -855,48 +861,66 @@ void main() {
),
),
),
);
)
)
;
expect
(
appBarTop
(
tester
),
0.0
);
expect
(
appBarHeight
(
tester
),
kToolbarHeight
);
await
tester
.
pumpWidget
(
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
MediaQuery
(
data:
topPadding100
,
child:
Scaffold
(
primary:
true
,
appBar:
AppBar
(
title:
const
Text
(
'title'
))
Localizations
(
locale:
const
Locale
(
'en'
,
'US'
),
delegates:
const
<
LocalizationsDelegate
<
dynamic
>>[
DefaultMaterialLocalizations
.
delegate
,
DefaultWidgetsLocalizations
.
delegate
,
],
child:
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
MediaQuery
(
data:
topPadding100
,
child:
Scaffold
(
primary:
true
,
appBar:
AppBar
(
title:
const
Text
(
'title'
))
),
),
),
);
)
)
;
expect
(
appBarTop
(
tester
),
0.0
);
expect
(
tester
.
getTopLeft
(
find
.
text
(
'title'
)).
dy
,
greaterThan
(
100.0
));
expect
(
appBarHeight
(
tester
),
kToolbarHeight
+
100.0
);
await
tester
.
pumpWidget
(
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
MediaQuery
(
data:
topPadding100
,
child:
Scaffold
(
primary:
false
,
appBar:
AppBar
(
bottom:
PreferredSize
(
preferredSize:
const
Size
.
fromHeight
(
200.0
),
child:
Container
(),
Localizations
(
locale:
const
Locale
(
'en'
,
'US'
),
delegates:
const
<
LocalizationsDelegate
<
dynamic
>>[
DefaultMaterialLocalizations
.
delegate
,
DefaultWidgetsLocalizations
.
delegate
,
],
child:
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
MediaQuery
(
data:
topPadding100
,
child:
Scaffold
(
primary:
false
,
appBar:
AppBar
(
bottom:
PreferredSize
(
preferredSize:
const
Size
.
fromHeight
(
200.0
),
child:
Container
(),
),
),
),
),
),
);
)
)
;
expect
(
appBarTop
(
tester
),
0.0
);
expect
(
appBarHeight
(
tester
),
kToolbarHeight
+
200.0
);
await
tester
.
pumpWidget
(
Directionality
(
Localizations
(
locale:
const
Locale
(
'en'
,
'US'
),
delegates:
const
<
LocalizationsDelegate
<
dynamic
>>[
DefaultMaterialLocalizations
.
delegate
,
DefaultWidgetsLocalizations
.
delegate
,
],
child:
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
MediaQuery
(
data:
topPadding100
,
...
...
@@ -911,18 +935,25 @@ void main() {
),
),
),
);
)
)
;
expect
(
appBarTop
(
tester
),
0.0
);
expect
(
appBarHeight
(
tester
),
kToolbarHeight
+
100.0
+
200.0
);
await
tester
.
pumpWidget
(
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
MediaQuery
(
data:
topPadding100
,
child:
AppBar
(
primary:
false
,
title:
const
Text
(
'title'
),
Localizations
(
locale:
const
Locale
(
'en'
,
'US'
),
delegates:
const
<
LocalizationsDelegate
<
dynamic
>>[
DefaultMaterialLocalizations
.
delegate
,
DefaultWidgetsLocalizations
.
delegate
,
],
child:
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
MediaQuery
(
data:
topPadding100
,
child:
AppBar
(
primary:
false
,
title:
const
Text
(
'title'
),
),
),
),
),
...
...
@@ -1095,7 +1126,13 @@ void main() {
final
Key
trailingKey
=
UniqueKey
();
await
tester
.
pumpWidget
(
Directionality
(
Localizations
(
locale:
const
Locale
(
'en'
,
'US'
),
delegates:
const
<
LocalizationsDelegate
<
dynamic
>>[
DefaultMaterialLocalizations
.
delegate
,
DefaultWidgetsLocalizations
.
delegate
,
],
child:
Directionality
(
textDirection:
TextDirection
.
rtl
,
child:
MediaQuery
(
data:
topPadding100
,
...
...
@@ -1109,7 +1146,7 @@ void main() {
),
),
),
);
)
)
;
expect
(
tester
.
getTopLeft
(
find
.
byType
(
AppBar
)),
const
Offset
(
0.0
,
0.0
));
expect
(
tester
.
getTopLeft
(
find
.
byKey
(
leadingKey
)),
const
Offset
(
800.0
-
56.0
,
100.0
));
expect
(
tester
.
getTopLeft
(
find
.
byKey
(
titleKey
)),
const
Offset
(
416.0
,
100.0
));
...
...
@@ -1124,7 +1161,13 @@ void main() {
final
Key
trailingKey
=
UniqueKey
();
await
tester
.
pumpWidget
(
Directionality
(
Localizations
(
locale:
const
Locale
(
'en'
,
'US'
),
delegates:
const
<
LocalizationsDelegate
<
dynamic
>>[
DefaultMaterialLocalizations
.
delegate
,
DefaultWidgetsLocalizations
.
delegate
,
],
child:
Directionality
(
textDirection:
TextDirection
.
rtl
,
child:
MediaQuery
(
data:
topPadding100
,
...
...
@@ -1140,7 +1183,7 @@ void main() {
),
),
),
);
)
)
;
expect
(
tester
.
getTopLeft
(
find
.
byType
(
AppBar
)),
const
Offset
(
0.0
,
0.0
));
expect
(
tester
.
getTopLeft
(
find
.
byKey
(
leadingKey
)),
const
Offset
(
800.0
-
56.0
,
100.0
));
expect
(
tester
.
getTopLeft
(
find
.
byKey
(
titleKey
)),
const
Offset
(
416.0
,
100.0
));
...
...
@@ -1155,7 +1198,13 @@ void main() {
final
Key
trailingKey
=
UniqueKey
();
await
tester
.
pumpWidget
(
Directionality
(
Localizations
(
locale:
const
Locale
(
'en'
,
'US'
),
delegates:
const
<
LocalizationsDelegate
<
dynamic
>>[
DefaultMaterialLocalizations
.
delegate
,
DefaultWidgetsLocalizations
.
delegate
,
],
child:
Directionality
(
textDirection:
TextDirection
.
rtl
,
child:
MediaQuery
(
data:
topPadding100
,
...
...
@@ -1171,7 +1220,7 @@ void main() {
),
),
),
);
)
)
;
expect
(
tester
.
getRect
(
find
.
byType
(
AppBar
)),
Rect
.
fromLTRB
(
0.0
,
0.0
,
800.00
,
100.0
+
56.0
));
expect
(
tester
.
getRect
(
find
.
byKey
(
leadingKey
)),
Rect
.
fromLTRB
(
800.0
-
56.0
,
100.0
,
800.0
,
100.0
+
56.0
));
expect
(
tester
.
getRect
(
find
.
byKey
(
trailingKey
)),
Rect
.
fromLTRB
(
0.0
,
100.0
,
400.0
,
100.0
+
56.0
));
...
...
packages/flutter/test/material/chip_theme_test.dart
View file @
9bf8502f
...
...
@@ -64,7 +64,9 @@ void main() {
bool
value
;
Widget
buildChip
(
ChipThemeData
data
)
{
return
Directionality
(
return
MaterialApp
(
locale:
const
Locale
(
'en'
,
'us'
),
home:
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
MediaQuery
(
data:
MediaQueryData
.
fromWindow
(
window
),
...
...
@@ -88,7 +90,7 @@ void main() {
),
),
),
);
)
)
;
}
await
tester
.
pumpWidget
(
buildChip
(
chipTheme
));
...
...
@@ -111,7 +113,8 @@ void main() {
);
const
bool
value
=
false
;
Widget
buildChip
(
ChipThemeData
data
)
{
return
Directionality
(
return
MaterialApp
(
home:
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
MediaQuery
(
data:
MediaQueryData
.
fromWindow
(
window
),
...
...
@@ -138,7 +141,7 @@ void main() {
),
),
),
);
)
)
;
}
await
tester
.
pumpWidget
(
buildChip
(
chipTheme
));
...
...
packages/flutter/test/material/floating_action_button_location_test.dart
View file @
9bf8502f
...
...
@@ -243,7 +243,13 @@ Widget buildFrame({
EdgeInsets
viewInsets
=
const
EdgeInsets
.
only
(
bottom:
200.0
),
Widget
bab
,
})
{
return
Directionality
(
return
Localizations
(
locale:
const
Locale
(
'en'
,
'us'
),
delegates:
const
<
LocalizationsDelegate
<
dynamic
>>[
DefaultWidgetsLocalizations
.
delegate
,
DefaultMaterialLocalizations
.
delegate
,
],
child:
Directionality
(
textDirection:
textDirection
,
child:
MediaQuery
(
data:
MediaQueryData
(
viewInsets:
viewInsets
),
...
...
@@ -255,7 +261,7 @@ Widget buildFrame({
body:
listener
,
),
),
);
)
)
;
}
class
_StartTopFloatingActionButtonLocation
extends
FloatingActionButtonLocation
{
...
...
packages/flutter/test/material/scaffold_test.dart
View file @
9bf8502f
This diff is collapsed.
Click to expand it.
packages/flutter/test/widgets/nested_scroll_view_test.dart
View file @
9bf8502f
...
...
@@ -318,19 +318,26 @@ void main() {
testWidgets
(
'NestedScrollViews with custom physics'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
MediaQuery
(
data:
const
MediaQueryData
(),
child:
NestedScrollView
(
physics:
const
_CustomPhysics
(),
headerSliverBuilder:
(
BuildContext
context
,
bool
innerBoxIsScrolled
)
{
return
<
Widget
>[
const
SliverAppBar
(
floating:
true
,
title:
Text
(
'AA'
),
),
];
},
body:
Container
(),
child:
Localizations
(
locale:
const
Locale
(
'en'
,
'US'
),
delegates:
const
<
LocalizationsDelegate
<
dynamic
>>[
DefaultMaterialLocalizations
.
delegate
,
DefaultWidgetsLocalizations
.
delegate
,
],
child:
MediaQuery
(
data:
const
MediaQueryData
(),
child:
NestedScrollView
(
physics:
const
_CustomPhysics
(),
headerSliverBuilder:
(
BuildContext
context
,
bool
innerBoxIsScrolled
)
{
return
<
Widget
>[
const
SliverAppBar
(
floating:
true
,
title:
Text
(
'AA'
),
),
];
},
body:
Container
(),
),
),
),
));
...
...
packages/flutter/test/widgets/scrollable_semantics_test.dart
View file @
9bf8502f
...
...
@@ -105,27 +105,34 @@ void main() {
await
tester
.
pumpWidget
(
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
MediaQuery
(
data:
const
MediaQueryData
(),
child:
Scrollable
(
controller:
scrollController
,
viewportBuilder:
(
BuildContext
context
,
ViewportOffset
offset
)
{
return
Viewport
(
offset:
offset
,
slivers:
<
Widget
>[
const
SliverAppBar
(
pinned:
true
,
expandedHeight:
kExpandedAppBarHeight
,
flexibleSpace:
FlexibleSpaceBar
(
title:
Text
(
'App Bar'
),
),
),
SliverList
(
delegate:
SliverChildListDelegate
(
containers
),
)
],
);
}),
child:
Localizations
(
locale:
const
Locale
(
'en'
,
'us'
),
delegates:
const
<
LocalizationsDelegate
<
dynamic
>>[
DefaultWidgetsLocalizations
.
delegate
,
DefaultMaterialLocalizations
.
delegate
,
],
child:
MediaQuery
(
data:
const
MediaQueryData
(),
child:
Scrollable
(
controller:
scrollController
,
viewportBuilder:
(
BuildContext
context
,
ViewportOffset
offset
)
{
return
Viewport
(
offset:
offset
,
slivers:
<
Widget
>[
const
SliverAppBar
(
pinned:
true
,
expandedHeight:
kExpandedAppBarHeight
,
flexibleSpace:
FlexibleSpaceBar
(
title:
Text
(
'App Bar'
),
),
),
SliverList
(
delegate:
SliverChildListDelegate
(
containers
),
)
],
);
}),
),
),
));
...
...
@@ -169,22 +176,29 @@ void main() {
textDirection:
TextDirection
.
ltr
,
child:
MediaQuery
(
data:
const
MediaQueryData
(),
child:
Scrollable
(
controller:
scrollController
,
viewportBuilder:
(
BuildContext
context
,
ViewportOffset
offset
)
{
return
Viewport
(
offset:
offset
,
slivers:
<
Widget
>[
const
SliverAppBar
(
pinned:
true
,
expandedHeight:
kExpandedAppBarHeight
,
flexibleSpace:
FlexibleSpaceBar
(
title:
Text
(
'App Bar'
),
child:
Localizations
(
locale:
const
Locale
(
'en'
,
'us'
),
delegates:
const
<
LocalizationsDelegate
<
dynamic
>>[
DefaultWidgetsLocalizations
.
delegate
,
DefaultMaterialLocalizations
.
delegate
,
],
child:
Scrollable
(
controller:
scrollController
,
viewportBuilder:
(
BuildContext
context
,
ViewportOffset
offset
)
{
return
Viewport
(
offset:
offset
,
slivers:
<
Widget
>[
const
SliverAppBar
(
pinned:
true
,
expandedHeight:
kExpandedAppBarHeight
,
flexibleSpace:
FlexibleSpaceBar
(
title:
Text
(
'App Bar'
),
),
),
),
]..
addAll
(
slivers
),
);
}
,
]..
addAll
(
slivers
),
);
},
)
,
),
),
));
...
...
packages/flutter/test/widgets/sliver_semantics_test.dart
View file @
9bf8502f
This diff is collapsed.
Click to expand it.
packages/flutter/test/widgets/slivers_appbar_floating_pinned_test.dart
View file @
9bf8502f
...
...
@@ -9,27 +9,34 @@ void main() {
testWidgets
(
'Sliver appbars - floating and pinned - second app bar stacks below'
,
(
WidgetTester
tester
)
async
{
final
ScrollController
controller
=
ScrollController
();
await
tester
.
pumpWidget
(
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
MediaQuery
(
data:
const
MediaQueryData
(),
child:
CustomScrollView
(
controller:
controller
,
slivers:
const
<
Widget
>[
SliverAppBar
(
floating:
true
,
pinned:
true
,
expandedHeight:
200.0
,
title:
Text
(
'A'
)),
SliverAppBar
(
primary:
false
,
pinned:
true
,
title:
Text
(
'B'
)),
SliverList
(
delegate:
SliverChildListDelegate
(
<
Widget
>[
Text
(
'C'
),
Text
(
'D'
),
SizedBox
(
height:
500.0
),
Text
(
'E'
),
SizedBox
(
height:
500.0
),
],
Localizations
(
locale:
const
Locale
(
'en'
,
'us'
),
delegates:
const
<
LocalizationsDelegate
<
dynamic
>>[
DefaultWidgetsLocalizations
.
delegate
,
DefaultMaterialLocalizations
.
delegate
,
],
child:
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
MediaQuery
(
data:
const
MediaQueryData
(),
child:
CustomScrollView
(
controller:
controller
,
slivers:
const
<
Widget
>[
SliverAppBar
(
floating:
true
,
pinned:
true
,
expandedHeight:
200.0
,
title:
Text
(
'A'
)),
SliverAppBar
(
primary:
false
,
pinned:
true
,
title:
Text
(
'B'
)),
SliverList
(
delegate:
SliverChildListDelegate
(
<
Widget
>[
Text
(
'C'
),
Text
(
'D'
),
SizedBox
(
height:
500.0
),
Text
(
'E'
),
SizedBox
(
height:
500.0
),
],
),
),
)
,
]
,
]
,
)
,
),
),
),
...
...
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