GeekyAnts / GaugesFlutter

A gauge package for Flutter that displays progress and can be customized for appearance and behavior.
https://pub.dev/packages/geekyants_flutter_gauges
MIT License
67 stars 15 forks source link

Changing start/end of gauges does not cause re-render #249

Open NotTsunami opened 11 months ago

NotTsunami commented 11 months ago

Describe the bug Changing start/end of a gauge does not cause a re-render, but changing a Pointer value does. I filed this under bug report as I would expect this to be out of the box behavior, but it can also suffice as a feature request.

To Reproduce See reproducible code.

Expected behavior When the start or end values are changed, the gauge is expected to respect these values and re-render.

Screenshots N/A

Desktop (please complete the following information):

Additional context Reproducible code:

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

void main() {
  runApp(
    const MaterialApp(
      debugShowCheckedModeBanner: false,
      home: LinearGaugeExample(),
    ),
  );
}

///
/// The following code  is a Simple Example of [LinearGauge] Widget.
/// You can customize the [LinearGauge] Widget as per your need.
///
class LinearGaugeExample extends StatefulWidget {
  const LinearGaugeExample({Key? key}) : super(key: key);

  @override
  State<LinearGaugeExample> createState() => _LinearGaugeExampleState();
}

class _LinearGaugeExampleState extends State<LinearGaugeExample> {
  double startVal = 0.0;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: Column(
          children: [
            LinearGauge(
              start: startVal,
              gaugeOrientation: GaugeOrientation.horizontal,
              enableGaugeAnimation: true,
              rulers: RulerStyle(
                rulerPosition: RulerPosition.bottom,
              ),
              pointers: const [
                Pointer(
                  value: 50,
                  shape: PointerShape.circle,
                ),
              ],
            ),
            TextButton(
                onPressed: () {
                  setState(() {
                    if (startVal == 0.0) {
                      startVal = 5.0;
                    } else {
                      startVal = 0.0;
                    }
                  });
                },
                child: const Text('Toggle Start'))
          ],
        ),
      ),
    );
  }
}
hasnentai commented 11 months ago

Hi, @NotTsunami Would you be willing to look at the code to find a possible solution? We will be happy to merge your PR. Happy Gaugeing