【问题标题】:I want a small circle in search bar icon is it possible我想在搜索栏图标中有一个小圆圈可以吗
【发布时间】:2020-03-21 03:09:21
【问题描述】:

我想要在搜索栏中包含边框的代码

代码如下

孩子:行( 孩子们: [ 图标按钮( 图标:图标( 图标.菜单, 颜色:Colors.black,

                        ),
                        onPressed: () {
                          print("your menu action here");
                          _scaffoldKey.currentState.openDrawer();
                        },

                        ),
                        Expanded(


                        child: TextField(
                          decoration: InputDecoration(

                            hintText: "Search",


                          ),
                        ),
                      ),

                        IconButton(
                        icon: Icon(

                          Icons.search,
                          color: Colors.red,
                        ),
                        onPressed: () {
                          print("your menu action here");
                        },
                      ),

                      ]
                    ),

【问题讨论】:

  • 我已添加代码
  • 你能给我代码吗..?

标签: flutter design-patterns flutter-layout flutter-animation


【解决方案1】:

child: Row(
      children: <Widget>[
        IconButton(
          icon: Icon(
            Icons.menu,
            color: Colors.black,
          ),
          onPressed: () {
            print("your menu action here");
            _scaffoldKey.currentState.openDrawer();
          },
        ),
        Expanded(
          child: Container(
            margin: EdgeInsets.only(right: 5.0),
            child: TextFormField(
              cursorColor: Colors.black,
              decoration: InputDecoration(
                focusedBorder: OutlineInputBorder(
                  gapPadding: 0.0,
                  borderRadius: BorderRadius.circular(30.0),
                  borderSide: BorderSide(
                    color: Colors.black87,
                    width: 1.0,
                  ),
                ),
                hintText: 'Search',
                fillColor: Colors.white,
                border: OutlineInputBorder(
                  gapPadding: 0.0,
                  borderRadius: BorderRadius.circular(30.0),
                  borderSide: BorderSide(
                    color: Colors.black87,
                    width: 1.0,
                  ),
                ),
                suffixIcon: Container(
                  decoration: BoxDecoration(
                      color: Colors.black,
                      shape: BoxShape.circle,
                      boxShadow: [
                        BoxShadow(
                          color: Colors.black38,
                          offset: Offset(-5.0, 0.0),
                          blurRadius: 10,
                        )
                      ]),
                  child: IconButton(
                    icon: Icon(
                      Icons.search,
                      color: Colors.white,
                    ),
                    onPressed: () {},
                  ),
                  /* child: FloatingActionButton(
                    onPressed: () {},
                    mini: true,
                    elevation: 5.0,
                    backgroundColor: Colors.black,
                    child: Icon(
                      Icons.search,
                    ),
                  ),*/
                ),
                filled: true,
                contentPadding: EdgeInsets.only(
                  left: 15.0,
                  top: 0.0,
                  bottom: 0.0,
                ),
              ),
            ),
          ),
        ),
      ],
    ),

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多