gpt4 book ai didi

带有封面图片和头像的 Flutter 个人资料页面

转载 作者:IT王子 更新时间:2023-10-29 06:35:35 27 4
gpt4 key购买 nike

Sample profile page image

我想用封面图片和个人资料图片制作个人资料页面。我需要将个人资料照片堆叠在底部的封面照片上。请引用上面的照片。

下面是我到目前为止的代码

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
)
),
),
],
),
),
],
),
),
);
}
}

最佳答案

您需要使用 Stack小部件。

此示例代码显示了您正在寻找的内容。

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
),
),
)
],
),
);
}
}

关于带有封面图片和头像的 Flutter 个人资料页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51351257/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com