Multiple cherry-picks to replicate last internal roll. (#111703)
* Roll Flutter Engine from 4096e133ef51 to 6610f3f2a9fb (11 revisions) (#111240) (#111533)
Co-authored-by: engine-flutter-autoroll <engine-flutter-autoroll@skia.org>
* Revert Ballistic & Clamping simulation updates (#111535)
* Roll Flutter Engine from 4096e133ef51 to 6610f3f2a9fb (11 revisions) (#111240)
* Revert Ballistic & Clamping simulation updates (#111201)
Co-authored-by: engine-flutter-autoroll <engine-flutter-autoroll@skia.org>
Co-authored-by: Kate Lovett <katelovett@google.com>
* Revert "Update MaterialBanner to support Material 3" (#111612)
* Roll Flutter Engine from 4096e133ef51 to 6610f3f2a9fb (11 revisions) (#111240)
* Revert Ballistic & Clamping simulation updates (#111201)
* Revert "Update `MaterialBanner` to support Material 3" (#111288)
Co-authored-by: engine-flutter-autoroll <engine-flutter-autoroll@skia.org>
Co-authored-by: Kate Lovett <katelovett@google.com>
Co-authored-by: Casey Hillers <chillers@google.com>
* Revert "Use semantics label for backbutton and closebutton for Androi… (#111636)
* Roll Flutter Engine from 4096e133ef51 to 6610f3f2a9fb (11 revisions) (#111240)
* Revert Ballistic & Clamping simulation updates (#111201)
* Revert "Update `MaterialBanner` to support Material 3" (#111288)
* Revert "Use semantics label for backbutton and closebutton for Android" (#111305)
Co-authored-by: engine-flutter-autoroll <engine-flutter-autoroll@skia.org>
Co-authored-by: Kate Lovett <katelovett@google.com>
Co-authored-by: Casey Hillers <chillers@google.com>
Co-authored-by: Xilai Zhang <xilaizhang@google.com>
* Revert "Single tap on the previous selection should toggle the toolbar on iOS…" (#111662)
Co-authored-by: engine-flutter-autoroll <engine-flutter-autoroll@skia.org>
Co-authored-by: Kate Lovett <katelovett@google.com>
Co-authored-by: Casey Hillers <chillers@google.com>
Co-authored-by: Xilai Zhang <xilaizhang@google.com>
diff --git a/bin/internal/canvaskit.version b/bin/internal/canvaskit.version
index 56b4dbe..5b4d72b 100644
--- a/bin/internal/canvaskit.version
+++ b/bin/internal/canvaskit.version
@@ -1 +1 @@
-yrsfF-vTvu4jzBBm1o6tDl70dky-l4G29Dnj75UvRDgC
+8wh6J7ZXGCgo1vvCQIqkmskYQZfjhcXQG1YCKFNrzRUC
diff --git a/bin/internal/engine.version b/bin/internal/engine.version
index 5a3e4e5..7cf26e4 100644
--- a/bin/internal/engine.version
+++ b/bin/internal/engine.version
@@ -1 +1 @@
-3af5d354cd4fa654e488601151323e7dd3c935a6
+6610f3f2a9fb278f4090f963599ba0d54186804f
diff --git a/bin/internal/fuchsia-mac.version b/bin/internal/fuchsia-mac.version
index 7a96f69..3f1e1ad 100644
--- a/bin/internal/fuchsia-mac.version
+++ b/bin/internal/fuchsia-mac.version
@@ -1 +1 @@
-vxuLLecT-NU8FuW1lAbXNg5iDOvKWw9cYQrLIi2vMFAC
+SptzPcGbOBfYL-TumC73XZ9vaDJbzuZrDBi7OubOYuUC
diff --git a/dev/tools/gen_defaults/bin/gen_defaults.dart b/dev/tools/gen_defaults/bin/gen_defaults.dart
index 659cec6..7186877 100644
--- a/dev/tools/gen_defaults/bin/gen_defaults.dart
+++ b/dev/tools/gen_defaults/bin/gen_defaults.dart
@@ -17,17 +17,16 @@
import 'dart:convert';
import 'dart:io';
-import 'package:gen_defaults/action_chip_template.dart';
import 'package:gen_defaults/app_bar_template.dart';
-import 'package:gen_defaults/banner_template.dart';
import 'package:gen_defaults/button_template.dart';
import 'package:gen_defaults/card_template.dart';
import 'package:gen_defaults/checkbox_template.dart';
+import 'package:gen_defaults/chip_action_template.dart';
+import 'package:gen_defaults/chip_filter_template.dart';
+import 'package:gen_defaults/chip_input_template.dart';
import 'package:gen_defaults/dialog_template.dart';
import 'package:gen_defaults/fab_template.dart';
-import 'package:gen_defaults/filter_chip_template.dart';
import 'package:gen_defaults/icon_button_template.dart';
-import 'package:gen_defaults/input_chip_template.dart';
import 'package:gen_defaults/input_decorator_template.dart';
import 'package:gen_defaults/navigation_bar_template.dart';
import 'package:gen_defaults/navigation_rail_template.dart';
@@ -104,7 +103,6 @@
tokens['colorsDark'] = _readTokenFile('color_dark.json');
AppBarTemplate('AppBar', '$materialLib/app_bar.dart', tokens).updateFile();
- BannerTemplate('Banner', '$materialLib/banner.dart', tokens).updateFile();
ButtonTemplate('md.comp.elevated-button', 'ElevatedButton', '$materialLib/elevated_button.dart', tokens).updateFile();
ButtonTemplate('md.comp.filled-button', 'FilledButton', '$materialLib/filled_button.dart', tokens).updateFile();
ButtonTemplate('md.comp.filled-tonal-button', 'FilledTonalButton', '$materialLib/filled_button.dart', tokens).updateFile();
@@ -112,10 +110,10 @@
ButtonTemplate('md.comp.text-button', 'TextButton', '$materialLib/text_button.dart', tokens).updateFile();
CardTemplate('Card', '$materialLib/card.dart', tokens).updateFile();
CheckboxTemplate('Checkbox', '$materialLib/checkbox.dart', tokens).updateFile();
- ChipActionTemplate('ActionChip', '$materialLib/action_chip.dart', tokens).updateFile();
- ChipFilterTemplate('FilterChip', '$materialLib/filter_chip.dart', tokens).updateFile();
- ChipFilterTemplate('FilterChip', '$materialLib/choice_chip.dart', tokens).updateFile();
- ChipInputTemplate('InputChip', '$materialLib/input_chip.dart', tokens).updateFile();
+ ChipActionTemplate('ActionChip', '$materialLib/chip_action.dart', tokens).updateFile();
+ ChipFilterTemplate('FilterChip', '$materialLib/chip_filter.dart', tokens).updateFile();
+ ChipFilterTemplate('FilterChip', '$materialLib/chip_choice.dart', tokens).updateFile();
+ ChipInputTemplate('InputChip', '$materialLib/chip_input.dart', tokens).updateFile();
DialogTemplate('Dialog', '$materialLib/dialog.dart', tokens).updateFile();
FABTemplate('FAB', '$materialLib/floating_action_button.dart', tokens).updateFile();
IconButtonTemplate('IconButton', '$materialLib/icon_button.dart', tokens).updateFile();
diff --git a/dev/tools/gen_defaults/lib/banner_template.dart b/dev/tools/gen_defaults/lib/banner_template.dart
deleted file mode 100644
index 123c8ec..0000000
--- a/dev/tools/gen_defaults/lib/banner_template.dart
+++ /dev/null
@@ -1,31 +0,0 @@
-// Copyright 2014 The Flutter Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-import 'template.dart';
-
-class BannerTemplate extends TokenTemplate {
- const BannerTemplate(super.blockName, super.fileName, super.tokens);
-
- @override
- String generate() => '''
-class _${blockName}DefaultsM3 extends MaterialBannerThemeData {
- const _${blockName}DefaultsM3(this.context)
- : super(elevation: ${elevation("md.comp.banner.container")});
-
- final BuildContext context;
-
- @override
- Color? get backgroundColor => ${componentColor("md.comp.banner.container")};
-
- @override
- Color? get surfaceTintColor => ${color("md.comp.banner.container.surface-tint-layer.color")};
-
- @override
- Color? get dividerColor => ${color("md.comp.banner.divider.color")};
-
- @override
- TextStyle? get contentTextStyle => ${textStyle("md.comp.banner.supporting-text")};
-}
-''';
-}
diff --git a/dev/tools/gen_defaults/lib/action_chip_template.dart b/dev/tools/gen_defaults/lib/chip_action_template.dart
similarity index 100%
rename from dev/tools/gen_defaults/lib/action_chip_template.dart
rename to dev/tools/gen_defaults/lib/chip_action_template.dart
diff --git a/dev/tools/gen_defaults/lib/filter_chip_template.dart b/dev/tools/gen_defaults/lib/chip_filter_template.dart
similarity index 100%
rename from dev/tools/gen_defaults/lib/filter_chip_template.dart
rename to dev/tools/gen_defaults/lib/chip_filter_template.dart
diff --git a/dev/tools/gen_defaults/lib/input_chip_template.dart b/dev/tools/gen_defaults/lib/chip_input_template.dart
similarity index 100%
rename from dev/tools/gen_defaults/lib/input_chip_template.dart
rename to dev/tools/gen_defaults/lib/chip_input_template.dart
diff --git a/dev/tools/generate_android_spline_data.dart b/dev/tools/generate_android_spline_data.dart
deleted file mode 100644
index 12e79d5..0000000
--- a/dev/tools/generate_android_spline_data.dart
+++ /dev/null
@@ -1,61 +0,0 @@
-// Copyright 2014 The Flutter Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-const int _nbSamples = 100;
-final List<double> _splinePosition = List<double>.filled(_nbSamples + 1, 0.0);
-final List<double> _splineTime = List<double>.filled(_nbSamples + 1, 0.0);
-const double _startTension = 0.5;
-const double _endTension = 1.0;
-const double _inflexion = 0.35;
-
-// Generate the spline data used in ClampingScrollSimulation.
-//
-// This logic is a translation of the 2-dimensional logic found in
-// https://android.googlesource.com/platform/frameworks/base/+/master/core/java/android/widget/Scroller.java.
-//
-// The output of this program should be copied over to [_splinePosition] in
-// flutter/packages/flutter/lib/src/widgets/scroll_simulation.dart.
-void main() {
- const double p1 = _startTension * _inflexion;
- const double p2 = 1.0 - _endTension * (1.0 - _inflexion);
- double xMin = 0.0;
- double yMin = 0.0;
- for (int i = 0; i < _nbSamples; i++) {
- final double alpha = i / _nbSamples;
- double xMax = 1.0;
- double x, tx, coef;
- while (true) {
- x = xMin + (xMax - xMin) / 2.0;
- coef = 3.0 * x * (1.0 - x);
- tx = coef * ((1.0 - x) * p1 + x * p2) + x * x * x;
- if ((tx - alpha).abs() < 1e-5) {
- break;
- }
- if (tx > alpha) {
- xMax = x;
- } else {
- xMin = x;
- }
- }
- _splinePosition[i] = coef * ((1.0 - x) * _startTension + x) + x * x * x;
- double yMax = 1.0;
- double y, dy;
- while (true) {
- y = yMin + (yMax - yMin) / 2.0;
- coef = 3.0 * y * (1.0 - y);
- dy = coef * ((1.0 - y) * _startTension + y) + y * y * y;
- if ((dy - alpha).abs() < 1e-5) {
- break;
- }
- if (dy > alpha) {
- yMax = y;
- } else {
- yMin = y;
- }
- }
- _splineTime[i] = coef * ((1.0 - y) * p1 + y * p2) + y * y * y;
- }
- _splinePosition[_nbSamples] = _splineTime[_nbSamples] = 1.0;
- print(_splinePosition);
-}
diff --git a/packages/flutter/lib/src/animation/animation_controller.dart b/packages/flutter/lib/src/animation/animation_controller.dart
index 25b5c04..da359a0 100644
--- a/packages/flutter/lib/src/animation/animation_controller.dart
+++ b/packages/flutter/lib/src/animation/animation_controller.dart
@@ -757,15 +757,6 @@
return result;
}
- /// Update the simulation without restarting the animation.
- ///
- /// The current simulation will be replaced with the provided [Simulation].
- /// It is only valid to call this when an animation is currently underway.
- void updateSimulation(Simulation simulation) {
- assert(isAnimating);
- _simulation = simulation;
- }
-
/// Stops running this animation.
///
/// This does not trigger any notifications. The animation stops in its
diff --git a/packages/flutter/lib/src/cupertino/text_field.dart b/packages/flutter/lib/src/cupertino/text_field.dart
index 3b7bf0c..71d7a49 100644
--- a/packages/flutter/lib/src/cupertino/text_field.dart
+++ b/packages/flutter/lib/src/cupertino/text_field.dart
@@ -102,6 +102,7 @@
@override
void onSingleTapUp(TapUpDetails details) {
+ editableText.hideToolbar();
// Because TextSelectionGestureDetector listens to taps that happen on
// widgets in front of it, tapping the clear button will also trigger
// this handler. If the clear button widget recognizes the up event,
diff --git a/packages/flutter/lib/src/material/back_button.dart b/packages/flutter/lib/src/material/back_button.dart
index 3feaba5..4d1f1c8 100644
--- a/packages/flutter/lib/src/material/back_button.dart
+++ b/packages/flutter/lib/src/material/back_button.dart
@@ -27,31 +27,22 @@
/// the current platform (as obtained from the [Theme]).
const BackButtonIcon({ super.key });
- @override
- Widget build(BuildContext context) {
- final String? semanticsLabel;
- final IconData data;
- switch (Theme.of(context).platform) {
+ /// Returns the appropriate "back" icon for the given `platform`.
+ static IconData _getIconData(TargetPlatform platform) {
+ switch (platform) {
case TargetPlatform.android:
- // Android uses semantics label to annotate the back button.
- semanticsLabel = MaterialLocalizations.of(context).backButtonTooltip;
- data = Icons.arrow_back;
- break;
case TargetPlatform.fuchsia:
case TargetPlatform.linux:
case TargetPlatform.windows:
- semanticsLabel = null;
- data = Icons.arrow_back;
- break;
+ return Icons.arrow_back;
case TargetPlatform.iOS:
case TargetPlatform.macOS:
- data = Icons.arrow_back_ios;
- semanticsLabel = null;
- break;
+ return Icons.arrow_back_ios;
}
-
- return Icon(data, semanticLabel: semanticsLabel);
}
+
+ @override
+ Widget build(BuildContext context) => Icon(_getIconData(Theme.of(context).platform));
}
/// A Material Design back button.
@@ -158,22 +149,8 @@
@override
Widget build(BuildContext context) {
assert(debugCheckHasMaterialLocalizations(context));
- final String? semanticsLabel;
- switch (Theme.of(context).platform) {
- case TargetPlatform.android:
- // Android uses semantics label to annotate the close button.
- semanticsLabel = MaterialLocalizations.of(context).closeButtonTooltip;
- break;
- case TargetPlatform.fuchsia:
- case TargetPlatform.linux:
- case TargetPlatform.windows:
- case TargetPlatform.iOS:
- case TargetPlatform.macOS:
- semanticsLabel = null;
- break;
- }
return IconButton(
- icon: Icon(Icons.close, semanticLabel: semanticsLabel),
+ icon: const Icon(Icons.close),
color: color,
tooltip: MaterialLocalizations.of(context).closeButtonTooltip,
onPressed: () {
diff --git a/packages/flutter/lib/src/material/banner.dart b/packages/flutter/lib/src/material/banner.dart
index 83849d0..6eede2d 100644
--- a/packages/flutter/lib/src/material/banner.dart
+++ b/packages/flutter/lib/src/material/banner.dart
@@ -102,15 +102,12 @@
this.elevation,
this.leading,
this.backgroundColor,
- this.surfaceTintColor,
- this.shadowColor,
- this.dividerColor,
this.padding,
this.leadingPadding,
this.forceActionsBelow = false,
this.overflowAlignment = OverflowBarAlignment.end,
this.animation,
- this.onVisible,
+ this.onVisible
}) : assert(elevation == null || elevation >= 0.0),
assert(content != null),
assert(actions != null),
@@ -156,29 +153,6 @@
/// also `null`, [ColorScheme.surface] of [ThemeData.colorScheme] is used.
final Color? backgroundColor;
- /// The color used as an overlay on [backgroundColor] to indicate elevation.
- ///
- /// If null, [MaterialBannerThemeData.surfaceTintColor] is used. If that
- /// is also null, the default value is [ColorScheme.surfaceTint].
- ///
- /// See [Material.surfaceTintColor] for more details on how this
- /// overlay is applied.
- final Color? surfaceTintColor;
-
- /// The color of the shadow below the [MaterialBanner].
- ///
- /// If this property is null, then [MaterialBannerThemeData.shadowColor] of
- /// [ThemeData.bannerTheme] is used. If that is also null, the default value
- /// is null.
- final Color? shadowColor;
-
- /// The color of the divider.
- ///
- /// If this property is null, then [MaterialBannerThemeData.dividerColor] of
- /// [ThemeData.bannerTheme] is used. If that is also null, the default value
- /// is [ColorScheme.surfaceVariant].
- final Color? dividerColor;
-
/// The amount of space by which to inset the [content].
///
/// If the [actions] are below the [content], this defaults to
@@ -299,7 +273,6 @@
final ThemeData theme = Theme.of(context);
final MaterialBannerThemeData bannerTheme = MaterialBannerTheme.of(context);
- final MaterialBannerThemeData defaults = theme.useMaterial3 ? _BannerDefaultsM3(context) : _BannerDefaultsM2(context);
final bool isSingleRow = widget.actions.length == 1 && !widget.forceActionsBelow;
final EdgeInsetsGeometry padding = widget.padding ?? bannerTheme.padding ?? (isSingleRow
@@ -323,26 +296,16 @@
final double elevation = widget.elevation ?? bannerTheme.elevation ?? 0.0;
final Color backgroundColor = widget.backgroundColor
?? bannerTheme.backgroundColor
- ?? defaults.backgroundColor!;
- final Color? surfaceTintColor = widget.surfaceTintColor
- ?? bannerTheme.surfaceTintColor
- ?? defaults.surfaceTintColor;
- final Color? shadowColor = widget.shadowColor
- ?? bannerTheme.shadowColor;
- final Color? dividerColor = widget.dividerColor
- ?? bannerTheme.dividerColor
- ?? defaults.dividerColor;
+ ?? theme.colorScheme.surface;
final TextStyle? textStyle = widget.contentTextStyle
?? bannerTheme.contentTextStyle
- ?? defaults.contentTextStyle;
+ ?? theme.textTheme.bodyMedium;
Widget materialBanner = Container(
margin: EdgeInsets.only(bottom: elevation > 0 ? 10.0 : 0.0),
child: Material(
elevation: elevation,
color: backgroundColor,
- surfaceTintColor: surfaceTintColor,
- shadowColor: shadowColor,
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
@@ -368,8 +331,9 @@
),
if (!isSingleRow)
buttonBar,
+
if (elevation == 0)
- Divider(height: 0, color: dividerColor),
+ const Divider(height: 0),
],
),
),
@@ -430,51 +394,3 @@
);
}
}
-
-class _BannerDefaultsM2 extends MaterialBannerThemeData {
- _BannerDefaultsM2(this.context)
- : _theme = Theme.of(context),
- super(elevation: 0.0);
-
- final BuildContext context;
- final ThemeData _theme;
-
- @override
- Color? get backgroundColor => _theme.colorScheme.surface;
-
- @override
- Color? get dividerColor => Theme.of(context).colorScheme.surfaceVariant;
-
- @override
- TextStyle? get contentTextStyle => _theme.textTheme.bodyText2;
-}
-
-// BEGIN GENERATED TOKEN PROPERTIES - Banner
-
-// Do not edit by hand. The code between the "BEGIN GENERATED" and
-// "END GENERATED" comments are generated from data in the Material
-// Design token database by the script:
-// dev/tools/gen_defaults/bin/gen_defaults.dart.
-
-// Token database version: v0_101
-
-class _BannerDefaultsM3 extends MaterialBannerThemeData {
- const _BannerDefaultsM3(this.context)
- : super(elevation: 1.0);
-
- final BuildContext context;
-
- @override
- Color? get backgroundColor => Theme.of(context).colorScheme.surface;
-
- @override
- Color? get surfaceTintColor => Theme.of(context).colorScheme.surfaceTint;
-
- @override
- Color? get dividerColor => Theme.of(context).colorScheme.surfaceVariant;
-
- @override
- TextStyle? get contentTextStyle => Theme.of(context).textTheme.bodyMedium;
-}
-
-// END GENERATED TOKEN PROPERTIES - Banner
diff --git a/packages/flutter/lib/src/material/banner_theme.dart b/packages/flutter/lib/src/material/banner_theme.dart
index 8b0b183..5081f88 100644
--- a/packages/flutter/lib/src/material/banner_theme.dart
+++ b/packages/flutter/lib/src/material/banner_theme.dart
@@ -35,9 +35,6 @@
/// [ThemeData.bannerTheme].
const MaterialBannerThemeData({
this.backgroundColor,
- this.surfaceTintColor,
- this.shadowColor,
- this.dividerColor,
this.contentTextStyle,
this.elevation,
this.padding,
@@ -47,15 +44,6 @@
/// The background color of a [MaterialBanner].
final Color? backgroundColor;
- /// Overrides the default value of [MaterialBanner.surfaceTintColor].
- final Color? surfaceTintColor;
-
- /// Overrides the default value of [MaterialBanner.shadowColor].
- final Color? shadowColor;
-
- /// Overrides the default value of [MaterialBanner.dividerColor].
- final Color? dividerColor;
-
/// Used to configure the [DefaultTextStyle] for the [MaterialBanner.content]
/// widget.
final TextStyle? contentTextStyle;
@@ -75,9 +63,6 @@
/// new values.
MaterialBannerThemeData copyWith({
Color? backgroundColor,
- Color? surfaceTintColor,
- Color? shadowColor,
- Color? dividerColor,
TextStyle? contentTextStyle,
double? elevation,
EdgeInsetsGeometry? padding,
@@ -85,9 +70,6 @@
}) {
return MaterialBannerThemeData(
backgroundColor: backgroundColor ?? this.backgroundColor,
- surfaceTintColor: surfaceTintColor ?? this.surfaceTintColor,
- shadowColor: shadowColor ?? this.shadowColor,
- dividerColor: dividerColor ?? this.dividerColor,
contentTextStyle: contentTextStyle ?? this.contentTextStyle,
elevation: elevation ?? this.elevation,
padding: padding ?? this.padding,
@@ -104,9 +86,6 @@
assert(t != null);
return MaterialBannerThemeData(
backgroundColor: Color.lerp(a?.backgroundColor, b?.backgroundColor, t),
- surfaceTintColor: Color.lerp(a?.surfaceTintColor, b?.surfaceTintColor, t),
- shadowColor: Color.lerp(a?.shadowColor, b?.shadowColor, t),
- dividerColor: Color.lerp(a?.dividerColor, b?.dividerColor, t),
contentTextStyle: TextStyle.lerp(a?.contentTextStyle, b?.contentTextStyle, t),
elevation: lerpDouble(a?.elevation, b?.elevation, t),
padding: EdgeInsetsGeometry.lerp(a?.padding, b?.padding, t),
@@ -117,9 +96,6 @@
@override
int get hashCode => Object.hash(
backgroundColor,
- surfaceTintColor,
- shadowColor,
- dividerColor,
contentTextStyle,
elevation,
padding,
@@ -135,25 +111,19 @@
return false;
}
return other is MaterialBannerThemeData
- && other.backgroundColor == backgroundColor
- && other.surfaceTintColor == surfaceTintColor
- && other.shadowColor == shadowColor
- && other.dividerColor == dividerColor
- && other.contentTextStyle == contentTextStyle
- && other.elevation == elevation
- && other.padding == padding
- && other.leadingPadding == leadingPadding;
+ && other.backgroundColor == backgroundColor
+ && other.contentTextStyle == contentTextStyle
+ && other.elevation == elevation
+ && other.padding == padding
+ && other.leadingPadding == leadingPadding;
}
@override
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
super.debugFillProperties(properties);
properties.add(ColorProperty('backgroundColor', backgroundColor, defaultValue: null));
- properties.add(ColorProperty('surfaceTintColor', surfaceTintColor, defaultValue: null));
- properties.add(ColorProperty('shadowColor', shadowColor, defaultValue: null));
- properties.add(ColorProperty('dividerColor', dividerColor, defaultValue: null));
properties.add(DiagnosticsProperty<TextStyle>('contentTextStyle', contentTextStyle, defaultValue: null));
- properties.add(DoubleProperty('elevation', elevation, defaultValue: null));
+ properties.add(DiagnosticsProperty<double>('elevation', elevation, defaultValue: null));
properties.add(DiagnosticsProperty<EdgeInsetsGeometry>('padding', padding, defaultValue: null));
properties.add(DiagnosticsProperty<EdgeInsetsGeometry>('leadingPadding', leadingPadding, defaultValue: null));
}
diff --git a/packages/flutter/lib/src/material/text_field.dart b/packages/flutter/lib/src/material/text_field.dart
index 19b69c2..853e8b4 100644
--- a/packages/flutter/lib/src/material/text_field.dart
+++ b/packages/flutter/lib/src/material/text_field.dart
@@ -89,6 +89,7 @@
@override
void onSingleTapUp(TapUpDetails details) {
+ editableText.hideToolbar();
super.onSingleTapUp(details);
_state._requestKeyboard();
_state.widget.onTap?.call();
diff --git a/packages/flutter/lib/src/widgets/editable_text.dart b/packages/flutter/lib/src/widgets/editable_text.dart
index 8fa7f9f..857bed9 100644
--- a/packages/flutter/lib/src/widgets/editable_text.dart
+++ b/packages/flutter/lib/src/widgets/editable_text.dart
@@ -3315,10 +3315,10 @@
}
/// Toggles the visibility of the toolbar.
- void toggleToolbar([bool hideHandles = true]) {
+ void toggleToolbar() {
assert(_selectionOverlay != null);
if (_selectionOverlay!.toolbarIsVisible) {
- hideToolbar(hideHandles);
+ hideToolbar();
} else {
showToolbar();
}
diff --git a/packages/flutter/lib/src/widgets/nested_scroll_view.dart b/packages/flutter/lib/src/widgets/nested_scroll_view.dart
index 46f5277..93f3029 100644
--- a/packages/flutter/lib/src/widgets/nested_scroll_view.dart
+++ b/packages/flutter/lib/src/widgets/nested_scroll_view.dart
@@ -686,12 +686,6 @@
);
}
- // TODO(Piinks): https://github.com/flutter/flutter/issues/100748
- @override
- Simulation? updateBallisticAnimation(double initVelocity, double initPosition) {
- return null;
- }
-
ScrollActivity createOuterBallisticScrollActivity(double velocity) {
// This function creates a ballistic scroll for the outer scrollable.
//
@@ -1367,12 +1361,6 @@
));
}
- // TODO(Piinks): see https://github.com/flutter/flutter/issues/100748
- @override
- Simulation? updateBallisticAnimation(double initVelocity, double initPosition) {
- return null;
- }
-
ScrollActivity createBallisticScrollActivity(
Simulation? simulation, {
required _NestedBallisticScrollActivityMode mode,
diff --git a/packages/flutter/lib/src/widgets/scroll_activity.dart b/packages/flutter/lib/src/widgets/scroll_activity.dart
index 96f6379..b8b7b1f 100644
--- a/packages/flutter/lib/src/widgets/scroll_activity.dart
+++ b/packages/flutter/lib/src/widgets/scroll_activity.dart
@@ -47,16 +47,6 @@
/// Terminate the current activity and start a ballistic activity with the
/// given velocity.
void goBallistic(double velocity);
-
- /// Update the ballistic animation instead of restarting it, for example as
- /// the result of a layout change after a flinging gesture.
- ///
- /// The [initVelocity] and [initPosition] refer to the starting values of the
- /// new ballistic animation.
- ///
- /// Can return null if the current [ScrollPhysics.createBallisticSimulation]
- /// returns null, which will trigger an [IdleScrollActivity] instead.
- Simulation? updateBallisticAnimation(double initVelocity, double initPosition);
}
/// Base class for scrolling activities like dragging and flinging.
@@ -534,17 +524,13 @@
class BallisticScrollActivity extends ScrollActivity {
/// Creates an activity that animates a scroll view based on a [simulation].
///
- /// The [delegate], [simulation], and [vsync] arguments must not be null. The
- /// [initVelocity] and [initPosition] arguments allow the ballistic activity
- /// to update the simulation instead of restarting it.
+ /// The [delegate], [simulation], and [vsync] arguments must not be null.
BallisticScrollActivity(
super.delegate,
Simulation simulation,
TickerProvider vsync,
- this.shouldIgnorePointer, {
- double initVelocity = 0.0,
- double initPosition = 0.0,
- }) : _initVelocity = initVelocity, _initPosition = initPosition {
+ this.shouldIgnorePointer,
+ ) {
_controller = AnimationController.unbounded(
debugLabel: kDebugMode ? objectRuntimeType(this, 'BallisticScrollActivity') : null,
vsync: vsync,
@@ -556,10 +542,6 @@
late AnimationController _controller;
- final double _initVelocity;
-
- final double _initPosition;
-
@override
void resetActivity() {
delegate.goBallistic(velocity);
@@ -567,13 +549,7 @@
@override
void applyNewDimensions() {
- final Simulation? newSimulation = delegate.updateBallisticAnimation(
- _initVelocity,
- _initPosition,
- );
- if (newSimulation != null) {
- _controller.updateSimulation(newSimulation);
- }
+ delegate.goBallistic(velocity);
}
void _tick() {
diff --git a/packages/flutter/lib/src/widgets/scroll_position_with_single_context.dart b/packages/flutter/lib/src/widgets/scroll_position_with_single_context.dart
index 68b838a..c1a1666 100644
--- a/packages/flutter/lib/src/widgets/scroll_position_with_single_context.dart
+++ b/packages/flutter/lib/src/widgets/scroll_position_with_single_context.dart
@@ -12,7 +12,6 @@
import 'framework.dart';
import 'scroll_activity.dart';
import 'scroll_context.dart';
-import 'scroll_metrics.dart';
import 'scroll_notification.dart';
import 'scroll_physics.dart';
import 'scroll_position.dart';
@@ -147,8 +146,6 @@
simulation,
context.vsync,
activity?.shouldIgnorePointer ?? true,
- initVelocity: velocity,
- initPosition: pixels,
));
} else {
goIdle();
@@ -156,27 +153,6 @@
}
@override
- Simulation? updateBallisticAnimation(double initVelocity, double initPosition) {
- assert(hasPixels);
- final FixedScrollMetrics initScrollMetrics = FixedScrollMetrics(
- minScrollExtent: minScrollExtent,
- maxScrollExtent: maxScrollExtent,
- pixels: initPosition,
- viewportDimension: viewportDimension,
- axisDirection: axisDirection,
- );
- final Simulation? simulation = physics.createBallisticSimulation(
- initScrollMetrics,
- initVelocity,
- );
- if (simulation == null) {
- goIdle();
- return null;
- }
- return simulation;
- }
-
- @override
ScrollDirection get userScrollDirection => _userScrollDirection;
ScrollDirection _userScrollDirection = ScrollDirection.idle;
diff --git a/packages/flutter/lib/src/widgets/scroll_simulation.dart b/packages/flutter/lib/src/widgets/scroll_simulation.dart
index 2d54d6f..eb12592 100644
--- a/packages/flutter/lib/src/widgets/scroll_simulation.dart
+++ b/packages/flutter/lib/src/widgets/scroll_simulation.dart
@@ -146,13 +146,11 @@
required this.velocity,
this.friction = 0.015,
super.tolerance,
- }) {
- _duration = _splineFlingDuration(velocity);
- _distance = _splineFlingDistance(velocity);
+ }) : assert(_flingVelocityPenetration(0.0) == _initialVelocityPenetration) {
+ _duration = _flingDuration(velocity);
+ _distance = (velocity * _duration / _initialVelocityPenetration).abs();
}
- final double _inflexion = 0.35;
-
/// The position of the particle at the beginning of the simulation.
final double position;
@@ -165,7 +163,7 @@
/// The more friction the particle experiences, the sooner it stops.
final double friction;
- late int _duration;
+ late double _duration;
late double _distance;
// See DECELERATION_RATE.
@@ -173,186 +171,59 @@
// See computeDeceleration().
static double _decelerationForFriction(double friction) {
- return 9.80665 *
- 39.37 *
- friction *
- 1.0 * // Flutter operates on logical pixels so the DPI should be 1.0.
- 160.0;
+ return friction * 61774.04968;
}
- // See getSplineDeceleration().
- double _splineDeceleration(double velocity) {
- return math.log(_inflexion *
- velocity.abs() /
- (friction * _decelerationForFriction(0.84)));
+ // See getSplineFlingDuration(). Returns a value in seconds.
+ double _flingDuration(double velocity) {
+ // See mPhysicalCoeff
+ final double scaledFriction = friction * _decelerationForFriction(0.84);
+
+ // See getSplineDeceleration().
+ final double deceleration = math.log(0.35 * velocity.abs() / scaledFriction);
+
+ return math.exp(deceleration / (_kDecelerationRate - 1.0));
}
- // See getSplineFlingDuration().
- int _splineFlingDuration(double velocity) {
- final double deceleration = _splineDeceleration(velocity);
- return (1000 * math.exp(deceleration / (_kDecelerationRate - 1.0))).round();
+ // Based on a cubic curve fit to the Scroller.computeScrollOffset() values
+ // produced for an initial velocity of 4000. The value of Scroller.getDuration()
+ // and Scroller.getFinalY() were 686ms and 961 pixels respectively.
+ //
+ // Algebra courtesy of Wolfram Alpha.
+ //
+ // f(x) = scrollOffset, x is time in milliseconds
+ // f(x) = 3.60882×10^-6 x^3 - 0.00668009 x^2 + 4.29427 x - 3.15307
+ // f(x) = 3.60882×10^-6 x^3 - 0.00668009 x^2 + 4.29427 x, so f(0) is 0
+ // f(686ms) = 961 pixels
+ // Scale to f(0 <= t <= 1.0), x = t * 686
+ // f(t) = 1165.03 t^3 - 3143.62 t^2 + 2945.87 t
+ // Scale f(t) so that 0.0 <= f(t) <= 1.0
+ // f(t) = (1165.03 t^3 - 3143.62 t^2 + 2945.87 t) / 961.0
+ // = 1.2 t^3 - 3.27 t^2 + 3.065 t
+ static const double _initialVelocityPenetration = 3.065;
+ static double _flingDistancePenetration(double t) {
+ return (1.2 * t * t * t) - (3.27 * t * t) + (_initialVelocityPenetration * t);
}
- // See getSplineFlingDistance().
- double _splineFlingDistance(double velocity) {
- final double l = _splineDeceleration(velocity);
- final double decelMinusOne = _kDecelerationRate - 1.0;
- return friction *
- _decelerationForFriction(0.84) *
- math.exp(_kDecelerationRate / decelMinusOne * l);
+ // The derivative of the _flingDistancePenetration() function.
+ static double _flingVelocityPenetration(double t) {
+ return (3.6 * t * t) - (6.54 * t) + _initialVelocityPenetration;
}
@override
double x(double time) {
- if (time == 0) {
- return position;
- }
- final _NBSample sample = _NBSample(time, _duration);
- return position + (sample.distanceCoef * _distance) * velocity.sign;
+ final double t = clampDouble(time / _duration, 0.0, 1.0);
+ return position + _distance * _flingDistancePenetration(t) * velocity.sign;
}
@override
double dx(double time) {
- if (time == 0) {
- return velocity;
- }
- final _NBSample sample = _NBSample(time, _duration);
- return sample.velocityCoef * _distance / _duration * velocity.sign * 1000.0;
+ final double t = clampDouble(time / _duration, 0.0, 1.0);
+ return _distance * _flingVelocityPenetration(t) * velocity.sign / _duration;
}
@override
bool isDone(double time) {
- return time * 1000.0 >= _duration;
+ return time >= _duration;
}
}
-
-class _NBSample {
- _NBSample(double time, int duration) {
- // See computeScrollOffset().
- final double t = time * 1000.0 / duration;
- final int index = (_nbSamples * t).clamp(0, _nbSamples).round(); // ignore_clamp_double_lint
- _distanceCoef = 1.0;
- _velocityCoef = 0.0;
- if (index < _nbSamples) {
- final double tInf = index / _nbSamples;
- final double tSup = (index + 1) / _nbSamples;
- final double dInf = _splinePosition[index];
- final double dSup = _splinePosition[index + 1];
- _velocityCoef = (dSup - dInf) / (tSup - tInf);
- _distanceCoef = dInf + (t - tInf) * _velocityCoef;
- }
- }
-
- late double _velocityCoef;
- double get velocityCoef => _velocityCoef;
-
- late double _distanceCoef;
- double get distanceCoef => _distanceCoef;
-
- static const int _nbSamples = 100;
-
- // Generated from dev/tools/generate_android_spline_data.dart.
- static const List<double> _splinePosition = <double>[
- 0.000022888183591973643,
- 0.028561000304762274,
- 0.05705195792956655,
- 0.08538917797618413,
- 0.11349556286812107,
- 0.14129881694635613,
- 0.16877157254923383,
- 0.19581093511175632,
- 0.22239649722992452,
- 0.24843841866631658,
- 0.2740024733220569,
- 0.298967680744136,
- 0.32333234658228116,
- 0.34709556909569184,
- 0.3702249257894571,
- 0.39272483400399893,
- 0.41456988647721615,
- 0.43582889025419114,
- 0.4564192786416,
- 0.476410299013587,
- 0.4957560715637827,
- 0.5145493169954743,
- 0.5327205670880077,
- 0.5502846891191615,
- 0.5673274324802855,
- 0.583810881323224,
- 0.5997478744397482,
- 0.615194045299478,
- 0.6301165005270208,
- 0.6445484042257972,
- 0.6585198219185201,
- 0.6720397744233084,
- 0.6850997688076114,
- 0.6977281404741683,
- 0.7099506591298411,
- 0.7217749311525871,
- 0.7331784038850426,
- 0.7442308394229518,
- 0.7549087205105974,
- 0.7652471277371271,
- 0.7752251637549381,
- 0.7848768260203478,
- 0.7942056937103814,
- 0.8032299679689082,
- 0.8119428702388629,
- 0.8203713516576219,
- 0.8285187880808974,
- 0.8363794492831295,
- 0.8439768562813565,
- 0.851322799855549,
- 0.8584111051351724,
- 0.8652534074722162,
- 0.8718525580962131,
- 0.8782333271742155,
- 0.8843892099362031,
- 0.8903155590440985,
- 0.8960465359221951,
- 0.9015574505919048,
- 0.9068736766459904,
- 0.9119951682409297,
- 0.9169321898723632,
- 0.9216747065581234,
- 0.9262420604674766,
- 0.9306331858366086,
- 0.9348476990715433,
- 0.9389007110754832,
- 0.9427903495057521,
- 0.9465220679845756,
- 0.9500943036519721,
- 0.9535176728088761,
- 0.9567898524767604,
- 0.959924306623116,
- 0.9629127700159108,
- 0.9657622101750765,
- 0.9684818726275105,
- 0.9710676079044347,
- 0.9735231939498,
- 0.9758514437576309,
- 0.9780599066560445,
- 0.9801485715370128,
- 0.9821149805689633,
- 0.9839677526782791,
- 0.9857085499421516,
- 0.9873347811966005,
- 0.9888547171706613,
- 0.9902689443512227,
- 0.9915771042095881,
- 0.9927840651641069,
- 0.9938913963715834,
- 0.9948987305580712,
- 0.9958114963810524,
- 0.9966274782266875,
- 0.997352148697352,
- 0.9979848677523623,
- 0.9985285021374979,
- 0.9989844084453229,
- 0.9993537595844986,
- 0.999638729860106,
- 0.9998403888004533,
- 0.9999602810470701,
- 1.0
- ];
-}
diff --git a/packages/flutter/lib/src/widgets/text_selection.dart b/packages/flutter/lib/src/widgets/text_selection.dart
index 00fc689..a4b6737 100644
--- a/packages/flutter/lib/src/widgets/text_selection.dart
+++ b/packages/flutter/lib/src/widgets/text_selection.dart
@@ -1590,19 +1590,6 @@
&& renderEditable.selection!.end >= textPosition.offset;
}
- bool _tapWasOnSelection(Offset position) {
- if (renderEditable.selection == null) {
- return false;
- }
-
- final TextPosition textPosition = renderEditable.getPositionForPoint(
- position,
- );
-
- return renderEditable.selection!.start < textPosition.offset
- && renderEditable.selection!.end > textPosition.offset;
- }
-
// Expand the selection to the given global position.
//
// Either base or extent will be moved to the last tapped position, whichever
@@ -1833,7 +1820,6 @@
case TargetPlatform.linux:
case TargetPlatform.macOS:
case TargetPlatform.windows:
- editableText.hideToolbar();
// On desktop platforms the selection is set on tap down.
if (_isShiftTapping) {
_isShiftTapping = false;
@@ -1841,7 +1827,6 @@
break;
case TargetPlatform.android:
case TargetPlatform.fuchsia:
- editableText.hideToolbar();
if (isShiftPressedValid) {
_isShiftTapping = true;
_extendSelection(details.globalPosition, SelectionChangedCause.tap);
@@ -1875,16 +1860,7 @@
case PointerDeviceKind.touch:
case PointerDeviceKind.unknown:
// On iOS/iPadOS a touch tap places the cursor at the edge of the word.
- final TextSelection previousSelection = editableText.textEditingValue.selection;
- // If the tap was within the previous selection, then the selection should stay the same.
- if (!_tapWasOnSelection(details.globalPosition)) {
- renderEditable.selectWordEdge(cause: SelectionChangedCause.tap);
- }
- if (previousSelection == editableText.textEditingValue.selection && renderEditable.hasFocus) {
- editableText.toggleToolbar(false);
- } else {
- editableText.hideToolbar(false);
- }
+ renderEditable.selectWordEdge(cause: SelectionChangedCause.tap);
break;
}
break;
diff --git a/packages/flutter/test/cupertino/text_field_test.dart b/packages/flutter/test/cupertino/text_field_test.dart
index 0c5f574..51a9cce 100644
--- a/packages/flutter/test/cupertino/text_field_test.dart
+++ b/packages/flutter/test/cupertino/text_field_test.dart
@@ -1752,87 +1752,11 @@
expect(controller.selection.isCollapsed, isTrue);
expect(controller.selection.baseOffset, isTargetPlatformMobile ? 7 : 6);
- // Toolbar shows on mobile.
- expect(find.byType(CupertinoButton), isContextMenuProvidedByPlatform ? findsNothing : isTargetPlatformMobile ? findsNWidgets(2) : findsNothing);
+ // No toolbar.
+ expect(find.byType(CupertinoButton), findsNothing);
}, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }));
testWidgets(
- 'Tapping on a non-collapsed selection toggles the toolbar and retains the selection',
- (WidgetTester tester) async {
- final TextEditingController controller = TextEditingController(
- text: 'Atwater Peel Sherbrooke Bonaventure',
- );
- // On iOS/iPadOS, during a tap we select the edge of the word closest to the tap.
- await tester.pumpWidget(
- CupertinoApp(
- home: Center(
- child: CupertinoTextField(
- controller: controller,
- ),
- ),
- ),
- );
-
- final Offset vPos = textOffsetToPosition(tester, 29); // Index of 'Bonav|enture'.
- final Offset ePos = textOffsetToPosition(tester, 35) + const Offset(7.0, 0.0); // Index of 'Bonaventure|' + Offset(7.0,0), which taps slightly to the right of the end of the text.
- final Offset wPos = textOffsetToPosition(tester, 3); // Index of 'Atw|ater'.
-
- // This tap just puts the cursor somewhere different than where the double
- // tap will occur to test that the double tap moves the existing cursor first.
- await tester.tapAt(wPos);
- await tester.pump(const Duration(milliseconds: 500));
-
- await tester.tapAt(vPos);
- await tester.pump(const Duration(milliseconds: 50));
- // First tap moved the cursor.
- expect(controller.selection.isCollapsed, true);
- expect(
- controller.selection.baseOffset,
- 35,
- );
- await tester.tapAt(vPos);
- await tester.pumpAndSettle(const Duration(milliseconds: 500));
-
- // Second tap selects the word around the cursor.
- expect(
- controller.selection,
- const TextSelection(baseOffset: 24, extentOffset: 35),
- );
-
- // Selected text shows 3 toolbar buttons.
- expect(find.byType(CupertinoButton), isContextMenuProvidedByPlatform ? findsNothing : findsNWidgets(3));
-
- // Tap the selected word to hide the toolbar and retain the selection.
- await tester.tapAt(vPos);
- await tester.pumpAndSettle();
- expect(
- controller.selection,
- const TextSelection(baseOffset: 24, extentOffset: 35),
- );
- expect(find.byType(CupertinoButton), findsNothing);
-
- // Tap the selected word to show the toolbar and retain the selection.
- await tester.tapAt(vPos);
- await tester.pumpAndSettle();
- expect(
- controller.selection,
- const TextSelection(baseOffset: 24, extentOffset: 35),
- );
- expect(find.byType(CupertinoButton), isContextMenuProvidedByPlatform ? findsNothing : findsNWidgets(3));
-
- // Tap past the selected word to move the cursor and hide the toolbar.
- await tester.tapAt(ePos);
- await tester.pumpAndSettle();
- expect(
- controller.selection,
- const TextSelection.collapsed(offset: 35),
- );
- expect(find.byType(CupertinoButton), findsNothing);
- },
- variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS }),
- );
-
- testWidgets(
'double tap selects word and first tap of double tap moves cursor',
(WidgetTester tester) async {
final TextEditingController controller = TextEditingController(
@@ -2777,13 +2701,11 @@
// Double tap selecting the same word somewhere else is fine.
await tester.tapAt(textFieldStart + const Offset(100.0, 5.0));
await tester.pump(const Duration(milliseconds: 50));
- // First tap hides the toolbar, and retains the selection.
+ // First tap moved the cursor.
expect(
controller.selection,
- const TextSelection(baseOffset: 0, extentOffset: 7),
+ const TextSelection.collapsed(offset: 7, affinity: TextAffinity.upstream),
);
- expect(find.byType(CupertinoButton), findsNothing);
- // Second tap shows the toolbar, and retains the selection.
await tester.tapAt(textFieldStart + const Offset(100.0, 5.0));
await tester.pumpAndSettle();
expect(
@@ -2794,12 +2716,11 @@
await tester.tapAt(textFieldStart + const Offset(150.0, 5.0));
await tester.pump(const Duration(milliseconds: 50));
- // First tap moved the cursor and hides the toolbar.
+ // First tap moved the cursor.
expect(
controller.selection,
const TextSelection.collapsed(offset: 8),
);
- expect(find.byType(CupertinoButton), findsNothing);
await tester.tapAt(textFieldStart + const Offset(150.0, 5.0));
await tester.pumpAndSettle();
expect(
diff --git a/packages/flutter/test/material/back_button_test.dart b/packages/flutter/test/material/back_button_test.dart
index 09d9fd1..d4ff9a9 100644
--- a/packages/flutter/test/material/back_button_test.dart
+++ b/packages/flutter/test/material/back_button_test.dart
@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
@@ -153,21 +152,9 @@
tester.state<NavigatorState>(find.byType(Navigator)).pushNamed('/next');
await tester.pumpAndSettle();
- final String? expectedLabel;
- switch(defaultTargetPlatform) {
- case TargetPlatform.android:
- expectedLabel = 'Back';
- break;
- case TargetPlatform.fuchsia:
- case TargetPlatform.iOS:
- case TargetPlatform.linux:
- case TargetPlatform.macOS:
- case TargetPlatform.windows:
- expectedLabel = null;
- }
+
expect(tester.getSemantics(find.byType(BackButton)), matchesSemantics(
tooltip: 'Back',
- label: expectedLabel,
isButton: true,
hasEnabledState: true,
isEnabled: true,
@@ -175,51 +162,7 @@
isFocusable: true,
));
handle.dispose();
- }, variant: TargetPlatformVariant.all());
-
- testWidgets('CloseButton semantics', (WidgetTester tester) async {
- final SemanticsHandle handle = tester.ensureSemantics();
- await tester.pumpWidget(
- MaterialApp(
- home: const Material(child: Text('Home')),
- routes: <String, WidgetBuilder>{
- '/next': (BuildContext context) {
- return const Material(
- child: Center(
- child: CloseButton(),
- ),
- );
- },
- },
- ),
- );
-
- tester.state<NavigatorState>(find.byType(Navigator)).pushNamed('/next');
-
- await tester.pumpAndSettle();
- final String? expectedLabel;
- switch(defaultTargetPlatform) {
- case TargetPlatform.android:
- expectedLabel = 'Close';
- break;
- case TargetPlatform.fuchsia:
- case TargetPlatform.iOS:
- case TargetPlatform.linux:
- case TargetPlatform.macOS:
- case TargetPlatform.windows:
- expectedLabel = null;
- }
- expect(tester.getSemantics(find.byType(CloseButton)), matchesSemantics(
- tooltip: 'Close',
- label: expectedLabel,
- isButton: true,
- hasEnabledState: true,
- isEnabled: true,
- hasTapAction: true,
- isFocusable: true,
- ));
- handle.dispose();
- }, variant: TargetPlatformVariant.all());
+ });
testWidgets('CloseButton color', (WidgetTester tester) async {
await tester.pumpWidget(
diff --git a/packages/flutter/test/material/banner_theme_test.dart b/packages/flutter/test/material/banner_theme_test.dart
index db351f9..258966a 100644
--- a/packages/flutter/test/material/banner_theme_test.dart
+++ b/packages/flutter/test/material/banner_theme_test.dart
@@ -15,13 +15,7 @@
test('MaterialBannerThemeData null fields by default', () {
const MaterialBannerThemeData bannerTheme = MaterialBannerThemeData();
expect(bannerTheme.backgroundColor, null);
- expect(bannerTheme.surfaceTintColor, null);
- expect(bannerTheme.shadowColor, null);
- expect(bannerTheme.dividerColor, null);
expect(bannerTheme.contentTextStyle, null);
- expect(bannerTheme.elevation, null);
- expect(bannerTheme.padding, null);
- expect(bannerTheme.leadingPadding, null);
});
testWidgets('Default MaterialBannerThemeData debugFillProperties', (WidgetTester tester) async {
@@ -29,9 +23,9 @@
const MaterialBannerThemeData().debugFillProperties(builder);
final List<String> description = builder.properties
- .where((DiagnosticsNode node) => !node.isFiltered(DiagnosticLevel.info))
- .map((DiagnosticsNode node) => node.toString())
- .toList();
+ .where((DiagnosticsNode node) => !node.isFiltered(DiagnosticLevel.info))
+ .map((DiagnosticsNode node) => node.toString())
+ .toList();
expect(description, <String>[]);
});
@@ -39,43 +33,27 @@
testWidgets('MaterialBannerThemeData implements debugFillProperties', (WidgetTester tester) async {
final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder();
const MaterialBannerThemeData(
- backgroundColor: Color(0xfffffff0),
- surfaceTintColor: Color(0xfffffff1),
- shadowColor: Color(0xfffffff2),
- dividerColor: Color(0xfffffff3),
- contentTextStyle: TextStyle(color: Color(0xfffffff4)),
- elevation: 4.0,
- padding: EdgeInsets.all(20.0),
- leadingPadding: EdgeInsets.only(left: 8.0),
+ backgroundColor: Color(0xFFFFFFFF),
+ contentTextStyle: TextStyle(color: Color(0xFFFFFFFF)),
).debugFillProperties(builder);
final List<String> description = builder.properties
- .where((DiagnosticsNode node) => !node.isFiltered(DiagnosticLevel.info))
- .map((DiagnosticsNode node) => node.toString())
- .toList();
+ .where((DiagnosticsNode node) => !node.isFiltered(DiagnosticLevel.info))
+ .map((DiagnosticsNode node) => node.toString())
+ .toList();
expect(description, <String>[
- 'backgroundColor: Color(0xfffffff0)',
- 'surfaceTintColor: Color(0xfffffff1)',
- 'shadowColor: Color(0xfffffff2)',
- 'dividerColor: Color(0xfffffff3)',
- 'contentTextStyle: TextStyle(inherit: true, color: Color(0xfffffff4))',
- 'elevation: 4.0',
- 'padding: EdgeInsets.all(20.0)',
- 'leadingPadding: EdgeInsets(8.0, 0.0, 0.0, 0.0)',
+ 'backgroundColor: Color(0xffffffff)',
+ 'contentTextStyle: TextStyle(inherit: true, color: Color(0xffffffff))',
]);
});
testWidgets('Passing no MaterialBannerThemeData returns defaults', (WidgetTester tester) async {
- final ThemeData theme = ThemeData();
const String contentText = 'Content';
-
await tester.pumpWidget(MaterialApp(
- theme: ThemeData(useMaterial3: true),
home: Scaffold(
body: MaterialBanner(
content: const Text(contentText),
- leading: const Icon(Icons.umbrella),
actions: <Widget>[
TextButton(
child: const Text('Action'),
@@ -87,39 +65,16 @@
));
final Material material = _getMaterialFromText(tester, contentText);
- expect(material.color, const Color(0xffffffff));
- expect(material.surfaceTintColor, theme.colorScheme.surfaceTint);
- expect(material.shadowColor, null);
- expect(material.elevation, 0.0);
-
final RenderParagraph content = _getTextRenderObjectFromDialog(tester, contentText);
- // Default value for ThemeData.typography is Typography.material2021()
- expect(
- content.text.style,
- Typography.material2021().englishLike.bodyMedium!.merge(
- Typography.material2021().black.bodyMedium,
- ),
- );
-
- final Offset rowTopLeft = tester.getTopLeft(find.byType(Row));
- final Offset materialTopLeft = tester.getTopLeft(_materialFinder());
- final Offset leadingTopLeft = tester.getTopLeft(find.byIcon(Icons.umbrella));
- expect(rowTopLeft.dy - materialTopLeft.dy, 2.0); // Default single line top padding.
- expect(rowTopLeft.dx - materialTopLeft.dx, 16.0); // Default single line start padding.
- expect(leadingTopLeft.dy - materialTopLeft.dy, 16); // Default leading padding.
- expect(leadingTopLeft.dx - materialTopLeft.dx, 16); // Default leading padding.
-
- final Divider divider = tester.widget<Divider>(find.byType(Divider));
- expect(divider.color, theme.colorScheme.surfaceVariant);
+ expect(material.color, const Color(0xffffffff));
+ // Default value for ThemeData.typography is Typography.material2014()
+ expect(content.text.style, Typography.material2014().englishLike.bodyMedium!.merge(Typography.material2014().black.bodyMedium));
});
testWidgets('Passing no MaterialBannerThemeData returns defaults when presented by ScaffoldMessenger', (WidgetTester tester) async {
- final ThemeData theme = ThemeData();
const String contentText = 'Content';
const Key tapTarget = Key('tap-target');
-
await tester.pumpWidget(MaterialApp(
- theme: ThemeData(useMaterial3: true),
home: Scaffold(
body: Builder(
builder: (BuildContext context) {
@@ -128,7 +83,6 @@
onTap: () {
ScaffoldMessenger.of(context).showMaterialBanner(MaterialBanner(
content: const Text(contentText),
- leading: const Icon(Icons.umbrella),
actions: <Widget>[
TextButton(
child: const Text('Action'),
@@ -151,30 +105,10 @@
await tester.pumpAndSettle();
final Material material = _getMaterialFromText(tester, contentText);
- expect(material.color, const Color(0xffffffff));
- expect(material.surfaceTintColor, theme.colorScheme.surfaceTint);
- expect(material.shadowColor, null);
- expect(material.elevation, 0.0);
-
final RenderParagraph content = _getTextRenderObjectFromDialog(tester, contentText);
- // Default value for ThemeData.typography is Typography.material2021()
- expect(
- content.text.style,
- Typography.material2021().englishLike.bodyMedium!.merge(
- Typography.material2021().black.bodyMedium,
- ),
- );
-
- final Offset rowTopLeft = tester.getTopLeft(find.byType(Row));
- final Offset materialTopLeft = tester.getTopLeft(_materialFinder());
- final Offset leadingTopLeft = tester.getTopLeft(find.byIcon(Icons.umbrella));
- expect(rowTopLeft.dy - materialTopLeft.dy, 2.0); // Default single line top padding.
- expect(rowTopLeft.dx - materialTopLeft.dx, 16.0); // Default single line start padding.
- expect(leadingTopLeft.dy - materialTopLeft.dy, 16); // Default leading padding.
- expect(leadingTopLeft.dx - materialTopLeft.dx, 16); // Default leading padding.
-
- final Divider divider = tester.widget<Divider>(find.byType(Divider));
- expect(divider.color, theme.colorScheme.surfaceVariant);
+ expect(material.color, const Color(0xffffffff));
+ // Default value for ThemeData.typography is Typography.material2014()
+ expect(content.text.style, Typography.material2014().englishLike.bodyMedium!.merge(Typography.material2014().black.bodyMedium));
});
testWidgets('MaterialBanner uses values from MaterialBannerThemeData', (WidgetTester tester) async {
@@ -197,12 +131,8 @@
));
final Material material = _getMaterialFromText(tester, contentText);
- expect(material.color, bannerTheme.backgroundColor);
- expect(material.surfaceTintColor, bannerTheme.surfaceTintColor);
- expect(material.shadowColor, bannerTheme.shadowColor);
- expect(material.elevation, bannerTheme.elevation);
-
final RenderParagraph content = _getTextRenderObjectFromDialog(tester, contentText);
+ expect(material.color, bannerTheme.backgroundColor);
expect(content.text.style, bannerTheme.contentTextStyle);
final Offset contentTopLeft = tester.getTopLeft(_textFinder(contentText));
@@ -212,8 +142,6 @@
expect(contentTopLeft.dx - materialTopLeft.dx, 41);
expect(leadingTopLeft.dy - materialTopLeft.dy, 19);
expect(leadingTopLeft.dx - materialTopLeft.dx, 11);
-
- expect(find.byType(Divider), findsNothing);
});
testWidgets('MaterialBanner uses values from MaterialBannerThemeData when presented by ScaffoldMessenger', (WidgetTester tester) async {
@@ -253,12 +181,8 @@
await tester.pumpAndSettle();
final Material material = _getMaterialFromText(tester, contentText);
- expect(material.color, bannerTheme.backgroundColor);
- expect(material.surfaceTintColor, bannerTheme.surfaceTintColor);
- expect(material.shadowColor, bannerTheme.shadowColor);
- expect(material.elevation, bannerTheme.elevation);
-
final RenderParagraph content = _getTextRenderObjectFromDialog(tester, contentText);
+ expect(material.color, bannerTheme.backgroundColor);
expect(content.text.style, bannerTheme.contentTextStyle);
final Offset contentTopLeft = tester.getTopLeft(_textFinder(contentText));
@@ -268,26 +192,18 @@
expect(contentTopLeft.dx - materialTopLeft.dx, 41);
expect(leadingTopLeft.dy - materialTopLeft.dy, 19);
expect(leadingTopLeft.dx - materialTopLeft.dx, 11);
-
- expect(find.byType(Divider), findsNothing);
});
testWidgets('MaterialBanner widget properties take priority over theme', (WidgetTester tester) async {
const Color backgroundColor = Colors.purple;
- const Color surfaceTintColor = Colors.red;
- const Color shadowColor = Colors.orange;
const TextStyle textStyle = TextStyle(color: Colors.green);
final MaterialBannerThemeData bannerTheme = _bannerTheme();
const String contentText = 'Content';
-
await tester.pumpWidget(MaterialApp(
theme: ThemeData(bannerTheme: bannerTheme),
home: Scaffold(
body: MaterialBanner(
backgroundColor: backgroundColor,
- surfaceTintColor: surfaceTintColor,
- shadowColor: shadowColor,
- elevation: 6.0,
leading: const Icon(Icons.ac_unit),
contentTextStyle: textStyle,
content: const Text(contentText),
@@ -304,12 +220,8 @@
));
final Material material = _getMaterialFromText(tester, contentText);
- expect(material.color, backgroundColor);
- expect(material.surfaceTintColor, surfaceTintColor);
- expect(material.shadowColor, shadowColor);
- expect(material.elevation, 6.0);
-
final RenderParagraph content = _getTextRenderObjectFromDialog(tester, contentText);
+ expect(material.color, backgroundColor);
expect(content.text.style, textStyle);
final Offset contentTopLeft = tester.getTopLeft(_textFinder(contentText));
@@ -319,18 +231,14 @@
expect(contentTopLeft.dx - materialTopLeft.dx, 58);
expect(leadingTopLeft.dy - materialTopLeft.dy, 24);
expect(leadingTopLeft.dx - materialTopLeft.dx, 22);
-
- expect(find.byType(Divider), findsNothing);
});
testWidgets('MaterialBanner widget properties take priority over theme when presented by ScaffoldMessenger', (WidgetTester tester) async {
const Color backgroundColor = Colors.purple;
- const double elevation = 6.0;
const TextStyle textStyle = TextStyle(color: Colors.green);
final MaterialBannerThemeData bannerTheme = _bannerTheme();
const String contentText = 'Content';
const Key tapTarget = Key('tap-target');
-
await tester.pumpWidget(MaterialApp(
theme: ThemeData(bannerTheme: bannerTheme),
home: Scaffold(
@@ -341,7 +249,6 @@
onTap: () {
ScaffoldMessenger.of(context).showMaterialBanner(MaterialBanner(
backgroundColor: backgroundColor,
- elevation: elevation,
leading: const Icon(Icons.ac_unit),
contentTextStyle: textStyle,
content: const Text(contentText),
@@ -369,10 +276,8 @@
await tester.pumpAndSettle();
final Material material = _getMaterialFromText(tester, contentText);
- expect(material.color, backgroundColor);
- expect(material.elevation, elevation);
-
final RenderParagraph content = _getTextRenderObjectFromDialog(tester, contentText);
+ expect(material.color, backgroundColor);
expect(content.text.style, textStyle);
final Offset contentTopLeft = tester.getTopLeft(_textFinder(contentText));
@@ -382,8 +287,6 @@
expect(contentTopLeft.dx - materialTopLeft.dx, 58);
expect(leadingTopLeft.dy - materialTopLeft.dy, 24);
expect(leadingTopLeft.dx - materialTopLeft.dx, 22);
-
- expect(find.byType(Divider), findsNothing);
});
testWidgets('MaterialBanner uses color scheme when necessary', (WidgetTester tester) async {
@@ -446,130 +349,12 @@
final Material material = _getMaterialFromText(tester, contentText);
expect(material.color, colorScheme.surface);
});
-
- group('Material 2', () {
- // Tests that are only relevant for Material 2. Once ThemeData.useMaterial3
- // is turned on by default, these tests can be removed.
-
- testWidgets('Passing no MaterialBannerThemeData returns defaults', (WidgetTester tester) async {
- final ThemeData theme = ThemeData();
- const String contentText = 'Content';
-
- await tester.pumpWidget(MaterialApp(
- home: Scaffold(
- body: MaterialBanner(
- content: const Text(contentText),
- leading: const Icon(Icons.umbrella),
- actions: <Widget>[
- TextButton(
- child: const Text('Action'),
- onPressed: () { },
- ),
- ],
- ),
- ),
- ));
-
- final Material material = _getMaterialFromText(tester, contentText);
- expect(material.color, const Color(0xffffffff));
- expect(material.surfaceTintColor, null);
- expect(material.shadowColor, null);
- expect(material.elevation, 0.0);
-
- final RenderParagraph content = _getTextRenderObjectFromDialog(tester, contentText);
- // Default value for ThemeData.typography is Typography.material2014()
- expect(
- content.text.style,
- Typography.material2014().englishLike.bodyText2!.merge(
- Typography.material2014().black.bodyText2,
- ),
- );
-
- final Offset rowTopLeft = tester.getTopLeft(find.byType(Row));
- final Offset materialTopLeft = tester.getTopLeft(_materialFinder());
- final Offset leadingTopLeft = tester.getTopLeft(find.byIcon(Icons.umbrella));
- expect(rowTopLeft.dy - materialTopLeft.dy, 2.0); // Default single line top padding.
- expect(rowTopLeft.dx - materialTopLeft.dx, 16.0); // Default single line start padding.
- expect(leadingTopLeft.dy - materialTopLeft.dy, 16); // Default leading padding.
- expect(leadingTopLeft.dx - materialTopLeft.dx, 16); // Default leading padding.
-
- final Divider divider = tester.widget<Divider>(find.byType(Divider));
- expect(divider.color, theme.colorScheme.surfaceVariant);
- });
-
- testWidgets('Passing no MaterialBannerThemeData returns defaults when presented by ScaffoldMessenger', (WidgetTester tester) async {
- final ThemeData theme = ThemeData();
- const String contentText = 'Content';
- const Key tapTarget = Key('tap-target');
-
- await tester.pumpWidget(MaterialApp(
- home: Scaffold(
- body: Builder(
- builder: (BuildContext context) {
- return GestureDetector(
- key: tapTarget,
- onTap: () {
- ScaffoldMessenger.of(context).showMaterialBanner(MaterialBanner(
- content: const Text(contentText),
- leading: const Icon(Icons.umbrella),
- actions: <Widget>[
- TextButton(
- child: const Text('Action'),
- onPressed: () { },
- ),
- ],
- ));
- },
- behavior: HitTestBehavior.opaque,
- child: const SizedBox(
- height: 100.0,
- width: 100.0,
- ),
- );
- },
- ),
- ),
- ));
- await tester.tap(find.byKey(tapTarget));
- await tester.pumpAndSettle();
-
- final Material material = _getMaterialFromText(tester, contentText);
- expect(material.color, const Color(0xffffffff));
- expect(material.surfaceTintColor, null);
- expect(material.shadowColor, null);
- expect(material.elevation, 0.0);
-
- final RenderParagraph content = _getTextRenderObjectFromDialog(tester, contentText);
- // Default value for ThemeData.typography is Typography.material2014()
- expect(
- content.text.style,
- Typography.material2014().englishLike.bodyText2!.merge(
- Typography.material2014().black.bodyText2,
- ),
- );
-
- final Offset rowTopLeft = tester.getTopLeft(find.byType(Row));
- final Offset materialTopLeft = tester.getTopLeft(_materialFinder());
- final Offset leadingTopLeft = tester.getTopLeft(find.byIcon(Icons.umbrella));
- expect(rowTopLeft.dy - materialTopLeft.dy, 2.0); // Default single line top padding.
- expect(rowTopLeft.dx - materialTopLeft.dx, 16.0); // Default single line start padding.
- expect(leadingTopLeft.dy - materialTopLeft.dy, 16); // Default leading padding.
- expect(leadingTopLeft.dx - materialTopLeft.dx, 16); // Default leading padding.
-
- final Divider divider = tester.widget<Divider>(find.byType(Divider));
- expect(divider.color, theme.colorScheme.surfaceVariant);
- });
- });
}
MaterialBannerThemeData _bannerTheme() {
return const MaterialBannerThemeData(
backgroundColor: Colors.orange,
- surfaceTintColor: Colors.yellow,
- shadowColor: Colors.red,
- dividerColor: Colors.green,
contentTextStyle: TextStyle(color: Colors.pink),
- elevation: 4.0,
padding: EdgeInsets.all(5),
leadingPadding: EdgeInsets.all(6),
);
diff --git a/packages/flutter/test/material/text_field_test.dart b/packages/flutter/test/material/text_field_test.dart
index 7f6d614..cef5992 100644
--- a/packages/flutter/test/material/text_field_test.dart
+++ b/packages/flutter/test/material/text_field_test.dart
@@ -7551,91 +7551,13 @@
expect(controller.selection.isCollapsed, isTrue);
expect(controller.selection.baseOffset, isTargetPlatformMobile ? 7 : 6);
- // Toolbar shows on iOS.
- expect(find.byType(CupertinoButton), isContextMenuProvidedByPlatform ? findsNothing : isTargetPlatformMobile ? findsNWidgets(2) : findsNothing);
+ // No toolbar.
+ expect(find.byType(CupertinoButton), findsNothing);
},
variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }),
);
testWidgets(
- 'Tapping on a non-collapsed selection toggles the toolbar and retains the selection',
- (WidgetTester tester) async {
- final TextEditingController controller = TextEditingController(
- text: 'Atwater Peel Sherbrooke Bonaventure',
- );
- // On iOS/iPadOS, during a tap we select the edge of the word closest to the tap.
- await tester.pumpWidget(
- MaterialApp(
- home: Material(
- child: Center(
- child: TextField(
- controller: controller,
- ),
- ),
- ),
- ),
- );
-
- final Offset vPos = textOffsetToPosition(tester, 29); // Index of 'Bonav|enture'.
- final Offset ePos = textOffsetToPosition(tester, 35) + const Offset(7.0, 0.0); // Index of 'Bonaventure|' + Offset(7.0,0), which taps slightly to the right of the end of the text.
- final Offset wPos = textOffsetToPosition(tester, 3); // Index of 'Atw|ater'.
-
- // This tap just puts the cursor somewhere different than where the double
- // tap will occur to test that the double tap moves the existing cursor first.
- await tester.tapAt(wPos);
- await tester.pump(const Duration(milliseconds: 500));
-
- await tester.tapAt(vPos);
- await tester.pump(const Duration(milliseconds: 50));
- // First tap moved the cursor.
- expect(controller.selection.isCollapsed, true);
- expect(
- controller.selection.baseOffset,
- 35,
- );
- await tester.tapAt(vPos);
- await tester.pumpAndSettle(const Duration(milliseconds: 500));
-
- // Second tap selects the word around the cursor.
- expect(
- controller.selection,
- const TextSelection(baseOffset: 24, extentOffset: 35),
- );
-
- // Selected text shows 3 toolbar buttons.
- expect(find.byType(CupertinoButton), isContextMenuProvidedByPlatform ? findsNothing : findsNWidgets(3));
-
- // Tap the selected word to hide the toolbar and retain the selection.
- await tester.tapAt(vPos);
- await tester.pumpAndSettle();
- expect(
- controller.selection,
- const TextSelection(baseOffset: 24, extentOffset: 35),
- );
- expect(find.byType(CupertinoButton), findsNothing);
-
- // Tap the selected word to show the toolbar and retain the selection.
- await tester.tapAt(vPos);
- await tester.pumpAndSettle();
- expect(
- controller.selection,
- const TextSelection(baseOffset: 24, extentOffset: 35),
- );
- expect(find.byType(CupertinoButton), isContextMenuProvidedByPlatform ? findsNothing : findsNWidgets(3));
-
- // Tap past the selected word to move the cursor and hide the toolbar.
- await tester.tapAt(ePos);
- await tester.pumpAndSettle();
- expect(
- controller.selection,
- const TextSelection.collapsed(offset: 35),
- );
- expect(find.byType(CupertinoButton), findsNothing);
- },
- variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS }),
- );
-
- testWidgets(
'double tap selects word and first tap of double tap moves cursor',
(WidgetTester tester) async {
final TextEditingController controller = TextEditingController(
@@ -9023,13 +8945,11 @@
// Double tap selecting the same word somewhere else is fine.
await tester.tapAt(textfieldStart + const Offset(100.0, 9.0));
await tester.pump(const Duration(milliseconds: 50));
- // First tap hides the toolbar and retains the selection.
+ // First tap moved the cursor.
expect(
controller.selection,
- const TextSelection(baseOffset: 0, extentOffset: 7),
+ const TextSelection.collapsed(offset: 7, affinity: TextAffinity.upstream),
);
- expect(find.byType(CupertinoButton), findsNothing);
- // Second tap shows the toolbar and retains the selection.
await tester.tapAt(textfieldStart + const Offset(100.0, 9.0));
await tester.pumpAndSettle();
expect(
@@ -9040,12 +8960,11 @@
await tester.tapAt(textfieldStart + const Offset(150.0, 9.0));
await tester.pump(const Duration(milliseconds: 50));
- // First tap moved the cursor and hides the toolbar.
+ // First tap moved the cursor.
expect(
controller.selection,
const TextSelection.collapsed(offset: 8),
);
- expect(find.byType(CupertinoButton), findsNothing);
await tester.tapAt(textfieldStart + const Offset(150.0, 9.0));
await tester.pumpAndSettle();
expect(
diff --git a/packages/flutter/test/widgets/scroll_activity_test.dart b/packages/flutter/test/widgets/scroll_activity_test.dart
index 673e4af..f6dd323 100644
--- a/packages/flutter/test/widgets/scroll_activity_test.dart
+++ b/packages/flutter/test/widgets/scroll_activity_test.dart
@@ -129,64 +129,6 @@
expect(find.text('Page 9'), findsOneWidget);
});
- List<Widget> childrenSizeIncrease(int n) {
- return List<Widget>.generate(n, (int i) {
- return SizedBox(height: 40.0 + i * 3, child: Text('$i'));
- });
- }
-
- testWidgets('Check for duplicate pixels with ClampingScrollPhysics', (WidgetTester tester) async {
- final List<double> scrollSimulationXList = <double>[];
- final TestScrollPhysics testScrollPhysics = TestScrollPhysics(
- scrollSimulationXList,
- parent: const ClampingScrollPhysics(),
- );
- await tester.pumpWidget(
- MaterialApp(
- home: ListView(
- physics: testScrollPhysics,
- children: childrenSizeIncrease(100),
- ),
- ),
- );
- await tester.fling(find.byType(ListView), const Offset(0.0, -4000.0), 4000.0);
- await tester.pumpAndSettle();
- final Set<double> checkSet = <double>{};
- checkSet.addAll(scrollSimulationXList);
- /// checkSet.length + 1 is because:
- /// simulation.x(0.0) will be called in _startSimulation.
- /// The first frame of the animation will also call simulation.x(0.0).
- /// It can be tolerated that it has at most one duplicate value.
- final bool hasOnlyOneDuplicate = scrollSimulationXList.length == checkSet.length + 1;
- expect(true, hasOnlyOneDuplicate); // and ends up at the end
- });
-
- testWidgets('Check for duplicate pixels with BouncingScrollPhysics', (WidgetTester tester) async {
- final List<double> scrollSimulationXList = <double>[];
- final TestScrollPhysics testScrollPhysics = TestScrollPhysics(
- scrollSimulationXList,
- parent: const BouncingScrollPhysics(),
- );
- await tester.pumpWidget(
- MaterialApp(
- home: ListView(
- physics: testScrollPhysics,
- children: childrenSizeIncrease(100),
- ),
- ),
- );
- await tester.fling(find.byType(ListView), const Offset(0.0, -4000.0), 4000.0);
- await tester.pumpAndSettle();
- final Set<double> checkSet = <double>{};
- checkSet.addAll(scrollSimulationXList);
- /// checkSet.length + 1 is because:
- /// simulation.x(0.0) will be call in _startSimulation.
- /// The first frame of the animation will also call simulation.x(0.0).
- /// It can be tolerated that it has at most one duplicate value.
- final bool noDuplicate = scrollSimulationXList.length == checkSet.length + 1;
- expect(true, noDuplicate); // and ends up at the end
- });
-
testWidgets('Pointer is not ignored during trackpad scrolling.', (WidgetTester tester) async {
final ScrollController controller = ScrollController();
int? lastTapped;
@@ -268,62 +210,6 @@
});
}
-class TestScrollPhysics extends ScrollPhysics {
- const TestScrollPhysics(this.scrollSimulationXList, { super.parent });
-
- final List<double> scrollSimulationXList;
-
- @override
- Simulation? createBallisticSimulation(
- ScrollMetrics position,
- double velocity,
- ) {
- final Simulation? scrollSimulation = super.createBallisticSimulation(
- position,
- velocity,
- );
- if (scrollSimulation != null && scrollSimulationXList != null) {
- return TestScrollScrollSimulation(
- scrollSimulation,
- scrollSimulationXList,
- );
- }
- return scrollSimulation;
- }
-
- @override
- TestScrollPhysics applyTo(ScrollPhysics? ancestor) {
- return TestScrollPhysics(
- scrollSimulationXList,
- parent: buildParent(ancestor),
- );
- }
-}
-
-class TestScrollScrollSimulation extends Simulation {
- TestScrollScrollSimulation(this.innerScrollSimulation,
- this.scrollSimulationXList,);
-
- final Simulation innerScrollSimulation;
-
- final List<double> scrollSimulationXList;
-
- @override
- double dx(double time) => innerScrollSimulation.dx(time);
-
- @override
- bool isDone(double time) => innerScrollSimulation.isDone(time);
-
- @override
- double x(double time) {
- final double simulationX = innerScrollSimulation.x(time);
- if (scrollSimulationXList != null) {
- scrollSimulationXList.add(simulationX);
- }
- return simulationX;
- }
-}
-
class PageView62209 extends StatefulWidget {
const PageView62209({super.key});
diff --git a/packages/flutter/test/widgets/scroll_simulation_test.dart b/packages/flutter/test/widgets/scroll_simulation_test.dart
index 99738be..69958f9 100644
--- a/packages/flutter/test/widgets/scroll_simulation_test.dart
+++ b/packages/flutter/test/widgets/scroll_simulation_test.dart
@@ -23,21 +23,4 @@
checkInitialConditions(75.0, 614.2093);
checkInitialConditions(5469.0, 182.114534);
});
-
- test('ClampingScrollSimulation velocity eventually reaches zero', () {
- void checkFinalConditions(double position, double velocity) {
- final ClampingScrollSimulation simulation = ClampingScrollSimulation(position: position, velocity: velocity);
- expect(simulation.dx(10.0), equals(0.0));
- }
-
- checkFinalConditions(51.0, 2000.0);
- checkFinalConditions(584.0, 2617.294734);
- checkFinalConditions(345.0, 1982.785934);
- checkFinalConditions(0.0, 1831.366634);
- checkFinalConditions(-156.2, 1541.57665);
- checkFinalConditions(4.0, 1139.250439);
- checkFinalConditions(4534.0, 1073.553798);
- checkFinalConditions(75.0, 614.2093);
- checkFinalConditions(5469.0, 182.114534);
- });
}
diff --git a/packages/flutter/test/widgets/scrollable_fling_test.dart b/packages/flutter/test/widgets/scrollable_fling_test.dart
index bb20cca..1d34b11 100644
--- a/packages/flutter/test/widgets/scrollable_fling_test.dart
+++ b/packages/flutter/test/widgets/scrollable_fling_test.dart
@@ -48,7 +48,7 @@
// Before changing these values, ensure the fling results in a distance that
// makes sense. See issue for more context.
expect(androidResult, greaterThan(394.0));
- expect(androidResult, lessThan(408.2));
+ expect(androidResult, lessThan(395.0));
await pumpTest(tester, TargetPlatform.linux);
await tester.fling(find.byType(ListView), const Offset(0.0, -dragOffset), 1000.0);
@@ -152,6 +152,6 @@
expect(log, equals(<String>['tap 21']));
await tester.tap(find.byType(Scrollable));
await tester.pump(const Duration(milliseconds: 50));
- expect(log, equals(<String>['tap 21', 'tap 49']));
+ expect(log, equals(<String>['tap 21', 'tap 48']));
});
}
diff --git a/packages/flutter/test/widgets/scrollable_semantics_test.dart b/packages/flutter/test/widgets/scrollable_semantics_test.dart
index 5307fc7..1c8f7ea 100644
--- a/packages/flutter/test/widgets/scrollable_semantics_test.dart
+++ b/packages/flutter/test/widgets/scrollable_semantics_test.dart
@@ -231,7 +231,7 @@
expect(semantics, includesNodeWith(
scrollExtentMin: 0.0,
- scrollPosition: 394.3,
+ scrollPosition: 380.2,
scrollExtentMax: 520.0,
actions: <SemanticsAction>[
SemanticsAction.scrollUp,
@@ -280,7 +280,7 @@
expect(semantics, includesNodeWith(
scrollExtentMin: 0.0,
- scrollPosition: 394.3,
+ scrollPosition: 380.2,
scrollExtentMax: double.infinity,
actions: <SemanticsAction>[
SemanticsAction.scrollUp,
@@ -292,7 +292,7 @@
expect(semantics, includesNodeWith(
scrollExtentMin: 0.0,
- scrollPosition: 788.6,
+ scrollPosition: 760.4,
scrollExtentMax: double.infinity,
actions: <SemanticsAction>[
SemanticsAction.scrollUp,
diff --git a/packages/flutter/test/widgets/scrollable_test.dart b/packages/flutter/test/widgets/scrollable_test.dart
index 1a27651..6cdea4f 100644
--- a/packages/flutter/test/widgets/scrollable_test.dart
+++ b/packages/flutter/test/widgets/scrollable_test.dart
@@ -946,8 +946,8 @@
expect(find.byKey(const ValueKey<String>('Box 0')), findsNothing);
expect(find.byKey(const ValueKey<String>('Box 52')), findsOneWidget);
- expect(expensiveWidgets, 40);
- expect(cheapWidgets, 21);
+ expect(expensiveWidgets, 38);
+ expect(cheapWidgets, 20);
});
testWidgets('Can recommendDeferredLoadingForContext - override heuristic', (WidgetTester tester) async {
@@ -989,9 +989,9 @@
expect(find.byKey(const ValueKey<String>('Box 0')), findsNothing);
expect(find.byKey(const ValueKey<String>('Cheap box 52')), findsOneWidget);
- expect(expensiveWidgets, 17);
- expect(cheapWidgets, 44);
- expect(physics.count, 44 + 17);
+ expect(expensiveWidgets, 18);
+ expect(cheapWidgets, 40);
+ expect(physics.count, 40 + 18);
});
testWidgets('Can recommendDeferredLoadingForContext - override heuristic and always return true', (WidgetTester tester) async {
@@ -1032,7 +1032,7 @@
expect(find.byKey(const ValueKey<String>('Cheap box 52')), findsOneWidget);
expect(expensiveWidgets, 0);
- expect(cheapWidgets, 61);
+ expect(cheapWidgets, 58);
});
testWidgets('ensureVisible does not move PageViews', (WidgetTester tester) async {
@@ -1439,9 +1439,9 @@
await tester.sendEventToBinding(testPointer.hover(tester.getCenter(find.byType(Scrollable))));
await tester.sendEventToBinding(testPointer.scrollInertiaCancel()); // Cancel partway through.
await tester.pump();
- expect(getScrollOffset(tester), closeTo(342.5439, 0.0001));
+ expect(getScrollOffset(tester), closeTo(333.2944, 0.0001));
await tester.pump(const Duration(milliseconds: 4800));
- expect(getScrollOffset(tester), closeTo(342.5439, 0.0001));
+ expect(getScrollOffset(tester), closeTo(333.2944, 0.0001));
});
}
diff --git a/packages/flutter/test/widgets/slivers_appbar_floating_pinned_test.dart b/packages/flutter/test/widgets/slivers_appbar_floating_pinned_test.dart
index 7ce6842..5306450 100644
--- a/packages/flutter/test/widgets/slivers_appbar_floating_pinned_test.dart
+++ b/packages/flutter/test/widgets/slivers_appbar_floating_pinned_test.dart
@@ -151,7 +151,7 @@
);
expect(semantics, hasSemantics(expectedSemantics, ignoreTransform: true, ignoreId: true, ignoreRect: true));
- await tester.fling(find.text('Tile 2'), const Offset(0, -600), 1950);
+ await tester.fling(find.text('Tile 2'), const Offset(0, -600), 2000);
await tester.pumpAndSettle();
expectedSemantics = TestSemantics.root(
diff --git a/packages/flutter/test/widgets/text_selection_test.dart b/packages/flutter/test/widgets/text_selection_test.dart
index 746f6c7..09980cd 100644
--- a/packages/flutter/test/widgets/text_selection_test.dart
+++ b/packages/flutter/test/widgets/text_selection_test.dart
@@ -569,38 +569,6 @@
}
}, variant: TargetPlatformVariant.all());
- testWidgets('test TextSelectionGestureDetectorBuilder toggles toolbar on single tap on previous selection iOS', (WidgetTester tester) async {
- await pumpTextSelectionGestureDetectorBuilder(tester);
-
- final FakeEditableTextState state = tester.state(find.byType(FakeEditableText));
- final FakeRenderEditable renderEditable = tester.renderObject(find.byType(FakeEditable));
- expect(state.showToolbarCalled, isFalse);
- expect(state.toggleToolbarCalled, isFalse);
- renderEditable.selection = const TextSelection(baseOffset: 2, extentOffset: 6);
- renderEditable.hasFocus = true;
-
- final TestGesture gesture = await tester.startGesture(
- const Offset(25.0, 200.0),
- pointer: 0,
- );
- await gesture.up();
- await tester.pumpAndSettle();
-
- switch (defaultTargetPlatform) {
- case TargetPlatform.iOS:
- expect(renderEditable.selectWordEdgeCalled, isFalse);
- expect(state.toggleToolbarCalled, isTrue);
- break;
- case TargetPlatform.macOS:
- case TargetPlatform.android:
- case TargetPlatform.fuchsia:
- case TargetPlatform.linux:
- case TargetPlatform.windows:
- expect(renderEditable.selectPositionAtCalled, isTrue);
- break;
- }
- }, variant: TargetPlatformVariant.all());
-
testWidgets('test TextSelectionGestureDetectorBuilder double tap', (WidgetTester tester) async {
await pumpTextSelectionGestureDetectorBuilder(tester);
final TestGesture gesture = await tester.startGesture(
@@ -1365,7 +1333,6 @@
class FakeEditableTextState extends EditableTextState {
final GlobalKey _editableKey = GlobalKey();
bool showToolbarCalled = false;
- bool toggleToolbarCalled = false;
@override
RenderEditable get renderEditable => _editableKey.currentContext!.findRenderObject()! as RenderEditable;
@@ -1377,8 +1344,7 @@
}
@override
- void toggleToolbar([bool hideHandles = true]) {
- toggleToolbarCalled = true;
+ void toggleToolbar() {
return;
}