Skip to content

Commit

Permalink
Merge de81457 into 6ba48ad
Browse files Browse the repository at this point in the history
  • Loading branch information
moniaS committed Aug 1, 2019
2 parents 6ba48ad + de81457 commit bc1415a
Show file tree
Hide file tree
Showing 8 changed files with 376 additions and 167 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ addons:
- ubuntu-toolchain-r-test # if we don't specify this, the libstdc++6 we get is the wrong version
packages:
- libstdc++6
- fonts-droid
- fonts-noto
before_script:
- git clone https://github.com/flutter/flutter.git -b beta --depth 1
- ./flutter/bin/flutter doctor
Expand Down
108 changes: 70 additions & 38 deletions example/lib/example.dart → example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,91 @@ class MyHomePage extends StatefulWidget {

class _MyHomePageState extends State<MyHomePage> {
int _currentIntValue = 10;
int _currentHorizontalIntValue = 10;
int _currentInfIntValue = 10;
double _currentDoubleValue = 3.0;
NumberPicker integerNumberPicker;
NumberPicker horizontalNumberPicker;
NumberPicker integerInfiniteNumberPicker;
NumberPicker decimalNumberPicker;

@override
Widget build(BuildContext context) {
_initializeNumberPickers();
return DefaultTabController(
length: 3,
child: Scaffold(
appBar: AppBar(
bottom: TabBar(
tabs: [
Tab(text: 'Integer'),
Tab(text: 'Decimal'),
Tab(text: 'Infinite loop'),
],
),
title: Text(widget.title),
),
body: TabBarView(
children: [
Column(
children: <Widget>[
SizedBox(height: 16),
Text('Default', style: Theme.of(context).textTheme.title),
integerNumberPicker,
new RaisedButton(
onPressed: () => _showIntDialog(),
child: new Text("Current int value: $_currentIntValue"),
),
Divider(color: Colors.grey, height: 32),
Text('Horizontal', style: Theme.of(context).textTheme.title),
horizontalNumberPicker,
Text(
"Current int value: $_currentHorizontalIntValue",
style: TextStyle(
fontWeight: FontWeight.w600,
),
),
],
),
Column(
children: <Widget>[
decimalNumberPicker,
new RaisedButton(
onPressed: () => _showDoubleDialog(),
child: new Text("Current double value: $_currentDoubleValue"),
),
],
),
Column(
children: <Widget>[
integerInfiniteNumberPicker,
new RaisedButton(
onPressed: () => _showInfIntDialog(),
child: new Text("Current int value: $_currentInfIntValue"),
),
],
)
],
),
),
);
}

void _initializeNumberPickers() {
integerNumberPicker = new NumberPicker.integer(
initialValue: _currentIntValue,
minValue: 0,
maxValue: 100,
step: 10,
onChanged: (value) => setState(() => _currentIntValue = value),
);
horizontalNumberPicker = new NumberPicker.horizontal(
initialValue: _currentHorizontalIntValue,
minValue: 0,
maxValue: 100,
step: 10,
onChanged: (value) => setState(() => _currentHorizontalIntValue = value),
);
integerInfiniteNumberPicker = new NumberPicker.integer(
initialValue: _currentInfIntValue,
minValue: 0,
Expand All @@ -61,44 +131,6 @@ class _MyHomePageState extends State<MyHomePage> {
decimalPlaces: 2,
onChanged: (value) => setState(() => _currentDoubleValue = value),
);
return new Scaffold(
appBar: new AppBar(
title: new Text(widget.title),
),
body: new Column(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: <Widget>[
new Row(children: <Widget>[
Expanded(
child: Column(children: <Widget>[
Text("Default"),
integerNumberPicker,
new RaisedButton(
onPressed: () => _showIntDialog(),
child: new Text("Current int value: $_currentIntValue"),
),
]),
),
Expanded(
child: Column(children: <Widget>[
Text("With infinite loop"),
integerInfiniteNumberPicker,
new RaisedButton(
onPressed: () => _showInfIntDialog(),
child: new Text("Current int value: $_currentInfIntValue"),
),
]),
),
]),
decimalNumberPicker,
new RaisedButton(
onPressed: () => _showDoubleDialog(),
child: new Text("Current double value: $_currentDoubleValue"),
),
],
),
);
}

Future _showIntDialog() async {
Expand Down

0 comments on commit bc1415a

Please sign in to comment.