如何在颤动中构建没有滑动功能的滑块

How to buld slider without sliding function in flutter

我想在 flutter 中像这样构建滑块(类似于 SleekCircularSlider)

final  double value = 0.9;

Container(
          color: Colors.black,
          child: Column(
            mainAxisSize: MainAxisSize.min,
            children: [
              Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: [
                  Text(
                    'html',
                    style: TextStyle(color: Colors.white),
                  ),
                  Text(
                    '$value%',
                    style: TextStyle(color: Colors.grey),
                  )
                ],
              ),
              LinearProgressIndicator(
                value: 0.9,
                color: Colors.yellow,
              )
            ],
          ),
        ),

您可以根据需要使用 flutter 内置 Slider 小部件来实现此目的。在下面找到代码片段。

final double sliderValue = 90.0;
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(),
      body: Container(
        width: 350,
        height: 350,
        child: SliderTheme(
          data: SliderThemeData(
            overlayColor: Colors.transparent,
            thumbShape: SliderComponentShape.noThumb,
          ),
          child: Column(
            children: [
              Row(
                mainAxisAlignment: MainAxisAlignment.spaceAround,
                children: [
                  Text('HTML'),
                  Text(sliderValue.toInt().toString() + '%')
                ],
              ),
              Slider(
                  value: 90,
                  min: 0.0,
                  max: 100.0,
                  divisions: 100,
                  mouseCursor: MouseCursor.uncontrolled,
                  onChanged: (double value) {}),
            ],
          ),
        ),
      ),
    );
  }