fix(flutter): 修复下拉刷新页面跟随

This commit is contained in:
Zhou Weidong committed 2026-10-20 16:57:28 +08:00
1 parent c4dcb714ab
commit 69eaacd74f
16 files changed
+85 -34

No files matched your search

+5 -1
View File
@@ -300,7 +300,11 @@ void main() {
);
expect(refresh.edgeOffset, 52);
await tester.drag(_verticalFeed, const Offset(0, 120));
expect(
tester.widget<ListView>(_verticalFeed).physics,
AppPullToRefresh.physics,
);
await tester.drag(_verticalFeed, const Offset(0, 240));
await tester.pump();
expect(find.text('Refreshing…'), findsOneWidget);
await tester.pumpAndSettle();
+14 -12
View File
@@ -6,6 +6,7 @@ import 'package:fruitshorts/app.dart';
import 'package:fruitshorts/core/data/models/drama.dart';
import 'package:fruitshorts/core/data/models/home_feed.dart';
import 'package:fruitshorts/core/theme/app_colors.dart';
import 'package:fruitshorts/core/widgets/app_pull_to_refresh.dart';
import 'package:fruitshorts/core/data/repositories/favorite_repository.dart';
import 'package:fruitshorts/core/data/repositories/playback_repository.dart';
import 'package:fruitshorts/core/data/repositories/watch_history_repository.dart';
@@ -181,7 +182,9 @@ void main() {
await tester.pumpAndSettle();
final list = find.byKey(const Key('ranking-list'));
await tester.drag(list, const Offset(0, -8000));
expect(tester.widget<ListView>(list).physics, AppPullToRefresh.physics);
final position = _scrollPosition(tester, const Key('ranking-list'));
position.jumpTo(position.maxScrollExtent);
await tester.pump();
expect(find.byKey(const Key('ranking-row-19')), findsOneWidget);
@@ -191,23 +194,22 @@ void main() {
expect(find.byKey(const Key('ranking-load-more')), findsOneWidget);
await tester.pump(const Duration(milliseconds: 1));
await tester.drag(list, const Offset(0, -8000));
position.jumpTo(position.maxScrollExtent);
await tester.pump();
expect(find.byKey(const Key('ranking-row-39')), findsOneWidget);
expect(find.byKey(const Key('ranking-row-40')), findsNothing);
expect(find.byKey(const Key('ranking-no-more')), findsOneWidget);
final position = _scrollPosition(tester, const Key('ranking-list'));
position.jumpTo(0);
await tester.pump();
final beforeRefresh = repository.fetchCalls;
await tester.drag(list, const Offset(0, 120));
await tester.drag(list, const Offset(0, 240));
await tester.pump();
await tester.pumpAndSettle();
expect(repository.fetchCalls, beforeRefresh + 1);
expect(position.pixels, 0);
await tester.drag(list, const Offset(0, -8000));
position.jumpTo(position.maxScrollExtent);
await tester.pump();
expect(find.byKey(const Key('ranking-load-more')), findsOneWidget);
expect(find.byKey(const Key('ranking-no-more')), findsNothing);
@@ -223,11 +225,13 @@ void main() {
await tester.pumpAndSettle();
final list = find.byKey(const Key('new-releases-list'));
expect(tester.widget<ListView>(list).physics, AppPullToRefresh.physics);
await tester.drag(list, const Offset(0, -400));
await tester.pump();
expect(_countKeys('home-drama-card-'), 20);
await tester.drag(list, const Offset(0, -8000));
final position = _scrollPosition(tester, const Key('new-releases-list'));
position.jumpTo(position.maxScrollExtent);
await tester.pump();
expect(find.byKey(const Key('new-releases-load-more')), findsOneWidget);
await tester.pump(const Duration(milliseconds: 299));
@@ -237,7 +241,6 @@ void main() {
expect(_countKeys('home-drama-card-'), 40);
await tester.pumpAndSettle();
final position = _scrollPosition(tester, const Key('new-releases-list'));
position.jumpTo(position.maxScrollExtent);
await tester.pumpAndSettle();
expect(find.byKey(const Key('new-releases-no-more')), findsOneWidget);
@@ -245,7 +248,7 @@ void main() {
position.jumpTo(0);
await tester.pump();
final beforeRefresh = repository.fetchCalls;
await tester.drag(list, const Offset(0, 120));
await tester.drag(list, const Offset(0, 240));
await tester.pump();
await tester.pumpAndSettle();
expect(repository.fetchCalls, beforeRefresh + 1);
@@ -263,10 +266,9 @@ void main() {
await tester.pumpAndSettle();
final beforeRefresh = repository.fetchCalls;
await tester.drag(
find.byKey(const Key('reserve-list')),
const Offset(0, 120),
);
final list = find.byKey(const Key('reserve-list'));
expect(tester.widget<ListView>(list).physics, AppPullToRefresh.physics);
await tester.drag(list, const Offset(0, 240));
await tester.pump();
await tester.pumpAndSettle();