飞镖 – Re:在颤动中创建一个下拉按钮

飞镖 – Re:在颤动中创建一个下拉按钮,第1张

概述我在构建中使用了DropDownButton,但我希望箭头显示在最后,而下拉项目将从箭头显示,但在我的应用程序中,它们从顶部显示.我附上截图供您参考. 请告诉我如何改变这个或者是否还有其他方法可以简单地创建一个下拉菜单. 一个例子将非常感激. 请原谅我的代码,因为我是编程新手,欢迎提出任何意见或建议. 非常感谢, 马希. import 'package:flutter/material.dart' 我在构建中使用了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,);   }  }
解决方法@H_404_25@ 这看起来像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: (_) {},);  }}
总结

以上是内存溢出为你收集整理的飞镖 – Re:在颤动中创建一个下拉按钮全部内容,希望文章能够帮你解决飞镖 – Re:在颤动中创建一个下拉按钮所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://www.outofmemory.cn/web/1002621.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-22
下一篇 2022-05-22

发表评论

登录后才能评论

评论列表(0条)

保存