Flutter 带封面图像和头像的颤振个人资料页面
我想用封面图片和个人资料图片制作个人资料页面。我需要把个人资料照片堆叠在封面照片的底部。请参考以上照片以供参考 下面是我到目前为止的代码Flutter 带封面图像和头像的颤振个人资料页面,flutter,flutter-layout,avatar,Flutter,Flutter Layout,Avatar,我想用封面图片和个人资料图片制作个人资料页面。我需要把个人资料照片堆叠在封面照片的底部。请参考以上照片以供参考 下面是我到目前为止的代码 class AccountPageState extends State<AccountPage> { @override Widget build(BuildContext context) { return Scaffold( body: Container( height: 170.0,
class AccountPageState extends State<AccountPage> {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Container(
height: 170.0,
width: double.infinity,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage("assets/images/erev/background.png"),
fit: BoxFit.cover,
),
boxShadow: [new BoxShadow(color: Colors.black, blurRadius: 8.0)],
color: Colors.green),
child: Column(
children: <Widget>[
Padding(
padding: const EdgeInsets.only(
top: 60.0, bottom: 18.0, right: 18.0, left: 18.0),
child: Row(
children: <Widget>[
Container(
height: 60.0,
width: 60.0,
decoration: BoxDecoration(
shape: BoxShape.circle,
image: DecorationImage(
image: new AssetImage("assets/images/erev/admin.jpeg"),
fit: BoxFit.cover
)
),
),
],
),
),
],
),
),
);
}
}
类AccountPageState扩展状态{
@凌驾
小部件构建(构建上下文){
返回脚手架(
主体:容器(
身高:170.0,
宽度:double.infinity,
装饰:盒子装饰(
图像:装饰图像(
图像:AssetImage(“assets/images/erev/background.png”),
适合:BoxFit.cover,
),
boxShadow:[新的boxShadow(颜色:Colors.black,blurRadius:8.0)],
颜色:颜色。绿色),
子:列(
儿童:[
填充物(
填充:仅限常量边设置(
顶部:60.0,底部:18.0,右侧:18.0,左侧:18.0),
孩子:排(
儿童:[
容器(
身高:60.0,
宽度:60.0,
装饰:盒子装饰(
形状:BoxShape.circle,
图像:装饰图像(
图像:新资产图像(“资产/images/erev/admin.jpeg”),
适合:BoxFit.cover
)
),
),
],
),
),
],
),
),
);
}
}
您需要使用小部件
此示例代码显示了您要查找的内容
import 'package:flutter/material.dart';
void main() => runApp(new MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new MaterialApp(
debugShowCheckedModeBanner: false,
title: 'Stack Demo',
home: new StackDemo(),
);
}
}
class StackDemo extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text('Stack Demo'),),
body: Stack(
alignment: Alignment.center,
children: <Widget>[
// background image and bottom contents
Column(
children: <Widget>[
Container(
height: 200.0,
color: Colors.orange,
child: Center(
child: Text('Background image goes here'),
),
),
Expanded(
child: Container(
color: Colors.white,
child: Center(
child: Text('Content goes here'),
),
),
)
],
),
// Profile image
Positioned(
top: 150.0, // (background container size) - (circle height / 2)
child: Container(
height: 100.0,
width: 100.0,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Colors.green
),
),
)
],
),
);
}
}
导入“包装:颤振/材料.省道”;
void main()=>runApp(新的MyApp());
类MyApp扩展了无状态小部件{
@凌驾
小部件构建(构建上下文){
返回新材料PP(
debugShowCheckedModeBanner:false,
标题:“堆栈演示”,
主页:新StackDemo(),
);
}
}
类StackDemo扩展了无状态小部件{
@凌驾
小部件构建(构建上下文){
返回脚手架(
appBar:appBar(标题:Text('Stack Demo'),),
主体:堆栈(
对齐:对齐.center,
儿童:[
//背景图像和底部内容
纵队(
儿童:[
容器(
高度:200.0,
颜色:颜色。橙色,
儿童:中心(
子:文本('背景图像在此处'),
),
),
扩大(
子:容器(
颜色:颜色,白色,
儿童:中心(
child:Text('内容在此处'),
),
),
)
],
),
//轮廓图像
定位(
顶部:150.0,//(背景容器大小)-(圆圈高度/2)
子:容器(
高度:100.0,
宽度:100.0,
装饰:盒子装饰(
形状:BoxShape.circle,
颜色:颜色。绿色
),
),
)
],
),
);
}
}
你好,Emmanuel,请粘贴到目前为止的实时代码,以便能够帮助您并避免下载提醒。我已经添加了代码now@EmmanuelFache当你问一个问题时,记住其他开发人员以及他们是如何搜索问题的。尽量使你的问题标题和描述更详细