Unverified Commit 7ce88694 authored by Kate Lovett's avatar Kate Lovett Committed by GitHub

Clean up scrollable.dart for 2D (#122357)

Clean up scrollable.dart for 2D
parent 670f9d20
...@@ -23,7 +23,7 @@ import 'pages.dart'; ...@@ -23,7 +23,7 @@ import 'pages.dart';
import 'performance_overlay.dart'; import 'performance_overlay.dart';
import 'restoration.dart'; import 'restoration.dart';
import 'router.dart'; import 'router.dart';
import 'scrollable.dart'; import 'scrollable_helpers.dart';
import 'semantics_debugger.dart'; import 'semantics_debugger.dart';
import 'shared_app_data.dart'; import 'shared_app_data.dart';
import 'shortcuts.dart'; import 'shortcuts.dart';
......
...@@ -9,7 +9,7 @@ import 'package:flutter/services.dart'; ...@@ -9,7 +9,7 @@ import 'package:flutter/services.dart';
import 'actions.dart'; import 'actions.dart';
import 'focus_traversal.dart'; import 'focus_traversal.dart';
import 'framework.dart'; import 'framework.dart';
import 'scrollable.dart'; import 'scrollable_helpers.dart';
import 'shortcuts.dart'; import 'shortcuts.dart';
import 'text_editing_intents.dart'; import 'text_editing_intents.dart';
......
...@@ -35,6 +35,7 @@ import 'scroll_controller.dart'; ...@@ -35,6 +35,7 @@ import 'scroll_controller.dart';
import 'scroll_physics.dart'; import 'scroll_physics.dart';
import 'scroll_position.dart'; import 'scroll_position.dart';
import 'scrollable.dart'; import 'scrollable.dart';
import 'scrollable_helpers.dart';
import 'shortcuts.dart'; import 'shortcuts.dart';
import 'spell_check.dart'; import 'spell_check.dart';
import 'tap_region.dart'; import 'tap_region.dart';
......
...@@ -16,6 +16,7 @@ import 'scroll_controller.dart'; ...@@ -16,6 +16,7 @@ import 'scroll_controller.dart';
import 'scroll_physics.dart'; import 'scroll_physics.dart';
import 'scroll_view.dart'; import 'scroll_view.dart';
import 'scrollable.dart'; import 'scrollable.dart';
import 'scrollable_helpers.dart';
import 'sliver.dart'; import 'sliver.dart';
import 'sliver_prototype_extent_list.dart'; import 'sliver_prototype_extent_list.dart';
import 'ticker_provider.dart'; import 'ticker_provider.dart';
......
...@@ -11,6 +11,7 @@ import 'framework.dart'; ...@@ -11,6 +11,7 @@ import 'framework.dart';
import 'overscroll_indicator.dart'; import 'overscroll_indicator.dart';
import 'scroll_physics.dart'; import 'scroll_physics.dart';
import 'scrollable.dart'; import 'scrollable.dart';
import 'scrollable_helpers.dart';
import 'scrollbar.dart'; import 'scrollbar.dart';
const Color _kDefaultGlowColor = Color(0xFFFFFFFF); const Color _kDefaultGlowColor = Color(0xFFFFFFFF);
......
This diff is collapsed.
...@@ -22,6 +22,7 @@ import 'scroll_metrics.dart'; ...@@ -22,6 +22,7 @@ import 'scroll_metrics.dart';
import 'scroll_notification.dart'; import 'scroll_notification.dart';
import 'scroll_position.dart'; import 'scroll_position.dart';
import 'scrollable.dart'; import 'scrollable.dart';
import 'scrollable_helpers.dart';
import 'ticker_provider.dart'; import 'ticker_provider.dart';
const double _kMinThumbExtent = 18.0; const double _kMinThumbExtent = 18.0;
......
...@@ -115,6 +115,7 @@ export 'src/widgets/scroll_position_with_single_context.dart'; ...@@ -115,6 +115,7 @@ export 'src/widgets/scroll_position_with_single_context.dart';
export 'src/widgets/scroll_simulation.dart'; export 'src/widgets/scroll_simulation.dart';
export 'src/widgets/scroll_view.dart'; export 'src/widgets/scroll_view.dart';
export 'src/widgets/scrollable.dart'; export 'src/widgets/scrollable.dart';
export 'src/widgets/scrollable_helpers.dart';
export 'src/widgets/scrollbar.dart'; export 'src/widgets/scrollbar.dart';
export 'src/widgets/selectable_region.dart'; export 'src/widgets/selectable_region.dart';
export 'src/widgets/selection_container.dart'; export 'src/widgets/selection_container.dart';
......
...@@ -1690,6 +1690,57 @@ void main() { ...@@ -1690,6 +1690,57 @@ void main() {
expect(tester.takeException(), isNull); expect(tester.takeException(), isNull);
semantics.dispose(); semantics.dispose();
}); });
testWidgets('deltaToScrollOrigin getter', (WidgetTester tester) async {
await tester.pumpWidget(
const MaterialApp(
home: CustomScrollView(
slivers: <Widget>[
SliverToBoxAdapter(child: SizedBox(height: 2000.0)),
],
),
)
);
final TestGesture gesture = await tester.startGesture(tester.getCenter(find.byType(Scrollable), warnIfMissed: true), kind: ui.PointerDeviceKind.unknown);
expect(getScrollOffset(tester), 0.0);
await gesture.moveBy(const Offset(0.0, -200));
await tester.pump();
await tester.pumpAndSettle();
expect(getScrollOffset(tester), 200);
final ScrollableState scrollable = tester.state(find.byType(Scrollable));
expect(scrollable.deltaToScrollOrigin, const Offset(0.0, 200));
});
testWidgets('resolvedPhysics getter', (WidgetTester tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeData.light().copyWith(
platform: TargetPlatform.android,
),
home: const CustomScrollView(
physics: AlwaysScrollableScrollPhysics(),
slivers: <Widget>[
SliverToBoxAdapter(child: SizedBox(height: 2000.0)),
],
),
)
);
final TestGesture gesture = await tester.startGesture(tester.getCenter(find.byType(Scrollable), warnIfMissed: true), kind: ui.PointerDeviceKind.unknown);
expect(getScrollOffset(tester), 0.0);
await gesture.moveBy(const Offset(0.0, -200));
await tester.pump();
await tester.pumpAndSettle();
expect(getScrollOffset(tester), 200);
final ScrollableState scrollable = tester.state(find.byType(Scrollable));
String types(ScrollPhysics? value) => value!.parent == null ? '${value.runtimeType}' : '${value.runtimeType} ${types(value.parent)}';
expect(
types(scrollable.resolvedPhysics),
'AlwaysScrollableScrollPhysics ClampingScrollPhysics RangeMaintainingScrollPhysics',
);
});
} }
// ignore: must_be_immutable // ignore: must_be_immutable
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment