Created
July 2, 2021 08:56
-
-
Save FantasyCheese/40bdea3393ee4e6e19da5a4d8155504e to your computer and use it in GitHub Desktop.
Flutter slider minimum
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( | |
MaterialApp( | |
home: App(), | |
), | |
); | |
} | |
class App extends StatefulWidget { | |
const App({Key key}) : super(key: key); | |
@override | |
_AppState createState() => _AppState(); | |
} | |
class _AppState extends State<App> { | |
double value = 0; | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
appBar: AppBar(), | |
body: Center( | |
child: Slider( | |
value: value, | |
min: 0, | |
max: 20, | |
divisions: 20, | |
onChanged: (value) { | |
if (value > 5) { | |
setState(() { | |
this.value = value; | |
}); | |
} | |
}, | |
), | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment