Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong values are notified when changing value while transition. #118

Open
kainosk opened this issue Jul 19, 2021 · 0 comments · May be fixed by #119
Open

Wrong values are notified when changing value while transition. #118

kainosk opened this issue Jul 19, 2021 · 0 comments · May be fixed by #119

Comments

@kainosk
Copy link

kainosk commented Jul 19, 2021

Problem:

Wrong values are notified when following below steps.

  1. Change values property while page transition.
  2. Drag outside of thumb
  3. Wrong values are notified from slider and wrong handler position is displayed.
    • Handler will jump to left end. (expected behavior is following pointer.)
Simulator.Screen.Recording.-.iPhone.12.Pro.Max.-.2021-07-19.at.20.51.14.mp4

Dart snippet to reproduce the bug:

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

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: Text('Sample'),
        ),
        body: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              Builder(builder: (context) {
                return TextButton(
                  onPressed: () {
                    Navigator.of(context).push(
                      MaterialPageRoute(
                        builder: (context) => SliderView(),
                      ),
                    );
                  },
                  child:
                      Text('Show Slider View', style: TextStyle(fontSize: 30)),
                );
              }),
            ],
          ),
        ),
      ),
    );
  }
}

class SliderView extends StatefulWidget {
  @override
  _SliderViewState createState() => _SliderViewState();
}

class _SliderViewState extends State<SliderView> {
  double _sliderValue = 0.0;

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

    // To reproduce the bug,
    // the duration of `delayed` should be less than transition animation's duration (maybe 300ms).
    // For example, this demo uses 1ms.
    Future.delayed(Duration(milliseconds: 1)).then((_) {
      setState(() {
        _sliderValue = 50;
      });
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(),
      body: SafeArea(
        child: Center(
          child: FlutterSlider(
            values: [_sliderValue],
            min: 0,
            max: 100,
          ),
        ),
      ),
    );
  }
}
kainosk pushed a commit to kainosk/flutter_xlider that referenced this issue Jul 20, 2021
marcqtan pushed a commit to marcqtan/flutter_xlider that referenced this issue Oct 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant