其他分享
首页 > 其他分享> > slider

slider

作者:互联网

import 'package:flutter/material.dart';

void main()=>runApp(MyApp());

class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: HomePage(),
);
}
}

class HomePage extends StatefulWidget {
@override
_HomePageState createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
double reading=0.0;
@override
Widget build(BuildContext context) {
return Scaffold(
body: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Slider(
value: reading,
min: 0.0,
max: 100.0,
inactiveColor: Colors.grey,
activeColor: Colors.orange,
label: 'value:$reading',
divisions: 10,
onChanged: (data){setState(() {
reading = data;
});})
],
),
);
}
}

标签:0.0,slider,extends,HomePageState,override,reading,class
来源: https://www.cnblogs.com/braveheart007/p/10976118.html