Skip to content

Refresh Indicator With SingleChildScrollView With BouncingScrollPhysics, Page Offset Jump After Refresh #149018

@rafurqan

Description

@rafurqan

Steps to reproduce

When using Refresh indicator with SingleChildScrollView with physic BouncingScrollPhysics, Page jump after using refresh. this is not the case in version 3.16. but since 13.19 and now in version 3.22.1 it still happens.

  1. Refresh indicator with SingleChildScrollView with physic BouncingScrollPhysics, it's error
  2. But Refresh indicator with ListView with physic BouncingScrollPhysics, it's fine

Expected results

Refresh indicator with ListView with physic BouncingScrollPhysics,

Screen_recording_20240524_102754.webm

Actual results

Refresh indicator with SingleChildScrollView with physic BouncingScrollPhysics,

Screen_recording_20240524_101517.webm

Code sample

Code sample With SingleChildScrollView
import 'dart:async';

import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends HookWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    final isLoading = useState(false);
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(title: const Text("Refresh Indicator")),
        body: RefreshIndicator(
          onRefresh: () async {
            isLoading.value = true;
            Future.delayed(
                const Duration(seconds: 3), () => isLoading.value = false);
          },
          child: SingleChildScrollView(
            physics: const AlwaysScrollableScrollPhysics(
                parent: BouncingScrollPhysics()),
            padding: const EdgeInsets.symmetric(horizontal: 20),
            child: Column(
              children: List.generate(
                100,
                (_) => isLoading.value
                    ? Row(children: [
                        const CircularProgressIndicator(),
                        const SizedBox(width: 5),
                        Text("loading $_")
                      ])
                    : Text("data $_"),
              )
                  .expand(
                    (_) => [_, const SizedBox(height: 10)],
                  )
                  .toList(),
            ),
          ),
        ),
      ),
    );
  }
}
Code sample With ListView
import 'dart:async';

import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends HookWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    final isLoading = useState(false);
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(title: const Text("Refresh Indicator")),
        body: RefreshIndicator(
          onRefresh: () async {
            isLoading.value = true;
            Future.delayed(
                const Duration(seconds: 3), () => isLoading.value = false);
          },
          child: ListView(
            physics: const AlwaysScrollableScrollPhysics(
                parent: BouncingScrollPhysics()),
            padding: const EdgeInsets.symmetric(horizontal: 20),
            children: List.generate(
              100,
              (_) => isLoading.value
                  ? Row(children: [
                      const CircularProgressIndicator(),
                      const SizedBox(width: 5),
                      Text("loading $_")
                    ])
                  : Text("data $_"),
            )
                .expand(
                  (_) => [_, const SizedBox(height: 10)],
                )
                .toList(),
          ),
        ),
      ),
    );
  }
}

Screenshots or Video

Screenshots / Video demonstration

[Upload media here]

Logs

Logs
[Paste your logs here]

Flutter Doctor output

Doctor output
[✓] Flutter (Channel stable, 3.22.1, on macOS 14.4.1 23E224 darwin-arm64, locale en-ID)
    • Flutter version 3.22.1 on channel stable at /Users/User/Downloads/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision a14f74ff3a (35 hours ago), 2024-05-22 11:08:21 -0500
    • Engine revision 55eae6864b
    • Dart version 3.4.1
    • DevTools version 2.34.3

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
    • Android SDK at /Users/User/Library/Android/sdk
    • Platform android-34, build-tools 33.0.0
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.10+0-17.0.10b1087.21-11572160)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.0.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 15A507
    • CocoaPods version 1.14.3

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2023.3)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.10+0-17.0.10b1087.21-11572160)

[✓] VS Code (version 1.89.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.88.0

[✓] Connected device (4 available)
    • sdk gphone arm64 (mobile)       • emulator-5554         • android-arm64  • Android 11 (API 30) (emulator)
    • macOS (desktop)                 • macos                 • darwin-arm64   • macOS 14.4.1 23E224 darwin-arm64
    • Mac Designed for iPad (desktop) • mac-designed-for-ipad • darwin         • macOS 14.4.1 23E224 darwin-arm64
    • Chrome (web)                    • chrome                • web-javascript • Google Chrome 125.0.6422.76

[✓] Network resources
    • All expected network resources are available.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work listf: material designflutter/packages/flutter/material repository.f: scrollingViewports, list views, slivers, etc.found in release: 3.22Found to occur in 3.22found in release: 3.23Found to occur in 3.23frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onteam-frameworkOwned by Framework teamtriaged-frameworkTriaged by Framework team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions