Skip to content

[ios] ValueListenableBuilder rebuild interrupts ongoing scroll gesture #173225

@koodimetsa

Description

@koodimetsa

Steps to reproduce

  1. Have a ValueListenableBuilder inside SingleChildScrollView.
  2. Scroll so much that there is rubber banding effect.
  3. Keep finger on display to "over scroll".
  4. When ValueNotifier value changes ValueListenableBuilder builds, scrolling is ended and causes ScrollView to go to begining(or end) of view.

Expected results

When ValueListenableBuilder rebuilds, scrolling should continue seamlessly.

Actual results

Scroll gesture ends when ValueListenableBuilder rebuilds.

Code sample

Code sample
import 'package:flutter/material.dart';

import 'dart:async';

class MainApp extends StatefulWidget {
  const MainApp({super.key});

  @override
  State<MainApp> createState() => _MainAppState();
}

class _MainAppState extends State<MainApp> {
  final titleValue = ValueNotifier<String>('0');
  int counter = 0;

  @override
  void initState() {
    super.initState();

    Timer.periodic(const Duration(milliseconds: 1500), (timer) {
      counter++;
      titleValue.value = counter.toString();
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: SingleChildScrollView(
          child: ConstrainedBox(
            constraints: BoxConstraints(
              minHeight: MediaQuery.sizeOf(context).height * 1.2,
            ),
            child: Column(
              children: [
                const SizedBox(height: 300),
                Row(
                  mainAxisAlignment: MainAxisAlignment.center,
                  children: [
                    const Text('Time: ', style: TextStyle(color: Colors.red)),
                    ValueListenableBuilder(
                      valueListenable: titleValue,
                      builder: (context, value, child) {
                        return Text(
                          value,
                          style: const TextStyle(
                            color: Colors.blue,
                            fontFeatures: [FontFeature.tabularFigures()],
                          ),
                        );
                      },
                    ),
                  ],
                ),
                Container(width: 200, height: 200, color: Colors.blue),
              ],
            ),
          ),
        ),
      ),
    );
  }
}

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

Screenshots or Video

Screenshots / Video demonstration
example.mp4

Logs

Flutter Doctor output

Doctor output
[✓] Flutter (Channel stable, 3.32.8, on macOS 15.6 24G84 darwin-arm64, locale en-US) [257ms]
    • Flutter version 3.32.8 on channel stable at /Users/mm/Coding/flutter/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision edada7c56e (10 days ago), 2025-07-25 14:08:03 +0000
    • Engine revision ef0cd00091
    • Dart version 3.8.1
    • DevTools version 2.45.1

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0) [973ms]
    • Android SDK at /Users/mm/Library/Android/sdk
    • Platform android-35, build-tools 34.0.0
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
      This is the JDK bundled with the latest Android Studio installation on this machine.
      To manually set the JDK path, use: `flutter config --jdk-dir="path/to/jdk"`.
    • Java version OpenJDK Runtime Environment (build 21.0.6+-13368085-b895.109)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 16.4) [509ms]
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 16F6
    • CocoaPods version 1.16.2

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

[✓] Android Studio (version 2024.3) [9ms]
    • 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 21.0.6+-13368085-b895.109)

[✓] VS Code (version 1.102.3) [8ms]
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.116.0

[✓] Connected device (4 available) [5.7s]
    • GoldenEye (2) (wireless) (mobile) • 00008110-000279691122801E            • ios            • iOS 18.6 22G86
    • iPhone 16 (mobile)                • AC5080C6-540F-4CBD-B01C-FC0146903FC7 • ios            • com.apple.CoreSimulator.SimRuntime.iOS-18-5 (simulator)
    • macOS (desktop)                   • macos                                • darwin-arm64   • macOS 15.6 24G84 darwin-arm64
    • Chrome (web)                      • chrome                               • web-javascript • Google Chrome 138.0.7204.184

[✓] Network resources [262ms]
    • 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.32Found to occur in 3.32found in release: 3.33Found to occur in 3.33frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onplatform-iosiOS applications specificallyplatform-macBuilding on or for macOS specificallyteam-frameworkOwned by Framework teamtriaged-frameworkTriaged by Framework teamworkaround availableThere is a workaround available to overcome the issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions