【发布时间】:2019-08-13 00:19:01
【问题描述】:
我正在尝试在我的 sliver 应用栏上包含一个圆形个人资料图像按钮,但 sliver 应用栏并没有完全正确地呈现它。这就是我得到的,我怎样才能在银色应用栏上实现圆形个人资料图像?
我的代码:
@override
Widget build(BuildContext context) {
return Scaffold(
body: CustomScrollView(
slivers: <Widget>[
SliverAppBar(
title: Text('Home'),
leading: Container(),
actions: <Widget>[
IconButton(
icon: Icon(Icons.notifications),
onPressed: () {}),
Padding(
padding: const EdgeInsets.all(8.0),
child: InkWell(
child: Container(
height: 30,
width: 30,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(25.0),
image: DecorationImage(image: AssetImage('assets/images/blank_profile.png'))
),
),
onTap: () => Navigator.push(context, new MaterialPageRoute(builder: (BuildContext context) => ProfilePage())),
),
),
],
),
使用 CircleAvatar:
@override
Widget build(BuildContext context) {
return Scaffold(
body: CustomScrollView(
slivers: <Widget>[
SliverAppBar(
title: Text('Home'),
backgroundColor: Colors.deepOrange,
leading: Container(),
actions: <Widget>[
IconButton(
icon: Icon(Icons.notifications),
onPressed: () {}),
CircleAvatar(
backgroundImage: AssetImage('assets/images/blank_profile.png'),
minRadius: 28,
),
],
),
【问题讨论】:
-
仍然无法正确渲染
-
在任何现代应用程序的应用程序栏上都可以找到圆形图像我相信您遇到过用户个人资料图像在应用程序栏上显示为圆形图像的应用程序
标签: flutter flutter-layout flutter-sliver