main.dart import 'package:flutter/material.dart'; void main() => runApp(MyApp()); class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( debugShowCheckedModeBanner: false, title: 'This is a Slide Example', home: Scaffold( appBar: AppBar( title: Text('ABC'), ), body: Column(children:[ Padding( child: Text( 'This is a Slide Example', style: TextStyle(fontSize: 20), ), padding: EdgeInsets.all(50), ), SlideExample(), RangeSliderExample() ]))); } } class SlideExample extends StatefulWidget { @override _Slider1State createState() => _Slider1State(); } class _Slider1State extends State { double rating = 0; @override Widget build(BuildContext context) { // TODO: implement build return Slider( label: "$rating", divisions: 10, value: rating, onChanged: (newRating) { setState(() => rating = newRating); }, ); } } class RangeSliderExample extends StatefulWidget { @override _RangeSliderExampleState createState() => _RangeSliderExampleState(); } class _RangeSliderExampleState extends State { var selectedRange = RangeValues(0.2, 0.8); @override Widget build(BuildContext context) { // TODO: implement build return RangeSlider( values: selectedRange, onChanged: (RangeValues newRange) { setState(() { selectedRange = newRange; }); }, ); } }
flutter Slide拖动滑条
2019/11/04 by Leave a Comment
Comment