Created
July 26, 2018 08:07
-
-
Save atreeon/dcf5079d3438952d68de38aecc9a97af to your computer and use it in GitHub Desktop.
Text and Dropdown, changing focus
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'; | |
class TextAndDropdown extends StatefulWidget { | |
@override | |
_TextAndDropdownState createState() => _TextAndDropdownState(); | |
} | |
class _TextAndDropdownState extends State<TextAndDropdown> { | |
int selectedDropdown; | |
String selectedText; | |
final textController = new TextEditingController(); | |
@override | |
void initState() { | |
super.initState(); | |
selectedDropdown = 1; | |
textController.addListener(() => print('')); | |
} | |
@override | |
Widget build(BuildContext context) { | |
return new Scaffold( | |
appBar: new AppBar( | |
title: new Text('Text and dropdown'), | |
), | |
body: Container( | |
child: Column( | |
children: [ | |
Padding( | |
padding: EdgeInsets.all(10.0), | |
), | |
DropdownButton(value: selectedDropdown, onChanged: _dropdownChange, items: [ | |
DropdownMenuItem( | |
child: Text('First'), | |
value: 1, | |
), | |
DropdownMenuItem(child: Text('Seconds')), | |
]), | |
TextField(controller: textController), | |
], | |
), | |
), | |
); | |
} | |
void _dropdownChange(val) { | |
setState(() { | |
selectedDropdown = val; | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment