好吧,我没修。作为初学者,这对我来说太复杂了。我找到了另一个解决方案。我做了一行,三个孩子:一个减号按钮和一个加号按钮,用于微调滑块的大步骤。
这是我使用的代码,你有更好的解决方案,让我知道。我只是为像我这样的其他初学者放置它。我要感谢特别想帮助我的@Abbas.M。
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
AnimatedOpacity(
opacity: height == 1 ? 0.0 : 1.0,
duration: Duration(milliseconds: 500),
child: RawMaterialButton(
child: Icon(MdiIcons.minus),
onPressed: () {
setState(() {
height > 1 ? height-- : height = height;
});
},
constraints: BoxConstraints.tightFor(
width: 25.0,
height: 25.0,
),
shape: CircleBorder(),
fillColor: white,
),
),
SliderTheme(
data: SliderTheme.of(context).copyWith(
inactiveTrackColor: cAppBottomBar,
activeTrackColor: white,
thumbColor: white,
overlayColor: cShadow,
thumbShape:
RoundSliderThumbShape(enabledThumbRadius: 10.0),
overlayShape:
RoundSliderOverlayShape(overlayRadius: 17.0),
),
child: Slider(
value: height.toDouble(),
min: 1,
max: 300,
onChanged: (value) {
setState(() {
height = value.toInt();
});
}),
),
AnimatedOpacity(
opacity: height == 300 ? 0.0 : 1.0,
duration: Duration(milliseconds: 500),
child: RawMaterialButton(
child: Icon(Icons.add),
onPressed: () {
setState(() {
height < 300 ? height++ : height = height;
});
},
constraints: BoxConstraints.tightFor(
width: 25.0,
height: 25.0,
),
shape: CircleBorder(),
fillColor: white,
),
),