Last active
September 11, 2024 11:38
-
-
Save slightfoot/f0b753606c97d8a2c06659803c12d858 to your computer and use it in GitHub Desktop.
Flutter Drop List Example with TextField
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'; | |
void main() | |
{ | |
final TextEditingController _controller = new TextEditingController(); | |
var items = ['Working a lot harder', 'Being a lot smarter', 'Being a self-starter', 'Placed in charge of trading charter']; | |
runApp( | |
new MaterialApp( | |
title: 'Drop List Example', | |
home: new Scaffold( | |
appBar: new AppBar(title: const Text('Drop List Example')), | |
body: new Center( | |
child: new Container( | |
child: new Column( | |
children: [ | |
new Padding( | |
padding: const EdgeInsets.all(24.0), | |
child: new Row( | |
children: <Widget>[ | |
new Expanded( | |
child: new TextField(controller: _controller) | |
), | |
new PopupMenuButton<String>( | |
icon: const Icon(Icons.arrow_drop_down), | |
onSelected: (String value) { | |
_controller.text = value; | |
}, | |
itemBuilder: (BuildContext context) { | |
return items.map<PopupMenuItem<String>>((String value) { | |
return new PopupMenuItem(child: new Text(value), value: value); | |
}).toList(); | |
}, | |
), | |
], | |
), | |
), | |
], | |
), | |
), | |
), | |
), | |
), | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
\
works like a charm bro!!