Skip to content

[Regression] Slider in TabBarView (multi children) triggered onChangeEnd when start dragging. #103675

@yohom

Description

@yohom

Steps to Reproduce

In 2.10.5, it is ok, but in 3.0 it occurs. Related #28115 #21069 .

  1. Put a Slider in TabBarView's children;
  2. Drag Slider's thumb, the onChangeEnd callback fired, and TabBarView scrolled;

Expected results:
TabBarView should not scrolled, and onChangeEnd should fired after dragging end rather than when dragging start.

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

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

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: const MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({Key? key, required this.title}) : super(key: key);

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  double _value = 0;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text(widget.title)),
      body: DefaultTabController(
        length: 2,
        child: Column(
          children: [
            const TabBar(
              tabs: [Tab(text: '1'), Tab(text: '2')],
              labelColor: Colors.black,
            ),
            Expanded(
              child: TabBarView(
                children: [
                  const Center(child: Placeholder()),
                  Center(
                    child: Slider(
                      value: _value,
                      onChangeEnd: (value) => debugPrint('onChangeEnd: $value'),
                      onChanged: (value) {
                        debugPrint('onChanged: $value');
                        setState(() => _value = value);
                      },
                      onChangeStart: (value) {
                        debugPrint('onChangeStart: $value');
                      },
                    ),
                  ),
                ],
              ),
            ),
          ],
        ),
      ),
    );
  }
}
Logs
[✓] Flutter (Channel stable, 3.0.0, on macOS 12.3.1 21E258 darwin-arm, locale en-CN)
    • Flutter version 3.0.0 at /Users/yohom/fvm/versions/stable
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision ee4e09cce0 (3 days ago), 2022-05-09 16:45:18 -0700
    • Engine revision d1b9a6938a
    • Dart version 2.17.0
    • DevTools version 2.12.2
    • Pub download mirror https://pub.flutter-io.cn
    • Flutter download mirror https://storage.flutter-io.cn

[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
    • Android SDK at /Users/yohom/Library/Android/sdk
    • Platform android-31, build-tools 31.0.0
    • ANDROID_HOME = /Users/yohom/Library/Android/sdk
    • Java binary at: /Users/yohom/Library/Java/JavaVirtualMachines/corretto-11.0.12/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment Corretto-11.0.12.7.2 (build 11.0.12+7-LTS)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 13.3.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • CocoaPods version 1.11.3

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

[✓] Android Studio (version 2021.2)
    • 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 11.0.12+0-b1504.28-7817840)

[✓] IntelliJ IDEA Ultimate Edition (version 2021.3.3)
    • IntelliJ at /Applications/IntelliJ IDEA.app
    • Flutter plugin version 67.1.3
    • Dart plugin version 213.7371

[✓] IntelliJ IDEA Community Edition (version 2021.2.4)
    • IntelliJ at /Volumes/yohom/private/mac_app/app/IntelliJ IDEA CE.app
    • Flutter plugin version 63.3.3
    • Dart plugin version 212.5632

[✓] IntelliJ IDEA Ultimate Edition (version 2021.2.4)
    • IntelliJ at /Volumes/yohom/private/mac_app/app/IntelliJ IDEA.app
    • Flutter plugin version 64.1.3
    • Dart plugin version 212.5632

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

[✓] Connected device (3 available)
    • MIX 3 (mobile)              • 84abad0c      • android-arm64  • Android 10 (API 29)
    • sdk gphone64 arm64 (mobile) • emulator-5554 • android-arm64  • Android 12 (API 31) (emulator)
    • Chrome (web)                • chrome        • web-javascript • Google Chrome 101.0.4951.64

[✓] HTTP Host Availability
    • All required HTTP hosts are available

• No issues found!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions