Skip to content

Instantly share code, notes, and snippets.

@SebRut
Last active January 9, 2020 10:18
Show Gist options
  • Save SebRut/48d2c61223107993e90a2a7591eaca6b to your computer and use it in GitHub Desktop.
Save SebRut/48d2c61223107993e90a2a7591eaca6b to your computer and use it in GitHub Desktop.
subway calc mock
import 'package:flutter/material.dart';
final Color darkBlue = Color.fromARGB(255, 18, 32, 47);
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData.dark().copyWith(scaffoldBackgroundColor: darkBlue),
debugShowCheckedModeBanner: false,
home: Scaffold(
body: Center(child: SubCalcWidget()),
),
);
}
}
class SubCalcState extends State<SubCalcWidget> {
var _departureTime = DateTime.now();
int _subAmount = 3;
int _subTime = 10;
int _wayTime = 10;
@override
Widget build(BuildContext context) {
return Column(children: [
Text("Subway Abfahrtsdeterminator"),
TextField(
decoration: const InputDecoration(
border: OutlineInputBorder(),
labelText: 'Abfahrtszeit',
)),
SizedBox(height: 10),
TextField(
onChanged: (newVal) => setState(() {
_subAmount = int.parse(newVal);
}),
decoration: const InputDecoration(
border: OutlineInputBorder(),
labelText: 'Anzahl Subs',
)),
SizedBox(height: 10),
TextField(
onChanged: (newVal) => setState(() {
_subTime = int.parse(newVal);
}),
decoration: const InputDecoration(
border: OutlineInputBorder(),
labelText: 'Zeit in min/Sub',
)),
SizedBox(height: 10),
TextField(
onChanged: (newVal) => setState(() {
_wayTime = int.parse(newVal);
}),
decoration: const InputDecoration(
border: OutlineInputBorder(),
labelText: 'Weglaufzeit in min',
)),
SizedBox(height: 20),
Text("Los geht's um: " +
_departureTime
.add(Duration(minutes: _subAmount * _subTime - _wayTime))
.toString())
]);
}
}
class SubCalcWidget extends StatefulWidget {
@override
SubCalcState createState() => SubCalcState();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment