【问题标题】:moving IconButton on Container flutter在容器颤动上移动 IconButton
【发布时间】:2021-12-02 01:39:33
【问题描述】:

当我想在我的个人资料图片上移动图标按钮时遇到了一些麻烦 我只想使用堆栈将它移动到图片的右下角,这是我尝试过的一些图片i want to move the image button on green circle that i put 这是我写的代码

 Center(
                child: Column(
                  children: <Widget>[
                    Stack(
                      children: [
                        Container(
                          margin: EdgeInsets.only(bottom: defaultSize),
                          height: defaultSize * 15,
                          width: defaultSize * 15,
                          decoration: BoxDecoration(
                            shape: BoxShape.circle,
                            border: Border.all(
                                color: Colors.white, width: defaultSize * 0.5),
                            image: DecorationImage(
                              fit: BoxFit.cover,
                              image: NetworkImage(
                                  'https://th.bing.com/th/id/OIP.1FbFcWycnyeemiMMsoIJ7gHaF7?w=182&h=145&c=7&r=0&o=5&dpr=1.25&pid=1.7'),
                            ),
                          ),
                          child: Positioned(
                              right: 0,
                              bottom: 0,
                              child: Container(
                                child: IconButton(
                                    onPressed: () {}, icon: Icon(Icons.image)),
                              )),
                        ),
                      ],
                    ),
                    Text("Nama Kamu Siapa ")
                  ],

【问题讨论】:

    标签: android visual-studio flutter android-studio dart


    【解决方案1】:

    错误:您的 Positioned Widget 是 Container 的子级。

    你必须让它成为堆栈的子节点:

    Stack(
                            children: [
                              Container(
                                height: 100,
                                width: 100,
                                decoration: BoxDecoration(
                                  shape: BoxShape.circle,
                                  image: DecorationImage(
                                    fit: BoxFit.cover,
                                    image: NetworkImage(
                                        'https://th.bing.com/th/id/OIP.1FbFcWycnyeemiMMsoIJ7gHaF7?w=182&h=145&c=7&r=0&o=5&dpr=1.25&pid=1.7'),
                                  ),
                                ),
                              ),
                              Positioned(
                                  right: 0,
                                  bottom: 0,
                                  child: Icon(Icons.image)),
                            ],
                          )
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-04-16
      • 1970-01-01
      • 1970-01-01
      • 2022-10-17
      • 1970-01-01
      • 2021-05-30
      • 2022-08-18
      • 2020-01-30
      相关资源
      最近更新 更多