我试图在银条应用程序栏上添加一个圆圈轮廓图像按钮,但银条应用程序栏显示效果不佳。这就是我得到的,如何在条形应用栏上获得圆形轮廓图像?
我的代码:
@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,
),
],
),
答案 0 :(得分:1)
为此,您必须使用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'),
),
),
],
)