Skip to content

Instantly share code, notes, and snippets.

@brunocalou
Last active March 21, 2019 12:26
Show Gist options
  • Save brunocalou/98444e09d9af55b5d19548c2dc1e8334 to your computer and use it in GitHub Desktop.
Save brunocalou/98444e09d9af55b5d19548c2dc1e8334 to your computer and use it in GitHub Desktop.
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Slider Test',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: MyHomePage(title: 'Slider Test'),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
double value = 0;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Center(
child: Slider(
min: 0,
max: 10,
divisions: 10,
value: value,
label: '$value',
onChanged: (newValue) => setState(
() {
value = newValue;
},
),
),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment