mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
Add debug check for localization parent (#20787)
This commit is contained in:
parent
199422cd2d
commit
9bf8502fef
@ -109,6 +109,7 @@ class AboutListTile extends StatelessWidget {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
assert(debugCheckHasMaterial(context));
|
assert(debugCheckHasMaterial(context));
|
||||||
|
assert(debugCheckHasMaterialLocalizations(context));
|
||||||
return ListTile(
|
return ListTile(
|
||||||
leading: icon,
|
leading: icon,
|
||||||
title: child ??
|
title: child ??
|
||||||
@ -263,6 +264,7 @@ class AboutDialog extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
assert(debugCheckHasMaterialLocalizations(context));
|
||||||
final String name = applicationName ?? _defaultApplicationName(context);
|
final String name = applicationName ?? _defaultApplicationName(context);
|
||||||
final String version = applicationVersion ?? _defaultApplicationVersion(context);
|
final String version = applicationVersion ?? _defaultApplicationVersion(context);
|
||||||
final Widget icon = applicationIcon ?? _defaultApplicationIcon(context);
|
final Widget icon = applicationIcon ?? _defaultApplicationIcon(context);
|
||||||
@ -437,6 +439,7 @@ class _LicensePageState extends State<LicensePage> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
assert(debugCheckHasMaterialLocalizations(context));
|
||||||
final String name = widget.applicationName ?? _defaultApplicationName(context);
|
final String name = widget.applicationName ?? _defaultApplicationName(context);
|
||||||
final String version = widget.applicationVersion ?? _defaultApplicationVersion(context);
|
final String version = widget.applicationVersion ?? _defaultApplicationVersion(context);
|
||||||
final MaterialLocalizations localizations = MaterialLocalizations.of(context);
|
final MaterialLocalizations localizations = MaterialLocalizations.of(context);
|
||||||
|
@ -11,6 +11,7 @@ import 'package:flutter/widgets.dart';
|
|||||||
|
|
||||||
import 'back_button.dart';
|
import 'back_button.dart';
|
||||||
import 'constants.dart';
|
import 'constants.dart';
|
||||||
|
import 'debug.dart';
|
||||||
import 'flexible_space_bar.dart';
|
import 'flexible_space_bar.dart';
|
||||||
import 'icon_button.dart';
|
import 'icon_button.dart';
|
||||||
import 'icons.dart';
|
import 'icons.dart';
|
||||||
@ -332,6 +333,7 @@ class _AppBarState extends State<AppBar> {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
assert(!widget.primary || debugCheckHasMediaQuery(context));
|
assert(!widget.primary || debugCheckHasMediaQuery(context));
|
||||||
|
assert(debugCheckHasMaterialLocalizations(context));
|
||||||
final ThemeData themeData = Theme.of(context);
|
final ThemeData themeData = Theme.of(context);
|
||||||
final ScaffoldState scaffold = Scaffold.of(context, nullOk: true);
|
final ScaffoldState scaffold = Scaffold.of(context, nullOk: true);
|
||||||
final ModalRoute<dynamic> parentRoute = ModalRoute.of(context);
|
final ModalRoute<dynamic> parentRoute = ModalRoute.of(context);
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
import 'package:flutter/widgets.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
|
|
||||||
|
import 'debug.dart';
|
||||||
import 'icon_button.dart';
|
import 'icon_button.dart';
|
||||||
import 'icons.dart';
|
import 'icons.dart';
|
||||||
import 'material_localizations.dart';
|
import 'material_localizations.dart';
|
||||||
@ -81,6 +82,7 @@ class BackButton extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
assert(debugCheckHasMaterialLocalizations(context));
|
||||||
return IconButton(
|
return IconButton(
|
||||||
icon: const BackButtonIcon(),
|
icon: const BackButtonIcon(),
|
||||||
color: color,
|
color: color,
|
||||||
|
@ -10,6 +10,7 @@ import 'package:vector_math/vector_math_64.dart' show Vector3;
|
|||||||
|
|
||||||
import 'colors.dart';
|
import 'colors.dart';
|
||||||
import 'constants.dart';
|
import 'constants.dart';
|
||||||
|
import 'debug.dart';
|
||||||
import 'ink_well.dart';
|
import 'ink_well.dart';
|
||||||
import 'material.dart';
|
import 'material.dart';
|
||||||
import 'material_localizations.dart';
|
import 'material_localizations.dart';
|
||||||
@ -495,6 +496,7 @@ class _BottomNavigationBarState extends State<BottomNavigationBar> with TickerPr
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
assert(debugCheckHasDirectionality(context));
|
assert(debugCheckHasDirectionality(context));
|
||||||
|
assert(debugCheckHasMaterialLocalizations(context));
|
||||||
|
|
||||||
// Labels apply up to _bottomMargin padding. Remainder is media padding.
|
// Labels apply up to _bottomMargin padding. Remainder is media padding.
|
||||||
final double additionalBottomPadding = math.max(MediaQuery.of(context).padding.bottom - _kBottomMargin, 0.0);
|
final double additionalBottomPadding = math.max(MediaQuery.of(context).padding.bottom - _kBottomMargin, 0.0);
|
||||||
|
@ -8,6 +8,7 @@ import 'package:flutter/foundation.dart';
|
|||||||
import 'package:flutter/widgets.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
|
|
||||||
import 'colors.dart';
|
import 'colors.dart';
|
||||||
|
import 'debug.dart';
|
||||||
import 'material.dart';
|
import 'material.dart';
|
||||||
import 'material_localizations.dart';
|
import 'material_localizations.dart';
|
||||||
import 'scaffold.dart';
|
import 'scaffold.dart';
|
||||||
@ -315,6 +316,7 @@ Future<T> showModalBottomSheet<T>({
|
|||||||
}) {
|
}) {
|
||||||
assert(context != null);
|
assert(context != null);
|
||||||
assert(builder != null);
|
assert(builder != null);
|
||||||
|
assert(debugCheckHasMaterialLocalizations(context));
|
||||||
return Navigator.push(context, _ModalBottomSheetRoute<T>(
|
return Navigator.push(context, _ModalBottomSheetRoute<T>(
|
||||||
builder: builder,
|
builder: builder,
|
||||||
theme: Theme.of(context, shadowThemeOnly: true),
|
theme: Theme.of(context, shadowThemeOnly: true),
|
||||||
|
@ -1429,6 +1429,7 @@ class _RawChipState extends State<RawChip> with TickerProviderStateMixin<RawChip
|
|||||||
assert(debugCheckHasMaterial(context));
|
assert(debugCheckHasMaterial(context));
|
||||||
assert(debugCheckHasMediaQuery(context));
|
assert(debugCheckHasMediaQuery(context));
|
||||||
assert(debugCheckHasDirectionality(context));
|
assert(debugCheckHasDirectionality(context));
|
||||||
|
assert(debugCheckHasMaterialLocalizations(context));
|
||||||
|
|
||||||
final ThemeData theme = Theme.of(context);
|
final ThemeData theme = Theme.of(context);
|
||||||
final ChipThemeData chipTheme = ChipTheme.of(context);
|
final ChipThemeData chipTheme = ChipTheme.of(context);
|
||||||
|
@ -945,6 +945,7 @@ class _DatePickerDialogState extends State<_DatePickerDialog> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
assert(debugCheckHasMaterialLocalizations(context));
|
||||||
final ThemeData theme = Theme.of(context);
|
final ThemeData theme = Theme.of(context);
|
||||||
final Widget picker = Flexible(
|
final Widget picker = Flexible(
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
import 'package:flutter/widgets.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
|
|
||||||
import 'material.dart';
|
import 'material.dart';
|
||||||
|
import 'material_localizations.dart';
|
||||||
|
|
||||||
/// Asserts that the given context has a [Material] ancestor.
|
/// Asserts that the given context has a [Material] ancestor.
|
||||||
///
|
///
|
||||||
@ -66,3 +67,63 @@ bool debugCheckHasMaterial(BuildContext context) {
|
|||||||
}());
|
}());
|
||||||
return true;
|
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;
|
||||||
|
}
|
||||||
|
@ -11,6 +11,7 @@ import 'package:flutter/widgets.dart';
|
|||||||
import 'button_bar.dart';
|
import 'button_bar.dart';
|
||||||
import 'button_theme.dart';
|
import 'button_theme.dart';
|
||||||
import 'colors.dart';
|
import 'colors.dart';
|
||||||
|
import 'debug.dart';
|
||||||
import 'ink_well.dart';
|
import 'ink_well.dart';
|
||||||
import 'material.dart';
|
import 'material.dart';
|
||||||
import 'material_localizations.dart';
|
import 'material_localizations.dart';
|
||||||
@ -232,6 +233,7 @@ class AlertDialog extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
assert(debugCheckHasMaterialLocalizations(context));
|
||||||
final List<Widget> children = <Widget>[];
|
final List<Widget> children = <Widget>[];
|
||||||
String label = semanticLabel;
|
String label = semanticLabel;
|
||||||
|
|
||||||
@ -490,6 +492,7 @@ class SimpleDialog extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
assert(debugCheckHasMaterialLocalizations(context));
|
||||||
final List<Widget> body = <Widget>[];
|
final List<Widget> body = <Widget>[];
|
||||||
String label = semanticLabel;
|
String label = semanticLabel;
|
||||||
|
|
||||||
@ -596,6 +599,7 @@ Future<T> showDialog<T>({
|
|||||||
WidgetBuilder builder,
|
WidgetBuilder builder,
|
||||||
}) {
|
}) {
|
||||||
assert(child == null || builder == null);
|
assert(child == null || builder == null);
|
||||||
|
assert(debugCheckHasMaterialLocalizations(context));
|
||||||
return showGeneralDialog(
|
return showGeneralDialog(
|
||||||
context: context,
|
context: context,
|
||||||
pageBuilder: (BuildContext buildContext, Animation<double> animation, Animation<double> secondaryAnimation) {
|
pageBuilder: (BuildContext buildContext, Animation<double> animation, Animation<double> secondaryAnimation) {
|
||||||
|
@ -6,6 +6,7 @@ import 'package:flutter/foundation.dart';
|
|||||||
import 'package:flutter/widgets.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
|
|
||||||
import 'colors.dart';
|
import 'colors.dart';
|
||||||
|
import 'debug.dart';
|
||||||
import 'list_tile.dart';
|
import 'list_tile.dart';
|
||||||
import 'material.dart';
|
import 'material.dart';
|
||||||
import 'material_localizations.dart';
|
import 'material_localizations.dart';
|
||||||
@ -116,6 +117,7 @@ class Drawer extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
assert(debugCheckHasMaterialLocalizations(context));
|
||||||
String label = semanticLabel;
|
String label = semanticLabel;
|
||||||
switch (defaultTargetPlatform) {
|
switch (defaultTargetPlatform) {
|
||||||
case TargetPlatform.iOS:
|
case TargetPlatform.iOS:
|
||||||
@ -431,6 +433,7 @@ class DrawerControllerState extends State<DrawerController> with SingleTickerPro
|
|||||||
}
|
}
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
assert(debugCheckHasMaterialLocalizations(context));
|
||||||
return ListTileTheme(
|
return ListTileTheme(
|
||||||
style: ListTileStyle.drawer,
|
style: ListTileStyle.drawer,
|
||||||
child: _buildDrawer(context),
|
child: _buildDrawer(context),
|
||||||
|
@ -139,6 +139,7 @@ class _DropdownMenuState<T> extends State<_DropdownMenu<T>> {
|
|||||||
//
|
//
|
||||||
// When the menu is dismissed we just fade the entire thing out
|
// When the menu is dismissed we just fade the entire thing out
|
||||||
// in the first 0.25s.
|
// in the first 0.25s.
|
||||||
|
assert(debugCheckHasMaterialLocalizations(context));
|
||||||
final MaterialLocalizations localizations = MaterialLocalizations.of(context);
|
final MaterialLocalizations localizations = MaterialLocalizations.of(context);
|
||||||
final _DropdownRoute<T> route = widget.route;
|
final _DropdownRoute<T> route = widget.route;
|
||||||
final double unit = 0.5 / (route.items.length + 1.5);
|
final double unit = 0.5 / (route.items.length + 1.5);
|
||||||
@ -631,6 +632,7 @@ class _DropdownButtonState<T> extends State<DropdownButton<T>> with WidgetsBindi
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
assert(debugCheckHasMaterial(context));
|
assert(debugCheckHasMaterial(context));
|
||||||
|
assert(debugCheckHasMaterialLocalizations(context));
|
||||||
|
|
||||||
// The width of the button and the menu are defined by the widest
|
// The width of the button and the menu are defined by the widest
|
||||||
// item and the width of the hint.
|
// item and the width of the hint.
|
||||||
|
@ -109,6 +109,7 @@ class _ExpandIconState extends State<ExpandIcon> with SingleTickerProviderStateM
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
assert(debugCheckHasMaterial(context));
|
assert(debugCheckHasMaterial(context));
|
||||||
|
assert(debugCheckHasMaterialLocalizations(context));
|
||||||
final MaterialLocalizations localizations = MaterialLocalizations.of(context);
|
final MaterialLocalizations localizations = MaterialLocalizations.of(context);
|
||||||
final ThemeData theme = Theme.of(context);
|
final ThemeData theme = Theme.of(context);
|
||||||
final String onTapHint = widget.isExpanded ? localizations.expandedIconTapHint : localizations.collapsedIconTapHint;
|
final String onTapHint = widget.isExpanded ? localizations.expandedIconTapHint : localizations.collapsedIconTapHint;
|
||||||
|
@ -12,6 +12,7 @@ import 'button_theme.dart';
|
|||||||
import 'card.dart';
|
import 'card.dart';
|
||||||
import 'data_table.dart';
|
import 'data_table.dart';
|
||||||
import 'data_table_source.dart';
|
import 'data_table_source.dart';
|
||||||
|
import 'debug.dart';
|
||||||
import 'dropdown.dart';
|
import 'dropdown.dart';
|
||||||
import 'icon_button.dart';
|
import 'icon_button.dart';
|
||||||
import 'icons.dart';
|
import 'icons.dart';
|
||||||
@ -286,6 +287,7 @@ class PaginatedDataTableState extends State<PaginatedDataTable> {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
// TODO(ianh): This whole build function doesn't handle RTL yet.
|
// TODO(ianh): This whole build function doesn't handle RTL yet.
|
||||||
|
assert(debugCheckHasMaterialLocalizations(context));
|
||||||
final ThemeData themeData = Theme.of(context);
|
final ThemeData themeData = Theme.of(context);
|
||||||
final MaterialLocalizations localizations = MaterialLocalizations.of(context);
|
final MaterialLocalizations localizations = MaterialLocalizations.of(context);
|
||||||
// HEADER
|
// HEADER
|
||||||
|
@ -8,6 +8,7 @@ import 'package:flutter/foundation.dart';
|
|||||||
import 'package:flutter/widgets.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
|
|
||||||
import 'constants.dart';
|
import 'constants.dart';
|
||||||
|
import 'debug.dart';
|
||||||
import 'divider.dart';
|
import 'divider.dart';
|
||||||
import 'icon_button.dart';
|
import 'icon_button.dart';
|
||||||
import 'icons.dart';
|
import 'icons.dart';
|
||||||
@ -713,6 +714,7 @@ Future<T> showMenu<T>({
|
|||||||
}) {
|
}) {
|
||||||
assert(context != null);
|
assert(context != null);
|
||||||
assert(items != null && items.isNotEmpty);
|
assert(items != null && items.isNotEmpty);
|
||||||
|
assert(debugCheckHasMaterialLocalizations(context));
|
||||||
String label = semanticLabel;
|
String label = semanticLabel;
|
||||||
switch (defaultTargetPlatform) {
|
switch (defaultTargetPlatform) {
|
||||||
case TargetPlatform.iOS:
|
case TargetPlatform.iOS:
|
||||||
@ -911,6 +913,7 @@ class _PopupMenuButtonState<T> extends State<PopupMenuButton<T>> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
assert(debugCheckHasMaterialLocalizations(context));
|
||||||
return widget.child != null
|
return widget.child != null
|
||||||
? InkWell(
|
? InkWell(
|
||||||
onTap: showButtonMenu,
|
onTap: showButtonMenu,
|
||||||
|
@ -7,6 +7,7 @@ import 'dart:math';
|
|||||||
import 'package:flutter/widgets.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
import 'package:flutter/rendering.dart';
|
import 'package:flutter/rendering.dart';
|
||||||
|
|
||||||
|
import 'debug.dart';
|
||||||
import 'material.dart';
|
import 'material.dart';
|
||||||
import 'material_localizations.dart';
|
import 'material_localizations.dart';
|
||||||
|
|
||||||
@ -510,6 +511,7 @@ class _ReorderableListContentState extends State<_ReorderableListContent> with T
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
assert(debugCheckHasMaterialLocalizations(context));
|
||||||
// We use the layout builder to constrain the cross-axis size of dragging child widgets.
|
// We use the layout builder to constrain the cross-axis size of dragging child widgets.
|
||||||
return LayoutBuilder(builder: (BuildContext context, BoxConstraints constraints) {
|
return LayoutBuilder(builder: (BuildContext context, BoxConstraints constraints) {
|
||||||
final List<Widget> wrappedChildren = <Widget>[];
|
final List<Widget> wrappedChildren = <Widget>[];
|
||||||
|
@ -9,6 +9,7 @@ import 'package:flutter/widgets.dart';
|
|||||||
|
|
||||||
import 'app_bar.dart';
|
import 'app_bar.dart';
|
||||||
import 'colors.dart';
|
import 'colors.dart';
|
||||||
|
import 'debug.dart';
|
||||||
import 'input_border.dart';
|
import 'input_border.dart';
|
||||||
import 'input_decorator.dart';
|
import 'input_decorator.dart';
|
||||||
import 'material_localizations.dart';
|
import 'material_localizations.dart';
|
||||||
@ -389,6 +390,7 @@ class _SearchPageState<T> extends State<_SearchPage<T>> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
assert(debugCheckHasMaterialLocalizations(context));
|
||||||
final ThemeData theme = widget.delegate.appBarTheme(context);
|
final ThemeData theme = widget.delegate.appBarTheme(context);
|
||||||
final String searchFieldLabel = MaterialLocalizations.of(context).searchFieldLabel;
|
final String searchFieldLabel = MaterialLocalizations.of(context).searchFieldLabel;
|
||||||
Widget body;
|
Widget body;
|
||||||
|
@ -540,6 +540,8 @@ class _TextFieldState extends State<TextField> with AutomaticKeepAliveClientMixi
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
super.build(context); // See AutomaticKeepAliveClientMixin.
|
super.build(context); // See AutomaticKeepAliveClientMixin.
|
||||||
assert(debugCheckHasMaterial(context));
|
assert(debugCheckHasMaterial(context));
|
||||||
|
// TODO(jonahwilliams): uncomment out this check once we have migrated tests.
|
||||||
|
// assert(debugCheckHasMaterialLocalizations(context));
|
||||||
assert(debugCheckHasDirectionality(context));
|
assert(debugCheckHasDirectionality(context));
|
||||||
final ThemeData themeData = Theme.of(context);
|
final ThemeData themeData = Theme.of(context);
|
||||||
final TextStyle style = widget.style ?? themeData.textTheme.subhead;
|
final TextStyle style = widget.style ?? themeData.textTheme.subhead;
|
||||||
|
@ -79,6 +79,7 @@ class _AccountDetails extends StatelessWidget {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
assert(debugCheckHasDirectionality(context));
|
assert(debugCheckHasDirectionality(context));
|
||||||
|
assert(debugCheckHasMaterialLocalizations(context));
|
||||||
|
|
||||||
final ThemeData theme = Theme.of(context);
|
final ThemeData theme = Theme.of(context);
|
||||||
final List<Widget> children = <Widget>[];
|
final List<Widget> children = <Widget>[];
|
||||||
@ -308,6 +309,7 @@ class _UserAccountsDrawerHeaderState extends State<UserAccountsDrawerHeader> {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
assert(debugCheckHasMaterial(context));
|
assert(debugCheckHasMaterial(context));
|
||||||
|
assert(debugCheckHasMaterialLocalizations(context));
|
||||||
return Semantics(
|
return Semantics(
|
||||||
container: true,
|
container: true,
|
||||||
label: MaterialLocalizations.of(context).signedInLabel,
|
label: MaterialLocalizations.of(context).signedInLabel,
|
||||||
|
@ -845,7 +845,13 @@ void main() {
|
|||||||
const MediaQueryData topPadding100 = MediaQueryData(padding: EdgeInsets.only(top: 100.0));
|
const MediaQueryData topPadding100 = MediaQueryData(padding: EdgeInsets.only(top: 100.0));
|
||||||
|
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
Directionality(
|
Localizations(
|
||||||
|
locale: const Locale('en', 'US'),
|
||||||
|
delegates: const <LocalizationsDelegate<dynamic>>[
|
||||||
|
DefaultMaterialLocalizations.delegate,
|
||||||
|
DefaultWidgetsLocalizations.delegate,
|
||||||
|
],
|
||||||
|
child: Directionality(
|
||||||
textDirection: TextDirection.ltr,
|
textDirection: TextDirection.ltr,
|
||||||
child: MediaQuery(
|
child: MediaQuery(
|
||||||
data: topPadding100,
|
data: topPadding100,
|
||||||
@ -855,48 +861,66 @@ void main() {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
));
|
||||||
expect(appBarTop(tester), 0.0);
|
expect(appBarTop(tester), 0.0);
|
||||||
expect(appBarHeight(tester), kToolbarHeight);
|
expect(appBarHeight(tester), kToolbarHeight);
|
||||||
|
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
Directionality(
|
Localizations(
|
||||||
textDirection: TextDirection.ltr,
|
locale: const Locale('en', 'US'),
|
||||||
child: MediaQuery(
|
delegates: const <LocalizationsDelegate<dynamic>>[
|
||||||
data: topPadding100,
|
DefaultMaterialLocalizations.delegate,
|
||||||
child: Scaffold(
|
DefaultWidgetsLocalizations.delegate,
|
||||||
primary: true,
|
],
|
||||||
appBar: AppBar(title: const Text('title'))
|
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(appBarTop(tester), 0.0);
|
||||||
expect(tester.getTopLeft(find.text('title')).dy, greaterThan(100.0));
|
expect(tester.getTopLeft(find.text('title')).dy, greaterThan(100.0));
|
||||||
expect(appBarHeight(tester), kToolbarHeight + 100.0);
|
expect(appBarHeight(tester), kToolbarHeight + 100.0);
|
||||||
|
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
Directionality(
|
Localizations(
|
||||||
textDirection: TextDirection.ltr,
|
locale: const Locale('en', 'US'),
|
||||||
child: MediaQuery(
|
delegates: const <LocalizationsDelegate<dynamic>>[
|
||||||
data: topPadding100,
|
DefaultMaterialLocalizations.delegate,
|
||||||
child: Scaffold(
|
DefaultWidgetsLocalizations.delegate,
|
||||||
primary: false,
|
],
|
||||||
appBar: AppBar(
|
child: Directionality(
|
||||||
bottom: PreferredSize(
|
textDirection: TextDirection.ltr,
|
||||||
preferredSize: const Size.fromHeight(200.0),
|
child: MediaQuery(
|
||||||
child: Container(),
|
data: topPadding100,
|
||||||
|
child: Scaffold(
|
||||||
|
primary: false,
|
||||||
|
appBar: AppBar(
|
||||||
|
bottom: PreferredSize(
|
||||||
|
preferredSize: const Size.fromHeight(200.0),
|
||||||
|
child: Container(),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
));
|
||||||
expect(appBarTop(tester), 0.0);
|
expect(appBarTop(tester), 0.0);
|
||||||
expect(appBarHeight(tester), kToolbarHeight + 200.0);
|
expect(appBarHeight(tester), kToolbarHeight + 200.0);
|
||||||
|
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
Directionality(
|
Localizations(
|
||||||
|
locale: const Locale('en', 'US'),
|
||||||
|
delegates: const <LocalizationsDelegate<dynamic>>[
|
||||||
|
DefaultMaterialLocalizations.delegate,
|
||||||
|
DefaultWidgetsLocalizations.delegate,
|
||||||
|
],
|
||||||
|
child: Directionality(
|
||||||
textDirection: TextDirection.ltr,
|
textDirection: TextDirection.ltr,
|
||||||
child: MediaQuery(
|
child: MediaQuery(
|
||||||
data: topPadding100,
|
data: topPadding100,
|
||||||
@ -911,18 +935,25 @@ void main() {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
));
|
||||||
expect(appBarTop(tester), 0.0);
|
expect(appBarTop(tester), 0.0);
|
||||||
expect(appBarHeight(tester), kToolbarHeight + 100.0 + 200.0);
|
expect(appBarHeight(tester), kToolbarHeight + 100.0 + 200.0);
|
||||||
|
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
Directionality(
|
Localizations(
|
||||||
textDirection: TextDirection.ltr,
|
locale: const Locale('en', 'US'),
|
||||||
child: MediaQuery(
|
delegates: const <LocalizationsDelegate<dynamic>>[
|
||||||
data: topPadding100,
|
DefaultMaterialLocalizations.delegate,
|
||||||
child: AppBar(
|
DefaultWidgetsLocalizations.delegate,
|
||||||
primary: false,
|
],
|
||||||
title: const Text('title'),
|
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();
|
final Key trailingKey = UniqueKey();
|
||||||
|
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
Directionality(
|
Localizations(
|
||||||
|
locale: const Locale('en', 'US'),
|
||||||
|
delegates: const <LocalizationsDelegate<dynamic>>[
|
||||||
|
DefaultMaterialLocalizations.delegate,
|
||||||
|
DefaultWidgetsLocalizations.delegate,
|
||||||
|
],
|
||||||
|
child: Directionality(
|
||||||
textDirection: TextDirection.rtl,
|
textDirection: TextDirection.rtl,
|
||||||
child: MediaQuery(
|
child: MediaQuery(
|
||||||
data: topPadding100,
|
data: topPadding100,
|
||||||
@ -1109,7 +1146,7 @@ void main() {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
));
|
||||||
expect(tester.getTopLeft(find.byType(AppBar)), const Offset(0.0, 0.0));
|
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(leadingKey)), const Offset(800.0 - 56.0, 100.0));
|
||||||
expect(tester.getTopLeft(find.byKey(titleKey)), const Offset(416.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();
|
final Key trailingKey = UniqueKey();
|
||||||
|
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
Directionality(
|
Localizations(
|
||||||
|
locale: const Locale('en', 'US'),
|
||||||
|
delegates: const <LocalizationsDelegate<dynamic>>[
|
||||||
|
DefaultMaterialLocalizations.delegate,
|
||||||
|
DefaultWidgetsLocalizations.delegate,
|
||||||
|
],
|
||||||
|
child: Directionality(
|
||||||
textDirection: TextDirection.rtl,
|
textDirection: TextDirection.rtl,
|
||||||
child: MediaQuery(
|
child: MediaQuery(
|
||||||
data: topPadding100,
|
data: topPadding100,
|
||||||
@ -1140,7 +1183,7 @@ void main() {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
));
|
||||||
expect(tester.getTopLeft(find.byType(AppBar)), const Offset(0.0, 0.0));
|
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(leadingKey)), const Offset(800.0 - 56.0, 100.0));
|
||||||
expect(tester.getTopLeft(find.byKey(titleKey)), const Offset(416.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();
|
final Key trailingKey = UniqueKey();
|
||||||
|
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
Directionality(
|
Localizations(
|
||||||
|
locale: const Locale('en', 'US'),
|
||||||
|
delegates: const <LocalizationsDelegate<dynamic>>[
|
||||||
|
DefaultMaterialLocalizations.delegate,
|
||||||
|
DefaultWidgetsLocalizations.delegate,
|
||||||
|
],
|
||||||
|
child: Directionality(
|
||||||
textDirection: TextDirection.rtl,
|
textDirection: TextDirection.rtl,
|
||||||
child: MediaQuery(
|
child: MediaQuery(
|
||||||
data: topPadding100,
|
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.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(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));
|
expect(tester.getRect(find.byKey(trailingKey)), Rect.fromLTRB(0.0, 100.0, 400.0, 100.0 + 56.0));
|
||||||
|
@ -64,7 +64,9 @@ void main() {
|
|||||||
bool value;
|
bool value;
|
||||||
|
|
||||||
Widget buildChip(ChipThemeData data) {
|
Widget buildChip(ChipThemeData data) {
|
||||||
return Directionality(
|
return MaterialApp(
|
||||||
|
locale: const Locale('en', 'us'),
|
||||||
|
home: Directionality(
|
||||||
textDirection: TextDirection.ltr,
|
textDirection: TextDirection.ltr,
|
||||||
child: MediaQuery(
|
child: MediaQuery(
|
||||||
data: MediaQueryData.fromWindow(window),
|
data: MediaQueryData.fromWindow(window),
|
||||||
@ -88,7 +90,7 @@ void main() {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
await tester.pumpWidget(buildChip(chipTheme));
|
await tester.pumpWidget(buildChip(chipTheme));
|
||||||
@ -111,7 +113,8 @@ void main() {
|
|||||||
);
|
);
|
||||||
const bool value = false;
|
const bool value = false;
|
||||||
Widget buildChip(ChipThemeData data) {
|
Widget buildChip(ChipThemeData data) {
|
||||||
return Directionality(
|
return MaterialApp(
|
||||||
|
home: Directionality(
|
||||||
textDirection: TextDirection.ltr,
|
textDirection: TextDirection.ltr,
|
||||||
child: MediaQuery(
|
child: MediaQuery(
|
||||||
data: MediaQueryData.fromWindow(window),
|
data: MediaQueryData.fromWindow(window),
|
||||||
@ -138,7 +141,7 @@ void main() {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
await tester.pumpWidget(buildChip(chipTheme));
|
await tester.pumpWidget(buildChip(chipTheme));
|
||||||
|
@ -243,7 +243,13 @@ Widget buildFrame({
|
|||||||
EdgeInsets viewInsets = const EdgeInsets.only(bottom: 200.0),
|
EdgeInsets viewInsets = const EdgeInsets.only(bottom: 200.0),
|
||||||
Widget bab,
|
Widget bab,
|
||||||
}) {
|
}) {
|
||||||
return Directionality(
|
return Localizations(
|
||||||
|
locale: const Locale('en', 'us'),
|
||||||
|
delegates: const <LocalizationsDelegate<dynamic>>[
|
||||||
|
DefaultWidgetsLocalizations.delegate,
|
||||||
|
DefaultMaterialLocalizations.delegate,
|
||||||
|
],
|
||||||
|
child: Directionality(
|
||||||
textDirection: textDirection,
|
textDirection: textDirection,
|
||||||
child: MediaQuery(
|
child: MediaQuery(
|
||||||
data: MediaQueryData(viewInsets: viewInsets),
|
data: MediaQueryData(viewInsets: viewInsets),
|
||||||
@ -255,7 +261,7 @@ Widget buildFrame({
|
|||||||
body: listener,
|
body: listener,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
class _StartTopFloatingActionButtonLocation extends FloatingActionButtonLocation {
|
class _StartTopFloatingActionButtonLocation extends FloatingActionButtonLocation {
|
||||||
|
@ -12,9 +12,20 @@ import '../widgets/semantics_tester.dart';
|
|||||||
void main() {
|
void main() {
|
||||||
testWidgets('Scaffold control test', (WidgetTester tester) async {
|
testWidgets('Scaffold control test', (WidgetTester tester) async {
|
||||||
final Key bodyKey = UniqueKey();
|
final Key bodyKey = UniqueKey();
|
||||||
await tester.pumpWidget(Directionality(
|
Widget boilerplate(Widget child) {
|
||||||
textDirection: TextDirection.ltr,
|
return Localizations(
|
||||||
child: Scaffold(
|
locale: const Locale('en', 'us'),
|
||||||
|
delegates: const <LocalizationsDelegate<dynamic>>[
|
||||||
|
DefaultWidgetsLocalizations.delegate,
|
||||||
|
DefaultMaterialLocalizations.delegate,
|
||||||
|
],
|
||||||
|
child: Directionality(
|
||||||
|
textDirection: TextDirection.ltr,
|
||||||
|
child: child,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
await tester.pumpWidget(boilerplate(Scaffold(
|
||||||
appBar: AppBar(title: const Text('Title')),
|
appBar: AppBar(title: const Text('Title')),
|
||||||
body: Container(key: bodyKey),
|
body: Container(key: bodyKey),
|
||||||
),
|
),
|
||||||
@ -30,9 +41,7 @@ void main() {
|
|||||||
RenderBox bodyBox = tester.renderObject(find.byKey(bodyKey));
|
RenderBox bodyBox = tester.renderObject(find.byKey(bodyKey));
|
||||||
expect(bodyBox.size, equals(const Size(800.0, 544.0)));
|
expect(bodyBox.size, equals(const Size(800.0, 544.0)));
|
||||||
|
|
||||||
await tester.pumpWidget(Directionality(
|
await tester.pumpWidget(boilerplate(MediaQuery(
|
||||||
textDirection: TextDirection.ltr,
|
|
||||||
child: MediaQuery(
|
|
||||||
data: const MediaQueryData(viewInsets: EdgeInsets.only(bottom: 100.0)),
|
data: const MediaQueryData(viewInsets: EdgeInsets.only(bottom: 100.0)),
|
||||||
child: Scaffold(
|
child: Scaffold(
|
||||||
appBar: AppBar(title: const Text('Title')),
|
appBar: AppBar(title: const Text('Title')),
|
||||||
@ -44,17 +53,14 @@ void main() {
|
|||||||
bodyBox = tester.renderObject(find.byKey(bodyKey));
|
bodyBox = tester.renderObject(find.byKey(bodyKey));
|
||||||
expect(bodyBox.size, equals(const Size(800.0, 444.0)));
|
expect(bodyBox.size, equals(const Size(800.0, 444.0)));
|
||||||
|
|
||||||
await tester.pumpWidget(Directionality(
|
await tester.pumpWidget(boilerplate(MediaQuery(
|
||||||
textDirection: TextDirection.ltr,
|
data: const MediaQueryData(viewInsets: EdgeInsets.only(bottom: 100.0)),
|
||||||
child: MediaQuery(
|
child: Scaffold(
|
||||||
data: const MediaQueryData(viewInsets: EdgeInsets.only(bottom: 100.0)),
|
appBar: AppBar(title: const Text('Title')),
|
||||||
child: Scaffold(
|
body: Container(key: bodyKey),
|
||||||
appBar: AppBar(title: const Text('Title')),
|
resizeToAvoidBottomPadding: false,
|
||||||
body: Container(key: bodyKey),
|
|
||||||
resizeToAvoidBottomPadding: false,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
));
|
)));
|
||||||
|
|
||||||
bodyBox = tester.renderObject(find.byKey(bodyKey));
|
bodyBox = tester.renderObject(find.byKey(bodyKey));
|
||||||
expect(bodyBox.size, equals(const Size(800.0, 544.0)));
|
expect(bodyBox.size, equals(const Size(800.0, 544.0)));
|
||||||
@ -62,24 +68,34 @@ void main() {
|
|||||||
|
|
||||||
testWidgets('Scaffold large bottom padding test', (WidgetTester tester) async {
|
testWidgets('Scaffold large bottom padding test', (WidgetTester tester) async {
|
||||||
final Key bodyKey = UniqueKey();
|
final Key bodyKey = UniqueKey();
|
||||||
await tester.pumpWidget(Directionality(
|
|
||||||
textDirection: TextDirection.ltr,
|
Widget boilerplate(Widget child) {
|
||||||
child: MediaQuery(
|
return Localizations(
|
||||||
data: const MediaQueryData(
|
locale: const Locale('en', 'us'),
|
||||||
viewInsets: EdgeInsets.only(bottom: 700.0),
|
delegates: const <LocalizationsDelegate<dynamic>>[
|
||||||
),
|
DefaultWidgetsLocalizations.delegate,
|
||||||
child: Scaffold(
|
DefaultMaterialLocalizations.delegate,
|
||||||
body: Container(key: bodyKey),
|
],
|
||||||
|
child: Directionality(
|
||||||
|
textDirection: TextDirection.ltr,
|
||||||
|
child: child,
|
||||||
),
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
await tester.pumpWidget(boilerplate(MediaQuery(
|
||||||
|
data: const MediaQueryData(
|
||||||
|
viewInsets: EdgeInsets.only(bottom: 700.0),
|
||||||
),
|
),
|
||||||
|
child: Scaffold(
|
||||||
|
body: Container(key: bodyKey),
|
||||||
|
))
|
||||||
));
|
));
|
||||||
|
|
||||||
final RenderBox bodyBox = tester.renderObject(find.byKey(bodyKey));
|
final RenderBox bodyBox = tester.renderObject(find.byKey(bodyKey));
|
||||||
expect(bodyBox.size, equals(const Size(800.0, 0.0)));
|
expect(bodyBox.size, equals(const Size(800.0, 0.0)));
|
||||||
|
|
||||||
await tester.pumpWidget(Directionality(
|
await tester.pumpWidget(boilerplate(MediaQuery(
|
||||||
textDirection: TextDirection.ltr,
|
|
||||||
child: MediaQuery(
|
|
||||||
data: const MediaQueryData(
|
data: const MediaQueryData(
|
||||||
viewInsets: EdgeInsets.only(bottom: 500.0),
|
viewInsets: EdgeInsets.only(bottom: 500.0),
|
||||||
),
|
),
|
||||||
@ -91,9 +107,7 @@ void main() {
|
|||||||
|
|
||||||
expect(bodyBox.size, equals(const Size(800.0, 100.0)));
|
expect(bodyBox.size, equals(const Size(800.0, 100.0)));
|
||||||
|
|
||||||
await tester.pumpWidget(Directionality(
|
await tester.pumpWidget(boilerplate(MediaQuery(
|
||||||
textDirection: TextDirection.ltr,
|
|
||||||
child: MediaQuery(
|
|
||||||
data: const MediaQueryData(
|
data: const MediaQueryData(
|
||||||
viewInsets: EdgeInsets.only(bottom: 580.0),
|
viewInsets: EdgeInsets.only(bottom: 580.0),
|
||||||
),
|
),
|
||||||
@ -597,64 +611,71 @@ void main() {
|
|||||||
final Key insideDrawer = UniqueKey();
|
final Key insideDrawer = UniqueKey();
|
||||||
final Key insideBottomNavigationBar = UniqueKey();
|
final Key insideBottomNavigationBar = UniqueKey();
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
Directionality(
|
Localizations(
|
||||||
textDirection: TextDirection.rtl,
|
locale: const Locale('en', 'us'),
|
||||||
child: MediaQuery(
|
delegates: const <LocalizationsDelegate<dynamic>>[
|
||||||
data: const MediaQueryData(
|
DefaultWidgetsLocalizations.delegate,
|
||||||
padding: EdgeInsets.only(
|
DefaultMaterialLocalizations.delegate,
|
||||||
left: 20.0,
|
],
|
||||||
top: 30.0,
|
child: Directionality(
|
||||||
right: 50.0,
|
textDirection: TextDirection.rtl,
|
||||||
bottom: 60.0,
|
child: MediaQuery(
|
||||||
|
data: const MediaQueryData(
|
||||||
|
padding: EdgeInsets.only(
|
||||||
|
left: 20.0,
|
||||||
|
top: 30.0,
|
||||||
|
right: 50.0,
|
||||||
|
bottom: 60.0,
|
||||||
|
),
|
||||||
|
viewInsets: EdgeInsets.only(bottom: 200.0),
|
||||||
),
|
),
|
||||||
viewInsets: EdgeInsets.only(bottom: 200.0),
|
child: Scaffold(
|
||||||
),
|
appBar: PreferredSize(
|
||||||
child: Scaffold(
|
preferredSize: const Size(11.0, 13.0),
|
||||||
appBar: PreferredSize(
|
child: Container(
|
||||||
preferredSize: const Size(11.0, 13.0),
|
key: appBar,
|
||||||
child: Container(
|
child: SafeArea(
|
||||||
key: appBar,
|
child: Placeholder(key: insideAppBar),
|
||||||
child: SafeArea(
|
),
|
||||||
child: Placeholder(key: insideAppBar),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
body: Container(
|
||||||
body: Container(
|
key: body,
|
||||||
key: body,
|
|
||||||
child: SafeArea(
|
|
||||||
child: Placeholder(key: insideBody),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
floatingActionButton: SizedBox(
|
|
||||||
key: floatingActionButton,
|
|
||||||
width: 77.0,
|
|
||||||
height: 77.0,
|
|
||||||
child: SafeArea(
|
|
||||||
child: Placeholder(key: insideFloatingActionButton),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
persistentFooterButtons: <Widget>[
|
|
||||||
SizedBox(
|
|
||||||
key: persistentFooterButton,
|
|
||||||
width: 100.0,
|
|
||||||
height: 90.0,
|
|
||||||
child: SafeArea(
|
child: SafeArea(
|
||||||
child: Placeholder(key: insidePersistentFooterButton),
|
child: Placeholder(key: insideBody),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
floatingActionButton: SizedBox(
|
||||||
drawer: Container(
|
key: floatingActionButton,
|
||||||
key: drawer,
|
width: 77.0,
|
||||||
width: 204.0,
|
height: 77.0,
|
||||||
child: SafeArea(
|
child: SafeArea(
|
||||||
child: Placeholder(key: insideDrawer),
|
child: Placeholder(key: insideFloatingActionButton),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
persistentFooterButtons: <Widget>[
|
||||||
bottomNavigationBar: SizedBox(
|
SizedBox(
|
||||||
key: bottomNavigationBar,
|
key: persistentFooterButton,
|
||||||
height: 85.0,
|
width: 100.0,
|
||||||
child: SafeArea(
|
height: 90.0,
|
||||||
child: Placeholder(key: insideBottomNavigationBar),
|
child: SafeArea(
|
||||||
|
child: Placeholder(key: insidePersistentFooterButton),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
drawer: Container(
|
||||||
|
key: drawer,
|
||||||
|
width: 204.0,
|
||||||
|
child: SafeArea(
|
||||||
|
child: Placeholder(key: insideDrawer),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
bottomNavigationBar: SizedBox(
|
||||||
|
key: bottomNavigationBar,
|
||||||
|
height: 85.0,
|
||||||
|
child: SafeArea(
|
||||||
|
child: Placeholder(key: insideBottomNavigationBar),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -692,57 +713,64 @@ void main() {
|
|||||||
final Key insidePersistentFooterButton = UniqueKey();
|
final Key insidePersistentFooterButton = UniqueKey();
|
||||||
final Key insideDrawer = UniqueKey();
|
final Key insideDrawer = UniqueKey();
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
Directionality(
|
Localizations(
|
||||||
textDirection: TextDirection.rtl,
|
locale: const Locale('en', 'us'),
|
||||||
child: MediaQuery(
|
delegates: const <LocalizationsDelegate<dynamic>>[
|
||||||
data: const MediaQueryData(
|
DefaultWidgetsLocalizations.delegate,
|
||||||
padding: EdgeInsets.only(
|
DefaultMaterialLocalizations.delegate,
|
||||||
left: 20.0,
|
],
|
||||||
top: 30.0,
|
child: Directionality(
|
||||||
right: 50.0,
|
textDirection: TextDirection.rtl,
|
||||||
bottom: 60.0,
|
child: MediaQuery(
|
||||||
|
data: const MediaQueryData(
|
||||||
|
padding: EdgeInsets.only(
|
||||||
|
left: 20.0,
|
||||||
|
top: 30.0,
|
||||||
|
right: 50.0,
|
||||||
|
bottom: 60.0,
|
||||||
|
),
|
||||||
|
viewInsets: EdgeInsets.only(bottom: 200.0),
|
||||||
),
|
),
|
||||||
viewInsets: EdgeInsets.only(bottom: 200.0),
|
child: Scaffold(
|
||||||
),
|
appBar: PreferredSize(
|
||||||
child: Scaffold(
|
preferredSize: const Size(11.0, 13.0),
|
||||||
appBar: PreferredSize(
|
child: Container(
|
||||||
preferredSize: const Size(11.0, 13.0),
|
key: appBar,
|
||||||
child: Container(
|
child: SafeArea(
|
||||||
key: appBar,
|
child: Placeholder(key: insideAppBar),
|
||||||
child: SafeArea(
|
),
|
||||||
child: Placeholder(key: insideAppBar),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
body: Container(
|
||||||
body: Container(
|
key: body,
|
||||||
key: body,
|
|
||||||
child: SafeArea(
|
|
||||||
child: Placeholder(key: insideBody),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
floatingActionButton: SizedBox(
|
|
||||||
key: floatingActionButton,
|
|
||||||
width: 77.0,
|
|
||||||
height: 77.0,
|
|
||||||
child: SafeArea(
|
|
||||||
child: Placeholder(key: insideFloatingActionButton),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
persistentFooterButtons: <Widget>[
|
|
||||||
SizedBox(
|
|
||||||
key: persistentFooterButton,
|
|
||||||
width: 100.0,
|
|
||||||
height: 90.0,
|
|
||||||
child: SafeArea(
|
child: SafeArea(
|
||||||
child: Placeholder(key: insidePersistentFooterButton),
|
child: Placeholder(key: insideBody),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
floatingActionButton: SizedBox(
|
||||||
drawer: Container(
|
key: floatingActionButton,
|
||||||
key: drawer,
|
width: 77.0,
|
||||||
width: 204.0,
|
height: 77.0,
|
||||||
child: SafeArea(
|
child: SafeArea(
|
||||||
child: Placeholder(key: insideDrawer),
|
child: Placeholder(key: insideFloatingActionButton),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
persistentFooterButtons: <Widget>[
|
||||||
|
SizedBox(
|
||||||
|
key: persistentFooterButton,
|
||||||
|
width: 100.0,
|
||||||
|
height: 90.0,
|
||||||
|
child: SafeArea(
|
||||||
|
child: Placeholder(key: insidePersistentFooterButton),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
drawer: Container(
|
||||||
|
key: drawer,
|
||||||
|
width: 204.0,
|
||||||
|
child: SafeArea(
|
||||||
|
child: Placeholder(key: insideDrawer),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -318,19 +318,26 @@ void main() {
|
|||||||
testWidgets('NestedScrollViews with custom physics', (WidgetTester tester) async {
|
testWidgets('NestedScrollViews with custom physics', (WidgetTester tester) async {
|
||||||
await tester.pumpWidget(Directionality(
|
await tester.pumpWidget(Directionality(
|
||||||
textDirection: TextDirection.ltr,
|
textDirection: TextDirection.ltr,
|
||||||
child: MediaQuery(
|
child: Localizations(
|
||||||
data: const MediaQueryData(),
|
locale: const Locale('en', 'US'),
|
||||||
child: NestedScrollView(
|
delegates: const <LocalizationsDelegate<dynamic>>[
|
||||||
physics: const _CustomPhysics(),
|
DefaultMaterialLocalizations.delegate,
|
||||||
headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) {
|
DefaultWidgetsLocalizations.delegate,
|
||||||
return <Widget>[
|
],
|
||||||
const SliverAppBar(
|
child: MediaQuery(
|
||||||
floating: true,
|
data: const MediaQueryData(),
|
||||||
title: Text('AA'),
|
child: NestedScrollView(
|
||||||
),
|
physics: const _CustomPhysics(),
|
||||||
];
|
headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) {
|
||||||
},
|
return <Widget>[
|
||||||
body: Container(),
|
const SliverAppBar(
|
||||||
|
floating: true,
|
||||||
|
title: Text('AA'),
|
||||||
|
),
|
||||||
|
];
|
||||||
|
},
|
||||||
|
body: Container(),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
));
|
));
|
||||||
|
@ -105,27 +105,34 @@ void main() {
|
|||||||
|
|
||||||
await tester.pumpWidget(Directionality(
|
await tester.pumpWidget(Directionality(
|
||||||
textDirection: TextDirection.ltr,
|
textDirection: TextDirection.ltr,
|
||||||
child: MediaQuery(
|
child: Localizations(
|
||||||
data: const MediaQueryData(),
|
locale: const Locale('en', 'us'),
|
||||||
child: Scrollable(
|
delegates: const <LocalizationsDelegate<dynamic>>[
|
||||||
controller: scrollController,
|
DefaultWidgetsLocalizations.delegate,
|
||||||
viewportBuilder: (BuildContext context, ViewportOffset offset) {
|
DefaultMaterialLocalizations.delegate,
|
||||||
return Viewport(
|
],
|
||||||
offset: offset,
|
child: MediaQuery(
|
||||||
slivers: <Widget>[
|
data: const MediaQueryData(),
|
||||||
const SliverAppBar(
|
child: Scrollable(
|
||||||
pinned: true,
|
controller: scrollController,
|
||||||
expandedHeight: kExpandedAppBarHeight,
|
viewportBuilder: (BuildContext context, ViewportOffset offset) {
|
||||||
flexibleSpace: FlexibleSpaceBar(
|
return Viewport(
|
||||||
title: Text('App Bar'),
|
offset: offset,
|
||||||
),
|
slivers: <Widget>[
|
||||||
),
|
const SliverAppBar(
|
||||||
SliverList(
|
pinned: true,
|
||||||
delegate: SliverChildListDelegate(containers),
|
expandedHeight: kExpandedAppBarHeight,
|
||||||
)
|
flexibleSpace: FlexibleSpaceBar(
|
||||||
],
|
title: Text('App Bar'),
|
||||||
);
|
),
|
||||||
}),
|
),
|
||||||
|
SliverList(
|
||||||
|
delegate: SliverChildListDelegate(containers),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
));
|
));
|
||||||
|
|
||||||
@ -169,22 +176,29 @@ void main() {
|
|||||||
textDirection: TextDirection.ltr,
|
textDirection: TextDirection.ltr,
|
||||||
child: MediaQuery(
|
child: MediaQuery(
|
||||||
data: const MediaQueryData(),
|
data: const MediaQueryData(),
|
||||||
child: Scrollable(
|
child: Localizations(
|
||||||
controller: scrollController,
|
locale: const Locale('en', 'us'),
|
||||||
viewportBuilder: (BuildContext context, ViewportOffset offset) {
|
delegates: const <LocalizationsDelegate<dynamic>>[
|
||||||
return Viewport(
|
DefaultWidgetsLocalizations.delegate,
|
||||||
offset: offset,
|
DefaultMaterialLocalizations.delegate,
|
||||||
slivers: <Widget>[
|
],
|
||||||
const SliverAppBar(
|
child: Scrollable(
|
||||||
pinned: true,
|
controller: scrollController,
|
||||||
expandedHeight: kExpandedAppBarHeight,
|
viewportBuilder: (BuildContext context, ViewportOffset offset) {
|
||||||
flexibleSpace: FlexibleSpaceBar(
|
return Viewport(
|
||||||
title: Text('App Bar'),
|
offset: offset,
|
||||||
|
slivers: <Widget>[
|
||||||
|
const SliverAppBar(
|
||||||
|
pinned: true,
|
||||||
|
expandedHeight: kExpandedAppBarHeight,
|
||||||
|
flexibleSpace: FlexibleSpaceBar(
|
||||||
|
title: Text('App Bar'),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
]..addAll(slivers),
|
||||||
]..addAll(slivers),
|
);
|
||||||
);
|
},
|
||||||
},
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
));
|
));
|
||||||
|
@ -37,22 +37,29 @@ void _tests() {
|
|||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
Semantics(
|
Semantics(
|
||||||
textDirection: TextDirection.ltr,
|
textDirection: TextDirection.ltr,
|
||||||
child: Directionality(
|
child: Localizations(
|
||||||
textDirection: TextDirection.ltr,
|
locale: const Locale('en', 'us'),
|
||||||
child: MediaQuery(
|
delegates: const <LocalizationsDelegate<dynamic>>[
|
||||||
data: const MediaQueryData(),
|
DefaultWidgetsLocalizations.delegate,
|
||||||
child: CustomScrollView(
|
DefaultMaterialLocalizations.delegate,
|
||||||
controller: scrollController,
|
],
|
||||||
slivers: <Widget>[
|
child: Directionality(
|
||||||
const SliverAppBar(
|
textDirection: TextDirection.ltr,
|
||||||
pinned: true,
|
child: MediaQuery(
|
||||||
expandedHeight: appBarExpandedHeight,
|
data: const MediaQueryData(),
|
||||||
title: Text('Semantics Test with Slivers'),
|
child: CustomScrollView(
|
||||||
),
|
controller: scrollController,
|
||||||
SliverList(
|
slivers: <Widget>[
|
||||||
delegate: SliverChildListDelegate(listChildren),
|
const SliverAppBar(
|
||||||
),
|
pinned: true,
|
||||||
],
|
expandedHeight: appBarExpandedHeight,
|
||||||
|
title: Text('Semantics Test with Slivers'),
|
||||||
|
),
|
||||||
|
SliverList(
|
||||||
|
delegate: SliverChildListDelegate(listChildren),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -289,14 +296,21 @@ void _tests() {
|
|||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
Semantics(
|
Semantics(
|
||||||
textDirection: TextDirection.ltr,
|
textDirection: TextDirection.ltr,
|
||||||
child: Directionality(
|
child: Localizations(
|
||||||
textDirection: TextDirection.ltr,
|
locale: const Locale('en', 'us'),
|
||||||
child: Center(
|
delegates: const <LocalizationsDelegate<dynamic>>[
|
||||||
child: SizedBox(
|
DefaultWidgetsLocalizations.delegate,
|
||||||
height: containerHeight,
|
DefaultMaterialLocalizations.delegate,
|
||||||
child: CustomScrollView(
|
],
|
||||||
controller: scrollController,
|
child: Directionality(
|
||||||
slivers: slivers,
|
textDirection: TextDirection.ltr,
|
||||||
|
child: Center(
|
||||||
|
child: SizedBox(
|
||||||
|
height: containerHeight,
|
||||||
|
child: CustomScrollView(
|
||||||
|
controller: scrollController,
|
||||||
|
slivers: slivers,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -366,10 +380,17 @@ void _tests() {
|
|||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
Semantics(
|
Semantics(
|
||||||
textDirection: TextDirection.ltr,
|
textDirection: TextDirection.ltr,
|
||||||
child: Directionality(
|
child: Localizations(
|
||||||
textDirection: TextDirection.ltr,
|
locale: const Locale('en', 'us'),
|
||||||
child: CustomScrollView(
|
delegates: const <LocalizationsDelegate<dynamic>>[
|
||||||
slivers: slivers,
|
DefaultWidgetsLocalizations.delegate,
|
||||||
|
DefaultMaterialLocalizations.delegate,
|
||||||
|
],
|
||||||
|
child: Directionality(
|
||||||
|
textDirection: TextDirection.ltr,
|
||||||
|
child: CustomScrollView(
|
||||||
|
slivers: slivers,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -437,22 +458,29 @@ void _tests() {
|
|||||||
final ScrollController controller = ScrollController(initialScrollOffset: 280.0);
|
final ScrollController controller = ScrollController(initialScrollOffset: 280.0);
|
||||||
await tester.pumpWidget(Semantics(
|
await tester.pumpWidget(Semantics(
|
||||||
textDirection: TextDirection.ltr,
|
textDirection: TextDirection.ltr,
|
||||||
child: Directionality(
|
child: Localizations(
|
||||||
textDirection: TextDirection.ltr,
|
locale: const Locale('en', 'us'),
|
||||||
child: MediaQuery(
|
delegates: const <LocalizationsDelegate<dynamic>>[
|
||||||
data: const MediaQueryData(),
|
DefaultWidgetsLocalizations.delegate,
|
||||||
child: CustomScrollView(
|
DefaultMaterialLocalizations.delegate,
|
||||||
slivers: <Widget>[
|
],
|
||||||
const SliverAppBar(
|
child: Directionality(
|
||||||
pinned: true,
|
textDirection: TextDirection.ltr,
|
||||||
expandedHeight: 100.0,
|
child: MediaQuery(
|
||||||
title: Text('AppBar'),
|
data: const MediaQueryData(),
|
||||||
),
|
child: CustomScrollView(
|
||||||
SliverList(
|
slivers: <Widget>[
|
||||||
delegate: SliverChildListDelegate(listChildren),
|
const SliverAppBar(
|
||||||
),
|
pinned: true,
|
||||||
],
|
expandedHeight: 100.0,
|
||||||
controller: controller,
|
title: Text('AppBar'),
|
||||||
|
),
|
||||||
|
SliverList(
|
||||||
|
delegate: SliverChildListDelegate(listChildren),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
controller: controller,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -542,19 +570,26 @@ void _tests() {
|
|||||||
});
|
});
|
||||||
await tester.pumpWidget(Semantics(
|
await tester.pumpWidget(Semantics(
|
||||||
textDirection: TextDirection.ltr,
|
textDirection: TextDirection.ltr,
|
||||||
child: Directionality(
|
child: Localizations(
|
||||||
textDirection: TextDirection.ltr,
|
locale: const Locale('en', 'us'),
|
||||||
child: MediaQuery(
|
delegates: const <LocalizationsDelegate<dynamic>>[
|
||||||
data: const MediaQueryData(),
|
DefaultWidgetsLocalizations.delegate,
|
||||||
child: CustomScrollView(
|
DefaultMaterialLocalizations.delegate,
|
||||||
controller: controller,
|
],
|
||||||
slivers: <Widget>[
|
child: Directionality(
|
||||||
const SliverAppBar(
|
textDirection: TextDirection.ltr,
|
||||||
pinned: true,
|
child: MediaQuery(
|
||||||
expandedHeight: 100.0,
|
data: const MediaQueryData(),
|
||||||
title: Text('AppBar'),
|
child: CustomScrollView(
|
||||||
),
|
controller: controller,
|
||||||
]..addAll(slivers),
|
slivers: <Widget>[
|
||||||
|
const SliverAppBar(
|
||||||
|
pinned: true,
|
||||||
|
expandedHeight: 100.0,
|
||||||
|
title: Text('AppBar'),
|
||||||
|
),
|
||||||
|
]..addAll(slivers),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -642,23 +677,30 @@ void _tests() {
|
|||||||
final ScrollController controller = ScrollController(initialScrollOffset: 280.0);
|
final ScrollController controller = ScrollController(initialScrollOffset: 280.0);
|
||||||
await tester.pumpWidget(Semantics(
|
await tester.pumpWidget(Semantics(
|
||||||
textDirection: TextDirection.ltr,
|
textDirection: TextDirection.ltr,
|
||||||
child: Directionality(
|
child: Localizations(
|
||||||
textDirection: TextDirection.ltr,
|
locale: const Locale('en', 'us'),
|
||||||
child: MediaQuery(
|
delegates: const <LocalizationsDelegate<dynamic>>[
|
||||||
data: const MediaQueryData(),
|
DefaultWidgetsLocalizations.delegate,
|
||||||
child: CustomScrollView(
|
DefaultMaterialLocalizations.delegate,
|
||||||
reverse: true, // This is the important setting for this test.
|
],
|
||||||
slivers: <Widget>[
|
child: Directionality(
|
||||||
const SliverAppBar(
|
textDirection: TextDirection.ltr,
|
||||||
pinned: true,
|
child: MediaQuery(
|
||||||
expandedHeight: 100.0,
|
data: const MediaQueryData(),
|
||||||
title: Text('AppBar'),
|
child: CustomScrollView(
|
||||||
),
|
reverse: true, // This is the important setting for this test.
|
||||||
SliverList(
|
slivers: <Widget>[
|
||||||
delegate: SliverChildListDelegate(listChildren),
|
const SliverAppBar(
|
||||||
),
|
pinned: true,
|
||||||
],
|
expandedHeight: 100.0,
|
||||||
controller: controller,
|
title: Text('AppBar'),
|
||||||
|
),
|
||||||
|
SliverList(
|
||||||
|
delegate: SliverChildListDelegate(listChildren),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
controller: controller,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -748,20 +790,27 @@ void _tests() {
|
|||||||
});
|
});
|
||||||
await tester.pumpWidget(Semantics(
|
await tester.pumpWidget(Semantics(
|
||||||
textDirection: TextDirection.ltr,
|
textDirection: TextDirection.ltr,
|
||||||
child: Directionality(
|
child: Localizations(
|
||||||
textDirection: TextDirection.ltr,
|
locale: const Locale('en', 'us'),
|
||||||
child: MediaQuery(
|
delegates: const <LocalizationsDelegate<dynamic>>[
|
||||||
data: const MediaQueryData(),
|
DefaultWidgetsLocalizations.delegate,
|
||||||
child: CustomScrollView(
|
DefaultMaterialLocalizations.delegate,
|
||||||
reverse: true, // This is the important setting for this test.
|
],
|
||||||
controller: controller,
|
child: Directionality(
|
||||||
slivers: <Widget>[
|
textDirection: TextDirection.ltr,
|
||||||
const SliverAppBar(
|
child: MediaQuery(
|
||||||
pinned: true,
|
data: const MediaQueryData(),
|
||||||
expandedHeight: 100.0,
|
child: CustomScrollView(
|
||||||
title: Text('AppBar'),
|
reverse: true, // This is the important setting for this test.
|
||||||
),
|
controller: controller,
|
||||||
]..addAll(slivers),
|
slivers: <Widget>[
|
||||||
|
const SliverAppBar(
|
||||||
|
pinned: true,
|
||||||
|
expandedHeight: 100.0,
|
||||||
|
title: Text('AppBar'),
|
||||||
|
),
|
||||||
|
]..addAll(slivers),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -856,39 +905,46 @@ void _tests() {
|
|||||||
textDirection: TextDirection.ltr,
|
textDirection: TextDirection.ltr,
|
||||||
child: Directionality(
|
child: Directionality(
|
||||||
textDirection: TextDirection.ltr,
|
textDirection: TextDirection.ltr,
|
||||||
child: MediaQuery(
|
child: Localizations(
|
||||||
data: const MediaQueryData(),
|
locale: const Locale('en', 'us'),
|
||||||
child: Scrollable(
|
delegates: const <LocalizationsDelegate<dynamic>>[
|
||||||
controller: controller,
|
DefaultWidgetsLocalizations.delegate,
|
||||||
viewportBuilder: (BuildContext context, ViewportOffset offset) {
|
DefaultMaterialLocalizations.delegate,
|
||||||
return Viewport(
|
],
|
||||||
offset: offset,
|
child: MediaQuery(
|
||||||
center: forwardAppBarKey,
|
data: const MediaQueryData(),
|
||||||
slivers: <Widget>[
|
child: Scrollable(
|
||||||
SliverList(
|
controller: controller,
|
||||||
delegate: SliverChildListDelegate(backwardChildren),
|
viewportBuilder: (BuildContext context, ViewportOffset offset) {
|
||||||
),
|
return Viewport(
|
||||||
const SliverAppBar(
|
offset: offset,
|
||||||
pinned: true,
|
center: forwardAppBarKey,
|
||||||
expandedHeight: 100.0,
|
slivers: <Widget>[
|
||||||
flexibleSpace: FlexibleSpaceBar(
|
SliverList(
|
||||||
title: Text('Backward app bar', textDirection: TextDirection.ltr),
|
delegate: SliverChildListDelegate(backwardChildren),
|
||||||
),
|
),
|
||||||
),
|
const SliverAppBar(
|
||||||
SliverAppBar(
|
pinned: true,
|
||||||
pinned: true,
|
expandedHeight: 100.0,
|
||||||
key: forwardAppBarKey,
|
flexibleSpace: FlexibleSpaceBar(
|
||||||
expandedHeight: 100.0,
|
title: Text('Backward app bar', textDirection: TextDirection.ltr),
|
||||||
flexibleSpace: const FlexibleSpaceBar(
|
),
|
||||||
title: Text('Forward app bar', textDirection: TextDirection.ltr),
|
|
||||||
),
|
),
|
||||||
),
|
SliverAppBar(
|
||||||
SliverList(
|
pinned: true,
|
||||||
delegate: SliverChildListDelegate(forwardChildren),
|
key: forwardAppBarKey,
|
||||||
),
|
expandedHeight: 100.0,
|
||||||
],
|
flexibleSpace: const FlexibleSpaceBar(
|
||||||
);
|
title: Text('Forward app bar', textDirection: TextDirection.ltr),
|
||||||
},
|
),
|
||||||
|
),
|
||||||
|
SliverList(
|
||||||
|
delegate: SliverChildListDelegate(forwardChildren),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -9,27 +9,34 @@ void main() {
|
|||||||
testWidgets('Sliver appbars - floating and pinned - second app bar stacks below', (WidgetTester tester) async {
|
testWidgets('Sliver appbars - floating and pinned - second app bar stacks below', (WidgetTester tester) async {
|
||||||
final ScrollController controller = ScrollController();
|
final ScrollController controller = ScrollController();
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
Directionality(
|
Localizations(
|
||||||
textDirection: TextDirection.ltr,
|
locale: const Locale('en', 'us'),
|
||||||
child: MediaQuery(
|
delegates: const <LocalizationsDelegate<dynamic>>[
|
||||||
data: const MediaQueryData(),
|
DefaultWidgetsLocalizations.delegate,
|
||||||
child: CustomScrollView(
|
DefaultMaterialLocalizations.delegate,
|
||||||
controller: controller,
|
],
|
||||||
slivers: const <Widget>[
|
child: Directionality(
|
||||||
SliverAppBar(floating: true, pinned: true, expandedHeight: 200.0, title: Text('A')),
|
textDirection: TextDirection.ltr,
|
||||||
SliverAppBar(primary: false, pinned: true, title: Text('B')),
|
child: MediaQuery(
|
||||||
SliverList(
|
data: const MediaQueryData(),
|
||||||
delegate: SliverChildListDelegate(
|
child: CustomScrollView(
|
||||||
<Widget>[
|
controller: controller,
|
||||||
Text('C'),
|
slivers: const <Widget>[
|
||||||
Text('D'),
|
SliverAppBar(floating: true, pinned: true, expandedHeight: 200.0, title: Text('A')),
|
||||||
SizedBox(height: 500.0),
|
SliverAppBar(primary: false, pinned: true, title: Text('B')),
|
||||||
Text('E'),
|
SliverList(
|
||||||
SizedBox(height: 500.0),
|
delegate: SliverChildListDelegate(
|
||||||
],
|
<Widget>[
|
||||||
|
Text('C'),
|
||||||
|
Text('D'),
|
||||||
|
SizedBox(height: 500.0),
|
||||||
|
Text('E'),
|
||||||
|
SizedBox(height: 500.0),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
],
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
Loading…
Reference in New Issue
Block a user