Created
March 1, 2022 17:14
-
-
Save romanejaquez/22ddbddfa59a802ebae34f3e552d65c3 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
import 'package:flutter/material.dart'; | |
import 'package:intl/intl.dart' show toBeginningOfSentenceCase; | |
const 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: Test(), | |
), | |
), | |
); | |
} | |
} | |
enum Locations { | |
belgium, | |
germany, | |
spain | |
} | |
class Test extends StatefulWidget { | |
@override | |
_TestState createState() => _TestState(); | |
} | |
class _TestState extends State<Test> { | |
Locations? _selectedLocation; | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
appBar: AppBar( | |
title: Text('hi'), | |
), | |
drawer: Drawer(), | |
body: Container( | |
padding: EdgeInsets.all(7), | |
child: Center( | |
child: Column( | |
children: [ | |
SizedBox( | |
height: 40, | |
), | |
DropdownButton( | |
// Not necessary for Option 1 | |
value: _selectedLocation, | |
onChanged: (Locations? newValue) { | |
setState(() { | |
_selectedLocation = newValue; | |
}); | |
}, | |
items: Locations.values.map((location) { | |
return DropdownMenuItem( | |
child: Text(toBeginningOfSentenceCase(location.name).toString()), | |
value: location, | |
); | |
}).toList(), | |
), | |
SizedBox( | |
height: 40, | |
), | |
Text('Option 2'), | |
SizedBox( | |
height: 40, | |
), | |
], | |
), | |
), | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment