Flutter Listview.builder 的最后一个元素更改其对齐方式,甚至所有其他元素都正确显示

问题描述 投票:0回答:1

下面的代码呈现元素列表,其中所有元素都按照提到的对齐方式正确显示,但最后一个元素意外地改变了它的对齐方式:

Expanded(
                child: Container(
                    width: maxWidth,
                    // height: maxHeight,
                    // height: h10p * 3,
                    decoration: const BoxDecoration(
                        color: Colours.white,
                        borderRadius: BorderRadius.only(
                          topLeft: Radius.circular(26),
                          topRight: Radius.circular(26),
                        )),
                    child: Column(
                      mainAxisAlignment: MainAxisAlignment.start,
                      children: [
                        Padding(
                          padding: const EdgeInsets.only(left: 18, top: 8),
                          child: Row(
                            children: [
                              InkWell(
                                  onTap: () {
                                    Navigator.pop(context);
                                  },
                                  child: Icon(Icons.circle_sharp)
                                  // SvgPicture.asset(
                                  //     "assets/images/arrowLeft.svg"),
                                  ),
                            ],
                          ),
                        ),
                        Flexible(
                          child: SizedBox(
                            child: Padding(
                              padding: const EdgeInsets.only(
                                left: 6,
                                right: 7,
                                top: 3,
                              ),
                              child: ListView.builder(
                                  padding: EdgeInsets.zero,

                                  // scrollDirection: Axis.vertical,
                                  shrinkWrap: true,
                                  itemCount: transLenght.length,
                                  itemBuilder: (context, index) {
                                    print(
                                        'invtr lengh ${transLenght.length}');
                                    // List trns = transLenght[index];

                                    final trType = transLenght[index]
                                        ['transaction_type'];

                                    final trAmount =
                                        transLenght[index]['amount'];
                                    String tramt =
                                        double.parse(trAmount.toString())
                                            .toStringAsFixed(2);
                                    final trDate = transLenght[index]
                                        ['transaction_date'];
                                    DateTime trdt = DateTime.parse(
                                        trDate); //invoice date

                                    String transdt =
                                        DateFormat("dd-MMM-yyyy")
                                            .format(trdt);
                                    final trRemark =
                                        transLenght[index]['remark'];
                                    final trinterest = transLenght[index]
                                            ['interest'] ??
                                        '';
                                    final trDiscount = transLenght[index]
                                            ['discount']
                                        .toString();
                                    String discnt =
                                        double.parse(trDiscount.toString())
                                            .toStringAsFixed(2);
                                    final amtCleared = transLenght[index]
                                        ['transaction_amount'];

                                    return
                                        // Padding(
                                        //     padding:
                                        //         const EdgeInsets.symmetric(vertical: 5),
                                        //     child:

                                        Card(
                                            shadowColor: Color.fromARGB(
                                                255, 245, 175, 45),
                                            elevation: 5,
                                            child: Padding(
                                              padding:
                                                  const EdgeInsets.only(
                                                left: 11,
                                                right: 14,
                                                top: 12,
                                              ),
                                              child: Row(
                                                mainAxisAlignment:
                                                    MainAxisAlignment.start,
                                                children: [
                                                  Column(
                                                    crossAxisAlignment:
                                                        CrossAxisAlignment
                                                            .start,
                                                    children: [
                                                      Text(
                                                        "Transaction Type",
                                                        style: TextStyle(
                                                          fontSize: 13,
                                                        ),
                                                      ),
                                                      Text(
                                                        "$trType",
                                                        style: TextStyle(
                                                            fontSize: 15,
                                                            fontWeight:
                                                                FontWeight
                                                                    .bold),
                                                      ),
                                                      SizedBox(height: 15),
                                                      Text(
                                                        "Transaction Amount",
                                                        style: TextStyle(
                                                          fontSize: 13,
                                                        ),
                                                      ),
                                                      Text(
                                                        "$tramt",
                                                        style: TextStyle(
                                                            fontSize: 15,
                                                            fontWeight:
                                                                FontWeight
                                                                    .bold),
                                                      ),
                                                      SizedBox(height: 15),
                                                      Text(
                                                        "Transaction Date",
                                                        style: TextStyle(
                                                          fontSize: 13,
                                                        ),
                                                      ),
                                                      Text(
                                                        "$transdt",
                                                        style: TextStyle(
                                                            fontSize: 15,
                                                            fontWeight:
                                                                FontWeight
                                                                    .bold),
                                                      ),
                                                      SizedBox(height: 15),
                                                      Text(
                                                        "Amount Cleared",
                                                        style: TextStyle(
                                                          fontSize: 13,
                                                        ),
                                                      ),
                                                      Text(
                                                        "$amtCleared",
                                                        style: TextStyle(
                                                            fontSize: 15,
                                                            fontWeight:
                                                                FontWeight
                                                                    .bold),
                                                      ),
                                                      SizedBox(height: 6),
                                                    ],
                                                  ),
                                                  Expanded(
                                                      child: SizedBox()),
                                                  Column(
                                                    mainAxisAlignment:
                                                        MainAxisAlignment
                                                            .start,
                                                    crossAxisAlignment:
                                                        CrossAxisAlignment
                                                            .start,
                                                    children: [
                                                      Text(
                                                        "Interest",
                                                        style: TextStyle(
                                                          fontSize: 13,
                                                        ),
                                                      ),
                                                      Text(
                                                        "$trinterest",
                                                        style: TextStyle(
                                                            fontSize: 15,
                                                            fontWeight:
                                                                FontWeight
                                                                    .bold),
                                                      ),
                                                      SizedBox(height: 15),
                                                      Text(
                                                        "Discount",
                                                        style: TextStyle(
                                                          fontSize: 13,
                                                        ),
                                                      ),
                                                      Text(
                                                        "$discnt",
                                                        style: TextStyle(
                                                            fontSize: 15,
                                                            fontWeight:
                                                                FontWeight
                                                                    .bold),
                                                      ),
                                                      SizedBox(height: 15),
                                                      Text(
                                                        "Remarks",
                                                        style: TextStyle(
                                                          fontSize: 13,
                                                        ),
                                                      ),
                                                      Text(
                                                        "$trRemark",
                                                        style: TextStyle(
                                                            fontSize: 14,
                                                            fontWeight:
                                                                FontWeight
                                                                    .bold),
                                                      ),
                                                      // SizedBox(height: 40),
                                                      Text(
                                                        "",
                                                        style: TextStyle(
                                                          fontSize: 12,
                                                        ),
                                                      ),
                                                      Text(
                                                        "",
                                                        style: TextStyle(
                                                            fontSize: 14,
                                                            fontWeight:
                                                                FontWeight
                                                                    .bold),
                                                      ),
                                                      Text(
                                                        "",
                                                        style: TextStyle(
                                                          fontSize: 12,
                                                        ),
                                                      ),
                                                      Text(
                                                        "",
                                                        style: TextStyle(
                                                          fontSize: 12,
                                                        ),
                                                      ),
                                                    ],
                                                  )
                                               
                                                ],
                                              ),
                                            ));
                                  }),
                            ),
                          ),
                        ),
                      ],
                    )))

flutter dart widget alignment flutter-listview
1个回答
0
投票

这是由于 Discount AppliedCredit Note

的文本长度

检查您的 Remark TextView 值,使其宽度保持静态,以便大文本值应该换行

© www.soinside.com 2019 - 2024. All rights reserved.