飞镖 – Re:在颤动中创建一个下拉按钮
发布时间:2020-12-14 14:52:57 所属栏目:百科 来源:网络整理
导读:我在构建中使用了DropDownButton,但我希望箭头显示在最后,而下拉项目将从箭头显示,但在我的应用程序中,它们从顶部显示.我附上截图供您参考. 请告诉我如何改变这个或者是否还有其他方法可以简单地创建一个下拉菜单. 一个例子将非常感激. 请原谅我的代码,因为
我在构建中使用了DropDownButton,但我希望箭头显示在最后,而下拉项目将从箭头显示,但在我的应用程序中,它们从顶部显示.我附上截图供您参考.
请告诉我如何改变这个或者是否还有其他方法可以简单地创建一个下拉菜单. 一个例子将非常感激. 请原谅我的代码,因为我是编程新手,欢迎提出任何意见或建议. 非常感谢, import 'package:flutter/material.dart'; import 'package:flutter/widgets.dart'; import 'dart:ui'; void main(){ runApp(new BranchSetup()); } class BranchSetup extends StatefulWidget { @override State<StatefulWidget> createState() { return new _BranchSetupState(); } } class _BranchSetupState extends State<BranchSetup> with WidgetsBindingObserver { @override Widget build(BuildContext context){ return new MaterialApp( theme: new ThemeData( primaryColor: const Color(0xFF229E9C),),title: 'Branch Setup',home: new Scaffold( body: new Container( child: new ListView( children: <Widget>[ new Container( margin: const EdgeInsets.all(16.0),child: new Row( children: <Widget>[ new Expanded( child: new TextFormField( decoration: new InputDecoration([enter image description here][1] labelText: 'Branch Name',],new Container( margin: const EdgeInsets.all(16.0),child: new DropdownButton<String>( items: <String>['Mens','Womans'] .map((String value) { return new DropdownMenuItem<String>( value: value,child: new Text(value),); } ).toList(),onChanged: null,); } } 解决方法
这看起来像Flutter中的一个错误.我提交了
issue.
在此期间,您可以通过将DropdownButton包装在列中来解决此问题. import 'package:flutter/material.dart'; void main() { runApp(new MaterialApp(home: new DemoApp())); } class DemoApp extends StatelessWidget { @override Widget build(BuildContext context) { return new Scaffold( appBar: new AppBar(title: new Text('DropdownButton Example')),body: new ListView( children: [ new Column( children: <Widget>[ new DropdownButton<String>( items: <String>['Foo','Bar'].map((String value) { return new DropdownMenuItem<String>( value: value,); }).toList(),onChanged: (_) {},); } } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |