自定义列表项中按钮的位置

时间:2021-05-08 17:25:02

标签: android flutter flutter-layout flutter-widget

我正在尝试 [![make the button ][1]][1] 在列表项的角落,但它不起作用 这是我试过的

Container(
                margin: EdgeInsets.all(5),
                padding: EdgeInsets.all(10),
                color: Colors.black12,
                child: Row(
                  mainAxisSize: MainAxisSize.max,
                  children: [
                    Container(
                      height: 100,
                      width: 100,
                      color: Colors.black,
                      child: Image.network(_items[index]['product_img']),
                    ),
                    Container(
                      child: Column(
                        mainAxisSize: MainAxisSize.max,
                        crossAxisAlignment: CrossAxisAlignment.end,
                        children: [
                          Container(
                            child: Container(
                              padding: const EdgeInsets.all(8.0),
                              child: Text(_items[index]['product_name']),
                            ),
                          ),
                          Container(
                            padding: const EdgeInsets.all(8.0),
                            child: Text('M.R.P:  ₹  ' +
                                _items[index]['product_price']),
                          ),
                          Container(
                            child: Row(
                              mainAxisSize: MainAxisSize.max,
                              crossAxisAlignment: CrossAxisAlignment.end,
                              children: [
                                Align(
                                  alignment: Alignment.bottomRight,
                                  child: Container(
                                    padding: EdgeInsets.all(8),
                                    child: ElevatedButton(
                                      child: Text("Add +"),
                                      onPressed: () =>
                                          print("it's pressed"),
                                      style: ElevatedButton.styleFrom(
                                        primary: Colors.red,
                                        onPrimary: Colors.white,
                                        shape: RoundedRectangleBorder(
                                          borderRadius:
                                              BorderRadius.circular(32.0),
                                        ),
                                      ),
                                    ),
                                  ),
                                ),
                              ],
                            ),
                          )
                        ],
                      ),
                    )

也尝试设置大小,但这也不起作用,在其中一个建议中,我被告知要放置 crossAxis,我尝试过但仍然无法正常工作 [1]:https://i.stack.imgur.com/RQ1hY.png

0 个答案:

没有答案