Created
May 4, 2020 07:20
-
-
Save LostKobrakai/6a2aeaa72ed77e3f9e2b08a5f5dfb5fc to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file | |
// for details. All rights reserved. Use of this source code is governed by a | |
// BSD-style license that can be found in the LICENSE file. | |
import 'package:flutter/material.dart'; | |
void main() => runApp(MyApp()); | |
class MyApp extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
title: 'Flutter Demo', | |
debugShowCheckedModeBanner: false, | |
theme: ThemeData( | |
primarySwatch: Colors.blue, | |
), | |
home: MyHomePage(), | |
); | |
} | |
} | |
class MyHomePage extends StatefulWidget { | |
@override | |
_MyHomePageState createState() => _MyHomePageState(); | |
} | |
enum RunningState { stopped, running, paused } | |
final _options = [ | |
{"name": "Kochwäsche 30°C", "duration": 150}, | |
{"name": "Kochwäsche 40°C", "duration": 155} | |
]; | |
class _MyHomePageState extends State<MyHomePage> { | |
RunningState state = RunningState.stopped; | |
int _counter = 0; | |
String _program = _options.first["name"]; | |
void _onProgramChange(String newValue) { | |
setState(() { | |
if (_counter == 0) { | |
_counter = 240; | |
} else {} | |
_program = newValue; | |
}); | |
} | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
body: Center( | |
child: Column( | |
mainAxisAlignment: MainAxisAlignment.center, | |
children: <Widget>[ | |
DropdownButton<String>( | |
value: _program, | |
icon: Icon(Icons.arrow_downward), | |
iconSize: 24, | |
elevation: 16, | |
style: TextStyle(color: Colors.deepPurple), | |
underline: Container( | |
height: 2, | |
color: Colors.deepPurpleAccent, | |
), | |
onChanged: _onProgramChange, | |
items: _options.map<DropdownMenuItem<String>>((Map value) { | |
return DropdownMenuItem<String>( | |
value: value["name"], | |
child: Text(value["name"]), | |
); | |
}).toList(), | |
), | |
Text( | |
'You have pushed the button this many times:', | |
), | |
Text( | |
'$_counter', | |
style: Theme.of(context).textTheme.headline4, | |
), | |
], | |
), | |
)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment