Created
December 9, 2019 12:52
-
-
Save rahulkhatri19/76d561cde570991256c60bbb12f99600 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
void main() { | |
runApp(new MaterialApp(home: SliderApp())); | |
} | |
class SliderApp extends StatefulWidget { | |
@override | |
_slider createState() => new _slider(); | |
} | |
class _slider extends State<SliderApp> { | |
double sliderVal = 3; | |
@override | |
Widget build(BuildContext context) { | |
return new Scaffold( | |
appBar: AppBar( | |
title: new Text('Slider App'), | |
), | |
body: new Center( | |
child: new Column( | |
mainAxisAlignment: MainAxisAlignment.center, | |
children: <Widget>[ | |
new Slider(value: sliderVal, min: 1.0, max: 10.0, onChanged: (double dbVal){ | |
sliderMethod(dbVal); | |
}), | |
new Text('Slider value: $sliderVal') | |
], | |
), | |
), | |
); | |
} | |
void sliderMethod(double dbVal) { | |
setState(() { | |
sliderVal = dbVal; | |
print(dbVal); | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment