我正在尝试在我的条子应用栏上添加一个圆形轮廓图像按钮,但是条形图应用栏不能正确渲染它。这就是我得到的,如何在条子应用栏上获得圆形轮廓图像?
我的代码:
@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,
),
],
),
为此,你必须使用CircleAvatar。
这是您可以使用的代码:
SliverAppBar(
title: Text('Home'),
leading: Container(),
actions: <Widget>[
IconButton(
icon: Icon(Icons.notifications),
onPressed: () {}),
CircleAvatar(
child: ClipOval(
child: Image.asset('assets/images/blank_profile.png'),
),
),
],
)