首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何使用颤振/飞镖在卡片中左右创建图标

如何使用颤振/飞镖在卡片中左右创建图标
EN

Stack Overflow用户
提问于 2022-07-19 12:00:22
回答 1查看 50关注 0票数 1

我不知道如何改变我已经突出显示在右上角的图标。我已经使用了spceBetween,但仍然不影响更改。

代码语言:javascript
运行
复制
class _SidebarState extends State<Sidebar> {
  @override
  Widget build(BuildContext context) {
    return Container(
      decoration: BoxDecoration(
          color: Color.fromARGB(255, 44, 41, 56),
          boxShadow: [
            BoxShadow(
              color: Colors.grey.withOpacity(0.5),
              spreadRadius: 5,
              blurRadius: 7,
              offset: Offset(0, 3), // changes position of shadow
            ),
          ],
          borderRadius: BorderRadius.only(topRight: const Radius.circular(20))),
      child: Column(
        children: [
          Row(
            mainAxisAlignment: MainAxisAlignment.spaceEvenly,
            children: <Widget>[
              ClipRRect(
                  borderRadius: BorderRadius.all(Radius.circular(32.0)),
                  child: Row(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    children: [
                      Container(
                        child: Material(
                          shadowColor: Colors.transparent,
                          color: Colors.transparent,
                          child: IconButton(
                            icon: Icon(Icons.menu,
                                color: Color.fromARGB(255, 247, 243, 243)),
                            onPressed: widget.onSideBarPressed,
                          ),
                        ),
                      ),
                      Container(
                        color: Colors.amber,
                        child: Material(
                          shadowColor: Colors.transparent,
                          color: Colors.transparent,
                          child: IconButton(
                            icon: Icon(Icons.access_time,
                                color: Color.fromARGB(255, 247, 243, 243)),
                            onPressed: widget.onSideBarPressed,
                          ),
                        ),
                      )
                    ],
                  )),
              Expanded(
                flex: 2,
                child: Text(
                  widget.title,
                  textAlign: TextAlign.center,
                  style: const TextStyle(
                      color: Colors.white,
                      fontWeight: FontWeight.bold,
                      fontSize: 18,
                      decoration: TextDecoration.none),
                ),
              )
            ],
          ),
          Divider(
            height: 0,
          ),
          Expanded(
            flex: 2,
            child: Container(
              child: widget.body,
            ),
          )
        ],
      ),
    );
  }
}
EN

回答 1

Stack Overflow用户

发布于 2022-07-19 12:21:26

要在左边和右边显示一个图标,您应该在您的AppBar上使用Scaffold()小部件。要在开头(左)放置一个小部件,请使用leading属性,并在末尾(右)放置一个小部件,使用actions属性:

代码语言:javascript
运行
复制
return Scaffold(
      appBar: AppBar(
        leading: Icon(Icons.menu),
        actions: [Icon(Icons.search)],
      ),);

结果:

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/73036507

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档