Flutter Slider 滑动条的基本使用

编程入门 行业动态 更新时间:2024-10-08 13:30:51

<a href=https://www.elefans.com/category/jswz/34/1770916.html style=Flutter Slider 滑动条的基本使用"/>

Flutter Slider 滑动条的基本使用

在码农的世界里,优美的应用体验,来源于程序员对细节的处理以及自我要求的境界,年轻人也是忙忙碌碌的码农中一员,每天、每周,都会留下一些脚印,就是这些创作的内容,有一种执着,就是不知为什么,如果你迷茫,不妨来瞅瞅码农的轨迹。

  • 优美的音乐节奏带你浏览这个效果的编码过程
  • 坚持每一天,是每个有理想青年的追求
  • 追寻年轻人的脚步,也许你的答案就在这里
  • 如果你迷茫 不妨来瞅瞅这里

Flutter滑动条 Slider 的详细配置使用


import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';/// 创建人: Created by zhaolong
/// 创建时间:Created by  on 2020/12/25.
///
/// 可关注公众号:我的大前端生涯   获取最新技术分享
/// 可关注网易云课堂:.htm
/// 可关注博客:
///main() {runApp(MaterialApp(debugShowCheckedModeBanner: false,home: AppRootPage(),),);
}class AppRootPage extends StatefulWidget {@overrideState<StatefulWidget> createState() {return new _AppRootPageState();}
}class _AppRootPageState extends State<AppRootPage> {@overrideWidget build(BuildContext context) {return Scaffold(appBar: AppBar(title: Text("滑动条"),),//居中body: Center(child: Container(width: 240,height: 120,child: buildThem(),),),);}//Slider的值double _sliderValue = 1.0;Widget buildThem() {return Theme(data: ThemeData(sliderTheme: SliderThemeData(trackHeight: 1,//滑块的颜色thumbColor: Colors.deepOrange,//滑块的大小thumbShape: RoundSliderThumbShape(enabledThumbRadius: 10),//点击滑块边缘的颜色overlayColor: Colors.deepPurpleAccent.withOpacity(0.2),//点击滑块边缘的显示半径overlayShape: RoundSliderOverlayShape(overlayRadius: 20),//滑动左侧滚动条的颜色activeTrackColor: Colors.blue,//滚动条右侧的颜色inactiveTrackColor: Colors.grey,//任何情况都显示气泡showValueIndicator: ShowValueIndicator.always,//气泡的文字样式valueIndicatorTextStyle: TextStyle(color: Colors.white),//气泡的背景valueIndicatorColor: Colors.redAccent)),child: buildSliderWidget(),);}Widget buildSliderWidget() {return Slider(//Slider的当前的值  0.0 ~ 1.0value: _sliderValue,min: 1.0,max: 100.0,//平均分成的等分divisions: 100,//滚动时会回调onChanged: (double value) {_sliderValue = value;print("Value $_sliderValue");setState(() {});},onChangeStart: (double startValue) {print("开始滚动");},onChangeEnd: (double endValue) {print("停止 滚动");},//滑块以及滑动左侧的滚动条颜色// activeColor: Colors.redAccent,//滑块右侧的滚动条颜色// inactiveColor: Colors.blue,//气泡label: "${_sliderValue.toStringAsFixed(1)}",);}
}

完毕

不局限于思维,不局限语言限制,才是编程的最高境界。

以小编的性格,肯定是要录制一套视频的,随后会上传

有兴趣 你可以关注一下 西瓜视频 — 早起的年轻人

更多推荐

Flutter Slider 滑动条的基本使用

本文发布于:2024-02-19 17:36:25,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1765190.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Flutter   Slider

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!