• Taha Tesser's avatar
    Fix `Slider` `onChanged` callback order & never calls `onChangeStart` on ... · 4f959b97
    Taha Tesser authored
    Fix `Slider` `onChanged` callback order & never calls `onChangeStart` on  `SliderInteraction.slideOnly` allowed interaction (#136720)
    
    fixes [Slider will call onChanged before onChangeStart when sliding.](https://github.com/flutter/flutter/issues/136707)
    
    This fixes a regression from https://github.com/flutter/flutter/pull/121483
    
    ### Code sample
    
    <details>
    <summary>expand to view the code sample</summary> 
    
    ```dart
    import 'package:flutter/material.dart';
    
    void main() => runApp(const MyApp());
    
    class MyApp extends StatelessWidget {
      const MyApp({super.key});
    
      @override
      Widget build(BuildContext context) {
        return const MaterialApp(
          debugShowCheckedModeBanner: false,
          home: Example(),
        );
      }
    }
    
    class Example extends StatefulWidget {
      const Example({super.key});
    
      @override
      State<Example> createState() => _ExampleState();
    }
    
    class _ExampleState extends State<Example> {
      double _sliderValue = 0.5;
    
      @override
      Widget build(BuildContext context) {
        return Scaffold(
          body: Center(
            child: Slider(
              // allowedInteraction: SliderInteraction.tapAndSlide,
              // allowedInteraction: SliderInteraction.tapOnly,
              // allowedInteraction: SliderInteraction.slideOnly
              // allowedInteraction: SliderInteraction.slideThumb,
              value: _sliderValue,
              onChangeStart: (newValue) {
                print("onChangeStart ......");
              },
              onChanged: (newValue) {
                print("onChanged ......");
                setState(() {
                  _sliderValue = newValue;
                });
              },
              onChangeEnd: (newValue) {
                print("onChangeEnd ......");
              },
            ),
          ),
        );
      }
    }
    ```
    
    </details>
    4f959b97
Name
Last commit
Last update
..
fix_data Loading commit data...
src Loading commit data...
analysis_options.yaml Loading commit data...
analysis_options_user.yaml Loading commit data...
animation.dart Loading commit data...
cupertino.dart Loading commit data...
foundation.dart Loading commit data...
gestures.dart Loading commit data...
material.dart Loading commit data...
painting.dart Loading commit data...
physics.dart Loading commit data...
rendering.dart Loading commit data...
scheduler.dart Loading commit data...
semantics.dart Loading commit data...
services.dart Loading commit data...
widgets.dart Loading commit data...