enter image description here这是列表图像我想从其中访问内容密钥。enter image description here已尝试上面的代码
tf7tbtn21#
请尝试此代码:
class MyPage extends StatelessWidget { MyPage({super.key}); final coumputerData = [ { "maintopic": "Computer Software", "subtopic": [ { "topic": "introduction", "content": "owhrfiuwbef iosevibskvsuibvisnesd nisudvusvc", } ] }, { "maintopic": "Computer", "subtopic": [ { "topic": "introduction", "content": "owhrfic", } ] } ]; @override Widget build(BuildContext context) { return Scaffold( body: ListView.builder( shrinkWrap: true, physics: const ClampingScrollPhysics(), itemCount: coumputerData.length, itemBuilder: ((context, index) { final List<Map> arrSubTopic = coumputerData[index]['subtopic'] as List<Map>; return Column( children: [ Container( height: 40, color: Colors.red, child: Row( children: [ Expanded( child: Center( child: Text(coumputerData[index]['maintopic'] as String), ), ) ], ), ), Container( color: Colors.amber, child: ListView.builder( shrinkWrap: true, physics: const ClampingScrollPhysics(), itemCount: arrSubTopic.length, itemBuilder: ((context, inx) { return Padding( padding: const EdgeInsets.all(8.0), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text(arrSubTopic[inx]['topic'] as String), Text(arrSubTopic[inx]['content'] as String) ], ), ); }), ), ) ], ); }), ), ); } }
您也可以使用模型类访问您的数据。要生成模型类,您可以使用此website。
1条答案
按热度按时间tf7tbtn21#
请尝试此代码:
您也可以使用模型类访问您的数据。要生成模型类,您可以使用此website。