要素の数が不特定なListViewを実装しようとしているのですが、
Every child of a RenderCustomMultiChildLayoutBox must have an ID in its parent data.
といったエラーがでてしまいます。
下記のコードは上から順にコンポーネントとして読み込んでいます。
dart
1class TermsScreen extends StatelessWidget { 2 3 Widget build(BuildContext context) { 4 return ChangeNotifierProvider<TermsChangeNotifier>( 5 create: (context) => TermsChangeNotifier(), 6 child: Scaffold( 7 appBar: PlainHeader(text: "利用規約"), 8 body: Consumer<TermsChangeNotifier>(builder: (context, value, child) { 9 return Expanded( 10 child: DocumentFrame( 11 title: "サービス利用規約", 12 titleList: value.titleList, 13 textList: value.bodyList 14 ), 15 ); 16 }), 17 ), 18 ); 19 } 20}
dart
1import 'package:flutter/material.dart'; 2import 'package:flutter/widgets.dart'; 3import 'package:talent/view/screen/terms/component/DocumentItem.dart'; 4// import 'package:talent/view/component/RoundRectButtonBlue.dart'; 5 6class DocumentFrame extends StatelessWidget { 7 final String title; 8 final List<String> titleList; 9 final List<String> textList; 10 11 const DocumentFrame({Key key, this.title, this.titleList, this.textList}) : super(key: key); 12 13 14 Widget build(BuildContext context) { 15 return Center( 16 child: Column(children: <Widget>[ 17 Container( 18 padding: EdgeInsets.only(top: 40.0, bottom: 40.0), 19 width: 303.0, 20 height: 462.0, 21 child: Scrollbar( 22 child: Padding( 23 padding: EdgeInsets.only(right: 5.0), 24 child: SingleChildScrollView( 25 child: Column( 26 crossAxisAlignment: CrossAxisAlignment.start, 27 children: <Widget>[ 28 Center( 29 child: Text(title, 30 style: TextStyle( 31 fontSize: 18.0, 32 )), 33 ), 34 SizedBox(height: 10.0), 35 Text("", style: Theme.of(context).textTheme.headline4), 36 SizedBox(height: 10.0), 37 Row(children: [ 38 Text("こちらをご参照ください:", style: Theme.of(context).textTheme.bodyText2), 39 Text("", style: TextStyle(fontSize: Theme.of(context).textTheme.bodyText2.fontSize, color: Colors.red)) 40 ]), 41 ListView.builder( 42 itemBuilder: (BuildContext context, int index) { 43 return DocumentItem( 44 title: titleList[index], 45 text: textList[index], 46 ); 47 }, 48 itemCount: 5) 49 ], 50 ) 51 ) 52 ), 53 ) 54 ), 55 Container( 56 width: 140.0, 57 height: 40.0, 58 // child: RoundRectButtonBlue(text: "戻る"), 59 ) 60 ]), 61 ); 62 } 63}
dart
1import 'package:flutter/material.dart'; 2import 'package:flutter/widgets.dart'; 3// import 'package:talent/view/component/RoundRectButtonBlue.dart'; 4 5class DocumentItem extends StatelessWidget { 6 final String title; 7 final String text; 8 9 const DocumentItem({Key key, this.title, this.text}) : super(key: key); 10 11 12 Widget build(BuildContext context) { 13 return Column( 14 children: [ 15 Text(title, style: Theme.of(context).textTheme.bodyText2), 16 Text(text, style: Theme.of(context).textTheme.bodyText2), 17 ] 18 ); 19 } 20} 21
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。