Skip to content

Instantly share code, notes, and snippets.

@zero-is-one
Created August 27, 2018 16:43
Show Gist options
  • Save zero-is-one/884cb21cefbd745ce42b94038c117cea to your computer and use it in GitHub Desktop.
Save zero-is-one/884cb21cefbd745ce42b94038c117cea to your computer and use it in GitHub Desktop.
import 'package:flutter/material.dart';
void main() => runApp(new MyApp());
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return new MaterialApp(
title: 'Flutter Demo',
home: new MyHomePage(title: 'Flutter Test Page'),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
@override
_MyHomePageState createState() => new _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
int _myValue = 60;
@override
Widget build(BuildContext context) {
return DefaultTabController(
length: 3,
child: new Scaffold(
appBar: new AppBar(
title: new Text(widget.title),
bottom: TabBar(
tabs: [
Tab(icon: Icon(Icons.directions_car)),
Tab(icon: Icon(Icons.directions_transit)),
Tab(icon: Icon(Icons.directions_bike)),
],
),
),
body: new TabBarView(children: <Widget>[
new Center(
child: new Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
new Slider(
value: _myValue.toDouble(),
min: 1.0,
max: 100.0,
divisions: 10,
label: '$_myValue',
onChanged: (double newValue) {
setState(() {
_myValue = newValue.round();
});
},
onChangeEnd: (double newValue) {
print('Ended change on $newValue');
},
),
],
),
),
new Icon(Icons.directions_transit),
new Icon(Icons.directions_bike),
]),
// This trailing comma makes auto-formatting nicer for build methods.
));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment