簡體   English   中英

如何輸入已經在 flutter 列內的一行內的兩個列表視圖

[英]how to enter two list views which is inside one row which is already inside the column in flutter

我有一種情況我必須這樣做列-> 行-> 兩個列表視圖

我已經嘗試了很多解決方案但無法存儲這可能嗎??

Expanded(
  child: Row(
    // mainAxisAlignment: MainAxisAlignment.spaceBetween,
    children: [
      ListView.builder(
        shrinkWrap: true,
        itemCount: selectedMainCasteIds?.length,
        itemBuilder: (context, index) {
          return Text('${selectedMainCasteIds![index].mainCasteName}',style: TextStyle(fontSize: 10),);
        },
      ),
      Text('ddddd'),

      ListView.builder(
        shrinkWrap: true,
        itemCount: selectedMainCasteIds?.length,
        itemBuilder: (context, index) {
          return Text('${selectedMainCasteIds![index].mainCasteName}',style: TextStyle(fontSize: 10),);
        },
      ),
    ],
  ),
),

也用Expanded包裹你的Listview

Expanded(
  child: Row(
    // mainAxisAlignment: MainAxisAlignment.spaceBetween,
    children: [
      Expanded(
        child: ListView.builder(
          shrinkWrap: true,
          itemCount: 2,
          itemBuilder: (context, index) {
            return Text(
              'lorem ipsum dolor',
//                     style: TextStyle(fontSize: 10),
            );
          },
        ),
      ),
      Padding(
        padding: EdgeInsets.all(8),
        child: Text('ddddd'),
      ),
      Expanded(
        child: ListView.builder(
          shrinkWrap: true,
          itemCount: 2,
          itemBuilder: (context, index) {
            return Text(
              'lorem ipsum dolor',
              textAlign: TextAlign.right,
//                     style: TextStyle(fontSize: 10),
            );
          },
        ),
      ),
    ],
  ),
),

在此處輸入圖像描述

final techs = <String>['Dart', 'Flutter', 'Firebase'];
final packages = <String>['Freezed', 'Riverpod', 'Isar'];

Column(
  children: [
    Row(
      children: [
        Expanded(
          child: ListView.builder(
            shrinkWrap: true,
            itemCount: techs.length,
            itemBuilder: (context, index) {
              return Text('Tech - ${techs[index]}');
            },
          ),
        ),
        Expanded(
          child: ListView.builder(
            shrinkWrap: true,
            itemCount: packages.length,
            itemBuilder: (context, index) {
              return Text('Package - ${packages[index]}');
            },
          ),
        ),
      ],
    ),
  ],
),

Output:

結果

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM