【发布时间】:2021-08-30 19:22:51
【问题描述】:
我已经制作了一个自定义抽屉 ui,但我希望其中包含用户详细信息,并且注销按钮不应该滚动。我使用了定位,但它给出了不正确的父级用法,并且在每个小部件上分别在堆栈中它不起作用我如何实现静态 ui 位置我不想让用户详细信息和注销按钮也随着滚动而移动我不想失去对不同屏幕尺寸的响应能力。
import 'package:avunja/commons/colors.dart';
import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart';
import 'onlinebutton.dart';
class InkWellDrawer extends StatefulWidget {
@override
_InkWellDrawerState createState() => _InkWellDrawerState();
}
class _InkWellDrawerState extends State<InkWellDrawer> {
bool _enable = false;
@override
Widget build(BuildContext ctxt) {
return Drawer(
child: Container(
color: Color(ReddishColor),
child: ListView(
children: <Widget>[
Container(
child: Column(
children: <Widget>[
SizedBox(
height: 10,
),
Padding(
padding: EdgeInsets.only(),
child: Container(
height: 80,
color: Color(0xFFBB0218),
child: Stack(
children: <Widget>[
Positioned(
child: Align(
alignment: Alignment.centerLeft,
child: Padding(
padding: EdgeInsets.only(left: 20),
child: CircleAvatar(
radius: 30.0,
backgroundImage:
AssetImage("assets/girl.png"),
backgroundColor: Colors.white,
),
),
),
),
Positioned(
child: Align(
alignment: Alignment.centerLeft,
child: Padding(
padding:
EdgeInsets.only(left: 90, bottom: 40),
child: Text(
"Angela Moury",
style: TextStyle(
fontWeight: FontWeight.w500,
color: Colors.white,
fontSize: 16),
)),
),
),
Positioned(
child: Align(
alignment: Alignment.centerLeft,
child: Padding(
padding: EdgeInsets.only(left: 90, top: 5),
child: Text(
"(254)7XX XX5 555",
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.w500,
fontSize: 14),
)),
),
),
Positioned(
child: Align(
alignment: Alignment.centerLeft,
child: Padding(
padding: EdgeInsets.only(left: 90, top: 45),
child: Text("carrie.m@avunja.com",
style: TextStyle(
fontWeight: FontWeight.w500,
fontSize: 14,
color: Colors.white)),
),
),
),
],
),
)),
Padding(
padding: EdgeInsets.only(left: 20, right: 20, top: 5),
child: Container(
child: Image.asset("assets/dividinglinedrawer.png"),
),
),
SizedBox(
height: 10,
),
Column(
children: <Widget>[
Padding(
padding: EdgeInsets.only(),
child: ListTile(
leading: Image.asset('assets/power.png'),
title: Text(
'Online Status',
style: TextStyle(fontSize: 14, color: Colors.white),
),
trailing: CustomSwitch(
value: _enable,
onChanged: (bool val) {
setState(() {
_enable = val;
});
},
),
onTap: () {},
),
),
Column(
children: <Widget>[
Padding(
padding: EdgeInsets.only(),
child: ListTile(
leading: Image.asset('assets/house.png'),
title: Text(
'Home',
style: TextStyle(
fontSize: 14, color: Colors.white),
),
onTap: () {},
),
),
],
),
Column(
children: <Widget>[
Padding(
padding: EdgeInsets.only(),
child: ListTile(
leading: Image.asset('assets/mail.png'),
title: Text(
'Inbox',
style: TextStyle(
fontSize: 14, color: Colors.white),
),
onTap: () {},
),
),
],
),
Column(
children: <Widget>[
Padding(
padding: EdgeInsets.only(),
child: ListTile(
leading: Image.asset('assets/notification.png'),
title: Text(
'Notifications',
style: TextStyle(
fontSize: 14, color: Colors.white),
),
onTap: () {},
),
),
],
),
SizedBox(
height: 5,
),
Padding(
padding: EdgeInsets.only(left: 20, right: 20, top: 5),
child: Container(
child: Image.asset("assets/dividinglinedrawer.png"),
),
),
SizedBox(
height: 5,
),
Column(
children: <Widget>[
Padding(
padding: EdgeInsets.only(),
child: ListTile(
leading: Image.asset('assets/account.png'),
title: Text(
'Account',
style: TextStyle(
fontSize: 14, color: Colors.white),
),
onTap: () {},
),
),
],
),
Column(
children: <Widget>[
Padding(
padding: EdgeInsets.only(),
child: ListTile(
leading: Image.asset('assets/payment.png'),
title: Text(
'Payment',
style: TextStyle(
fontSize: 14, color: Colors.white),
),
onTap: () {},
),
),
],
),
Column(
children: <Widget>[
Padding(
padding: EdgeInsets.only(),
child: ListTile(
leading: Image.asset('assets/topup.png'),
title: Text(
'Topup',
style: TextStyle(
fontSize: 14, color: Colors.white),
),
onTap: () {},
),
),
],
),
Column(
children: <Widget>[
Padding(
padding: EdgeInsets.only(),
child: ListTile(
leading: Image.asset('assets/withdraw.png'),
title: Text(
'Withdraw',
style: TextStyle(
fontSize: 14, color: Colors.white),
),
onTap: () {},
),
),
],
),
Column(
children: <Widget>[
Padding(
padding: EdgeInsets.only(),
child: ListTile(
leading: Image.asset('assets/bills.png'),
title: Text(
'Bills & Utilities',
style: TextStyle(
fontSize: 14, color: Colors.white),
),
onTap: () {},
),
),
],
),
SizedBox(
height: 5,
),
Padding(
padding: EdgeInsets.only(left: 20, right: 20, top: 5),
child: Container(
child: Image.asset("assets/dividinglinedrawer.png"),
),
),
SizedBox(
height: 5,
),
Column(
children: <Widget>[
Padding(
padding: EdgeInsets.only(),
child: ListTile(
leading: Image.asset('assets/reports.png'),
title: Text(
'Reports',
style: TextStyle(
fontSize: 14, color: Colors.white),
),
onTap: () {},
),
),
],
),
Column(
children: <Widget>[
Padding(
padding: EdgeInsets.only(),
child: ListTile(
leading: Image.asset('assets/transactions.png'),
title: Text(
'Transactions',
style: TextStyle(
fontSize: 14, color: Colors.white),
),
onTap: () {},
),
),
],
),
SizedBox(
height: 5,
),
Padding(
padding: EdgeInsets.only(left: 20, right: 20, top: 5),
child: Container(
child: Image.asset("assets/dividinglinedrawer.png"),
),
),
SizedBox(
height: 5,
),
Column(
children: <Widget>[
Padding(
padding: EdgeInsets.only(),
child: ListTile(
leading: Image.asset('assets/reward.png'),
title: Text(
'Rewards & Promotions',
style: TextStyle(
fontSize: 14, color: Colors.white),
),
onTap: () {},
),
),
],
),
Column(
children: <Widget>[
Padding(
padding: EdgeInsets.only(),
child: ListTile(
leading: Image.asset('assets/refer.png'),
title: Text(
'Refer',
style: TextStyle(
fontSize: 14, color: Colors.white),
),
onTap: () {},
),
),
],
),
SizedBox(
height: 5,
),
Padding(
padding: EdgeInsets.only(left: 20, right: 20, top: 5),
child: Container(
child: Image.asset("assets/dividinglinedrawer.png"),
),
),
SizedBox(
height: 5,
),
Column(
children: <Widget>[
Padding(
padding: EdgeInsets.only(),
child: ListTile(
leading: Image.asset('assets/support.png'),
title: Text(
'Support',
style: TextStyle(
fontSize: 14, color: Colors.white),
),
onTap: () {},
),
),
],
),
Column(
children: <Widget>[
Padding(
padding: EdgeInsets.only(),
child: ListTile(
leading: Image.asset('assets/settings.png'),
title: Text(
'Settings',
style: TextStyle(
fontSize: 14, color: Colors.white),
),
onTap: () {},
),
),
],
),
],
),
SizedBox(
height: 5,
),
Padding(
padding: EdgeInsets.only(left: 20, right: 20, top: 5),
child: Container(
child: Image.asset("assets/dividinglinedrawer.png"),
),
),
SizedBox(
height: 15,
),
Padding(
padding: EdgeInsets.only(),
child: Container(
height: 60,
color: Color(0xFFBB0218),
child: Padding(
padding: EdgeInsets.only(),
child: ListTile(
leading: Image.asset('assets/logout.png'),
title: Text(
'Logout',
style:
TextStyle(fontSize: 14, color: Colors.white),
),
onTap: () {},
),
),
)),
SizedBox(
height: 50,
child: Container(
height: 50,
),
)
],
),
),
],
),
),
);
}
}
【问题讨论】:
-
能否添加当前页面的截图和想要的结果?仅从代码很难想象这个问题:)
-
添加你想要的截图或图表? (正如@RohanThacker 所说)
-
截图会很棒!
-
添加了截图,我只希望它的配置文件部分是静态的。当我向下滚动抽屉中的其他选项时,它不应该滚动。同样适用于注销需要它修复
标签: firebase flutter dart flutter-layout flutter-dependencies