Flutter 颤振布局和间距
所以我试着让我的输出看起来像这样,这是我目前的进展 我尝试将我的小部件放入容器中,但当我尝试调整文本的填充时,卡片和日历也会发生同样的情况。此外,我还试图删除日历上的月份文本,我在论坛上得到了日历的代码,所以我真的不知道如何解决它 这是我的代码:Flutter 颤振布局和间距,flutter,layout,frontend,flutter-layout,padding,Flutter,Layout,Frontend,Flutter Layout,Padding,所以我试着让我的输出看起来像这样,这是我目前的进展 我尝试将我的小部件放入容器中,但当我尝试调整文本的填充时,卡片和日历也会发生同样的情况。此外,我还试图删除日历上的月份文本,我在论坛上得到了日历的代码,所以我真的不知道如何解决它 这是我的代码: @override Widget build(BuildContext context) { return Scaffold( appBar: buildCalendarPageAppBar(), body: Container( ma
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: buildCalendarPageAppBar(),
body: Container(
margin: EdgeInsets.only(top: 15, bottom: 10, left: 17, right: 15),
width: MediaQuery.of(context).size.width,
child: Column(children: [
Text(
"*Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt
ut labore et dolore magna aliqua.",
maxLines: 4,
overflow: TextOverflow.ellipsis,
textAlign: TextAlign.start,
style: TextStyle(
fontFamily: "DMSans",
letterSpacing: -0.2,
fontSize: 15.0,
color: Colors.grey,
fontWeight: FontWeight.w500,
),
),
Container(
height: 400,
child: Card(
elevation: 2.0,
color: Colors.white,
child: Padding(
padding:
EdgeInsets.only(left: 10, right: 10, top: 10, bottom: 0),
child: Container(
width: Get.width,
height: 500,
child: Column(
children: <Widget>[
buildCalendar(),
],
)),
),
),
),
Container(height: 20),
buildGoButton(),
]),
),
);
}
PreferredSizeWidget buildCalendarPageAppBar() {
double profileDimension = 35;
return PreferredSize(
preferredSize: Size.fromHeight(58),
child: AppBar(
backgroundColor: Colors.white,
titleSpacing: 10,
leading: IconButton(
icon: Icon(
MdiIcons.chevronLeft,
size: 30,
color: Colors.blue,
),
onPressed: () {
Navigator.of(context).pop();
},
),
title: Row(
children: [
Padding(
padding: EdgeInsets.only(
top: 5,
bottom: 5,
),
child: Text(
'Appointment',
style: TextStyle(
color: Colors.black87,
fontFamily: 'Poppins',
fontSize: 16,
fontWeight: FontWeight.bold,
),
),
),
],
),
actions: [
Padding(
padding: EdgeInsets.only(
top: 10,
bottom: 10,
),
child: Container(
height: profileDimension,
width: profileDimension,
alignment: Alignment.center,
decoration: BoxDecoration(
color: Colors.white,
border: Border.all(
color: Colors.black54,
width: 2,
),
borderRadius: BorderRadius.circular(50),
),
child: ClipRRect(
borderRadius: BorderRadius.circular(50),
child: Image(
width: profileDimension,
height: profileDimension,
image: AssetImage(
'assets/images/profile-image.jpeg',
),
fit: BoxFit.cover,
),
),
),
),
SizedBox(width: 20),
],
),
);
}
Widget buildCalendar() {
return TableCalendar(
initialCalendarFormat: CalendarFormat.month,
calendarStyle: CalendarStyle(
todayColor: Colors.blue,
selectedColor: Theme.of(context).primaryColor,
todayStyle: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 18.0,
color: Colors.white)),
headerStyle: HeaderStyle(
centerHeaderTitle: true,
formatButtonDecoration: BoxDecoration(
color: Colors.blue,
borderRadius: BorderRadius.circular(22.0),
),
formatButtonTextStyle: TextStyle(color: Colors.white),
formatButtonShowsNext: false,
),
startingDayOfWeek: StartingDayOfWeek.monday,
onDaySelected: (context, date, events) {
print(date.toString());
},
builders: CalendarBuilders(
selectedDayBuilder: (context, date, events) => Container(
margin: const EdgeInsets.all(5.0),
alignment: Alignment.center,
decoration: BoxDecoration(
color: Colors.blue, borderRadius: BorderRadius.circular(8.0)),
child: Text(
date.day.toString(),
style: TextStyle(color: Colors.white),
)),
todayDayBuilder: (context, date, events) => Container(
margin: const EdgeInsets.all(5.0),
alignment: Alignment.center,
decoration: BoxDecoration(
color: Colors.blue, borderRadius: BorderRadius.circular(8.0)),
child: Text(
date.day.toString(),
style: TextStyle(color: Colors.white),
)),
),
calendarController: _controller,
);
}
Widget buildGoButton() {
return Padding(
padding: EdgeInsets.only(left: 20, top: 20, right: 40),
child: new Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Container(
child: SizedBox(
height: 50.0,
width: 150.0,
child: RaisedButton(
onPressed: () {},
child: Text("Cancel"),
shape: RoundedRectangleBorder(
side: BorderSide(color: Colors.blue, width: 1)),
color: Colors.white,
textColor: Colors.blue,
),
),
),
Container(
child: SizedBox(
height: 50.0,
width: 150.0,
child: RaisedButton(
onPressed: () {},
child: Text("Send Request"),
color: Colors.blue,
textColor: Colors.white,
),
),
),
],
),
);
}
}
@覆盖
小部件构建(构建上下文){
返回脚手架(
appBar:buildCalendarPageAppBar(),
主体:容器(
页边距:仅限边集(顶部:15,底部:10,左侧:17,右侧:15),
宽度:MediaQuery.of(context).size.width,
子项:列(子项:[
正文(
“*Lorem ipsum Door sit amet,高级顾问,临时顾问
“我们的劳动和财富是巨大的。”,
maxLines:4,
溢出:TextOverflow.省略号,
textAlign:textAlign.start,
样式:TextStyle(
fontFamily:“DMSans”,
字母间距:-0.2,
字体大小:15.0,
颜色:颜色。灰色,
fontWeight:fontWeight.w500,
),
),
容器(
身高:400,
孩子:卡片(
标高:2.0,
颜色:颜色,白色,
孩子:填充(
衬垫:
仅限边集(左:10,右:10,顶部:10,底部:0),
子:容器(
宽度:Get.width,
身高:500,
子:列(
儿童:[
buildCalendar(),
],
)),
),
),
),
货柜(高度:20),
buildGoButton(),
]),
),
);
}
PreferredSizeWidget buildCalendarPageAppBar(){
双轮廓尺寸=35;
返回首选大小(
首选尺寸:从高度开始的尺寸(58),
孩子:AppBar(
背景颜色:Colors.white,
标题间距:10,
领先:IconButton(
图标:图标(
mdicons.chevronLeft,
尺码:30,
颜色:颜色,蓝色,
),
已按下:(){
Navigator.of(context.pop();
},
),
标题:世界其他地区(
儿童:[
填充物(
填充:仅限边缘设置(
前五名,
底部:5,
),
子:文本(
"委任",,
样式:TextStyle(
颜色:颜色。黑色87,
fontFamily:“罂粟花”,
尺寸:16,
fontWeight:fontWeight.bold,
),
),
),
],
),
行动:[
填充物(
填充:仅限边缘设置(
前10名,
底部:10,
),
子:容器(
高度:外形尺寸,
宽度:外形尺寸,
对齐:对齐.center,
装饰:盒子装饰(
颜色:颜色,白色,
边界:边界(
颜色:颜色。黑色54,
宽度:2,
),
边界半径:边界半径。圆形(50),
),
孩子:ClipRRect(
边界半径:边界半径。圆形(50),
孩子:图像(
宽度:外形尺寸,
高度:外形尺寸,
图片:资产评估(
“assets/images/profile image.jpeg”,
),
适合:BoxFit.cover,
),
),
),
),
尺寸箱(宽度:20),
],
),
);
}
Widget buildCalendar(){
返回表日历(
initialCalendarFormat:CalendarFormat.month,
calendarStyle:calendarStyle(
今天的颜色:颜色。蓝色,
selectedColor:Theme.of(context).primaryColor,
今日风格:文本风格(
fontWeight:fontWeight.bold,
字体大小:18.0,
颜色:颜色。白色),
headerStyle:headerStyle(
是的,
FormatButton装饰:盒子装饰(
颜色:颜色,蓝色,
边界半径:边界半径。圆形(22.0),
),
formatButtonTextStyle:TextStyle(颜色:Colors.white),
formatButtonShowsNext:false,
),
星期一开始:星期一开始,
onDaySelected:(上下文、日期、事件){
打印(date.toString());
},
生成器:日历生成器(
selectedDayBuilder:(上下文、日期、事件)=>容器(
边距:所有常数边集(5.0),
对齐:对齐.center,
装饰:盒子装饰(
颜色:Colors.blue,borderRadius:borderRadius.circular(8.0)),
子:文本(
date.day.toString(),
样式:TextStyle(颜色:Colors.white),
)),
TodayBuilder:(上下文、日期、事件)=>容器(
边距:所有常数边集(5.0),
对齐:对齐.center,
装饰:盒子装饰(
颜色:Colors.blue,borderRadius:borderRadius.circular(8.0)),
子:文本(
date.day.toString(),
样式:TextStyle(颜色:Colors.white),
)),
),
日历控制器:_控制器,
);
}
Widget buildGoButton(){
返回填充(
填充:仅限边缘设置(左:20,上:20,右:40),
孩子:新的一排(
mainAxisAlignment:mainAxisAlignment.spaceBetween,
儿童:[
容器(
孩子:大小盒子(
身高:50.0,
宽度:150.0,
孩子:升起按钮(
按下:(){},
子项:文本(“取消”),
形状:圆形矩形边框(
边:边框边(颜色:Colors.blue,宽度:1)),
颜色:颜色,白色,
textColor:Colors.blue,
),
),
),
容器(
孩子:大小盒子(
身高:50.0,
宽度:150.0,
孩子:升起按钮(
按下:(){},
子项:文本(“发送请求”),
颜色:颜色,蓝色,
textColor:Colors.white,
),
),
),
],
),
);
}
}
我会很感激的
SizedBox(
height: 300.0,
)