sleek_circular_slider icon indicating copy to clipboard operation
sleek_circular_slider copied to clipboard

Progress Bar Colour doesn't change on state Change

Open gmccormack95 opened this issue 3 years ago • 6 comments

SleekCircularSlider seems to be a StatefulWidget so when changing the state of the progress bar colour it just keeps it's initial colour. What would be the best way to update the progress bar colour without rebuilding the page?

gmccormack95 avatar Jul 08 '20 18:07 gmccormack95

I solved this problem like this. https://github.com/nero-angela/sleek_circular_slider/commit/3343b5e3ecb35a454cc1c69b59e977e78d140ddd

nero-angela avatar Sep 28 '20 05:09 nero-angela

Might be worth to open a PR for this, there are likely to be more people with the same or similar requirements

geisterfurz007 avatar Oct 07 '20 06:10 geisterfurz007

Hi, I'm on a short holiday. Will check the PR when back (after the 14th of Oct)

matthewfx avatar Oct 08 '20 23:10 matthewfx

Could you please provide some code with an example of what you want to achieve? I've been playing with the slider and whenever I change an appearance it updates for me.

matthewfx avatar Oct 20 '20 05:10 matthewfx

Could you please provide some code with an example of what you want to achieve? I've been playing with the slider and whenever I change an appearance it updates for me.

I tried to change the color of SleekCircularSlider in StatefullWidget using setState method, but it didn't work. I've attached the code for reproduction below.

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

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

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  Color _pointColor = Colors.pinkAccent;

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          crossAxisAlignment: CrossAxisAlignment.center,
          children: [
            SizedBox(width: double.infinity),
            SleekCircularSlider(
              min: 0,
              max: 1000,
              initialValue: 426,
              appearance: CircularSliderAppearance(
                customColors: CustomSliderColors(
                  progressBarColor: _pointColor,
                  trackColor: _pointColor.withOpacity(0.2),
                  dotColor: _pointColor,
                ),
                customWidths: CustomSliderWidths(
                  progressBarWidth: 4,
                  trackWidth: 4,
                ),
              ),
            ),
            RaisedButton(
              child: Text('change color'),
              onPressed: () {
                setState(() {
                  _pointColor = Colors.blueAccent;
                });
              },
            )
          ],
        ),
      ),
    );
  }
}

nero-angela avatar Oct 22 '20 03:10 nero-angela

@nero-angela I confirm your fix works. +1 for your PR. I'll use your repo until #32 is merged.

cihadturhan avatar Nov 24 '20 03:11 cihadturhan