Flutter 颤振下拉按钮中可能存在渲染错误
我正在Flitter web上开发Spotify UI克隆(web版),并实现了带有后退/前进按钮的顶部栏和右侧的用户栏,作为一个列,但他们意识到该栏固定在其位置上,并且您的音乐建议会在其中滚动 我的解决方案是设置一个顶部有条的堆栈,如下所示:Flutter 颤振下拉按钮中可能存在渲染错误,flutter,flutter-web,Flutter,Flutter Web,我正在Flitter web上开发Spotify UI克隆(web版),并实现了带有后退/前进按钮的顶部栏和右侧的用户栏,作为一个列,但他们意识到该栏固定在其位置上,并且您的音乐建议会在其中滚动 我的解决方案是设置一个顶部有条的堆栈,如下所示: _mainScreen(BuildContext context){ Size size = MediaQuery.of(context).size; return Container( padding: EdgeInse
_mainScreen(BuildContext context){
Size size = MediaQuery.of(context).size;
return Container(
padding: EdgeInsets.symmetric(horizontal: 15.0),
color: Color.fromRGBO(22, 22, 22, 1.0),
height: double.infinity,
width: size.width*0.82,
child: Stack(
children: <Widget>[
SingleChildScrollView(
child: Column(
children: <Widget>[
SizedBox(height: size.height*0.09,),
_suggestionLists(size)
],
),
),
_topBar(size)
],
)
);
}
\u主屏幕(构建上下文){
Size Size=MediaQuery.of(context).Size;
返回容器(
填充:边缘组。对称(水平:15.0),
颜色:color.fromRGBO(22,22,22,1.0),
高度:双无限,
宽度:尺寸。宽度*0.82,
子:堆栈(
儿童:[
SingleChildScrollView(
子:列(
儿童:[
大小框(高度:大小。高度*0.09,),
_建议列表(大小)
],
),
),
_顶栏(尺寸)
],
)
);
}
然后发生了这样的事情:
在进行我之前提到的更改之前,它都不在那里。
以下是该小部件的代码:
_profileButtons(Size size){
return Container(
height: size.height*0.05,
padding: EdgeInsets.symmetric(horizontal: 5.0),
decoration: BoxDecoration(
color: Color.fromRGBO(15, 15, 15, 0.8),
borderRadius: BorderRadius.circular(100.0)
),
child: DropdownButton<String>(
dropdownColor: Color.fromRGBO(75, 75, 75, 1.0),
style: TextStyle(color: Colors.white),
hint: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Container(
padding: EdgeInsets.all(1.0),
child: Icon(Icons.person, color: Colors.white, size: 20,),
decoration: BoxDecoration(
color: Color.fromRGBO(75, 75, 75, 1.0),
border: Border.all(color: Color.fromRGBO(75, 75, 75, 1.0)),
borderRadius: BorderRadius.circular(100.0)
),
),
SizedBox(width: 5.0,),
Text('Your UserName', style: TextStyle(color: Colors.white),),
],
),
icon: Icon(Icons.arrow_drop_down, color: Colors.white,),
items: <String>['Account', 'Profile', 'Log out'].map((String value) {
return new DropdownMenuItem<String>(
value: value,
child: new Text(value),
);
}).toList(),
onChanged: (_) {},
)
);
}
\u配置文件按钮(大小){
返回容器(
高度:尺寸。高度*0.05,
填充:边缘组。对称(水平:5.0),
装饰:盒子装饰(
颜色:color.fromRGBO(15,15,15,0.8),
边界半径:边界半径。圆形(100.0)
),
孩子:下拉按钮(
dropdownColor:Color.fromRGBO(75,75,75,1.0),
样式:TextStyle(颜色:Colors.white),
提示:行(
crossAxisAlignment:crossAxisAlignment.center,
儿童:[
容器(
填充:所有边缘设置(1.0),
子:图标(Icons.person,颜色:Colors.white,大小:20,),
装饰:盒子装饰(
颜色:颜色。来自RGBO(75,75,75,1.0),
边框:border.all(颜色:color.fromRGBO(75,75,75,1.0)),
边界半径:边界半径。圆形(100.0)
),
),
尺寸控制盒(宽度:5.0,),
Text('您的用户名',样式:Text样式(颜色:Colors.white),),
],
),
图标:图标(Icons.arrow\u下拉列表,颜色:Colors.white,),
项目:['Account','Profile','Log out'].map((字符串值){
返回新的DropdownMenuItem(
价值:价值,
子项:新文本(值),
);
}).toList(),
一旦改变:({},
)
);
}
我尝试过把容器、边框等弄乱一点,但我似乎没有发现它有什么问题,可能是渲染错误吗?
如果需要,我将提供额外的代码/详细信息您可以在下面复制粘贴运行完整代码
要隐藏下划线,可以使用
DropdownButtonHideUnderline
wrapDropdownButton
代码片段
DropdownButtonHideUnderline(
child: DropdownButton<String>(
DropdownButtonHideUnderline(
孩子:下拉按钮(
工作演示
完整代码
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: MyHomePage(),
);
}
}
class MyHomePage extends StatelessWidget {
_profileButtons(Size size) {
return Container(
height: size.height * 0.05,
padding: EdgeInsets.symmetric(horizontal: 5.0),
decoration: BoxDecoration(
color: Color.fromRGBO(15, 15, 15, 0.8),
borderRadius: BorderRadius.circular(100.0)),
child: DropdownButtonHideUnderline(
child: DropdownButton<String>(
dropdownColor: Color.fromRGBO(75, 75, 75, 1.0),
style: TextStyle(color: Colors.white),
hint: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Container(
padding: EdgeInsets.all(1.0),
child: Icon(
Icons.person,
color: Colors.white,
size: 20,
),
decoration: BoxDecoration(
color: Color.fromRGBO(75, 75, 75, 1.0),
border:
Border.all(color: Color.fromRGBO(75, 75, 75, 1.0)),
borderRadius: BorderRadius.circular(100.0)),
),
SizedBox(
width: 5.0,
),
Text(
'Your UserName',
style: TextStyle(color: Colors.white),
),
],
),
icon: Icon(
Icons.arrow_drop_down,
color: Colors.white,
),
items:
<String>['Account', 'Profile', 'Log out'].map((String value) {
return new DropdownMenuItem<String>(
value: value,
child: new Text(value),
);
}).toList(),
onChanged: (_) {},
),
));
}
@override
Widget build(BuildContext context) {
return Scaffold(appBar: AppBar(), body: _profileButtons(Size(800, 800)));
}
}
import'包装:flift/cupertino.dart';
进口“包装:颤振/材料.省道”;
void main(){
runApp(MyApp());
}
类MyApp扩展了无状态小部件{
@凌驾
小部件构建(构建上下文){
返回材料PP(
标题:“颤振演示”,
主题:主题数据(
主样本:颜色。蓝色,
),
主页:MyHomePage(),
);
}
}
类MyHomePage扩展了无状态小部件{
_配置文件按钮(大小){
返回容器(
高度:size.height*0.05,
填充:边缘组。对称(水平:5.0),
装饰:盒子装饰(
颜色:color.fromRGBO(15,15,15,0.8),
边界半径:边界半径。圆形(100.0)),
子项:DropdownButtonHideUnderline(
孩子:下拉按钮(
dropdownColor:Color.fromRGBO(75,75,75,1.0),
样式:TextStyle(颜色:Colors.white),
提示:行(
crossAxisAlignment:crossAxisAlignment.center,
儿童:[
容器(
填充:所有边缘设置(1.0),
子:图标(
一个人,
颜色:颜色,白色,
尺码:20,
),
装饰:盒子装饰(
颜色:颜色。来自RGBO(75,75,75,1.0),
边界:
Border.all(颜色:color.fromRGBO(75,75,75,1.0)),
边界半径:边界半径。圆形(100.0)),
),
大小盒子(
宽度:5.0,
),
正文(
“您的用户名”,
样式:TextStyle(颜色:Colors.white),
),
],
),
图标:图标(
Icons.arrow\u下拉菜单,
颜色:颜色,白色,
),
项目:
['Account'、'Profile'、'Log out'].map((字符串值){
返回新的DropdownMenuItem(
价值:价值,
子项:新文本(值),
);
}).toList(),
一旦改变:({},
),
));
}
@凌驾
小部件构建(构建上下文){
返回脚手架(appBar:appBar(),主体:_profileButtons(尺寸(800800));
}
}
我看不出这两段代码之间有任何联系,你能给我更多的代码吗?哦,我搞砸了,它缺少连接它们的代码,不管怎么说,有人回答了一些有希望的问题,我明天会试试的。干了它,很有魅力,非常感谢