ListViewのTextに以降、同じ文字を表示したくない

Dart

1TextButton(2 onPressed: () {3 Navigator.pop(context);4 _addDoneList();5 _setStudyTime();6 _addStudyTimeList();7 _addSubjectNameList();8 _dateText = now.month.toString() + '月' + now.day.toString() + '日';9 _addDateList();10 spm.saveDoneList(doneList);11 spm.saveStudyTimeList(studyTimeList);12 spm.saveSubjectNameList(subjectNameList);13 spm.saveDateList(dateList);14 },15 child: const Text('追加する'),16 )17 ],18 )19 );20 }21 22 void _addDoneList() {23 setState(() {24 doneList.add(_doneText);25 });26 }27 28 void _setStudyTime() {29 _studyTimeText = dropdown1Value + '時間' + dropdown2Value + '分';30 }31 32 void _addStudyTimeList () {33 studyTimeList.add(_studyTimeText);34 }35 36 void _addSubjectNameList() {37 subjectNameList.add(_subjectNameText);38 }39 40 void _addDateList() {41 if(dateList.isNotEmpty && dateList.elementAt(dateList.length -1) == _dateText || dateList.isNotEmpty && dateList.elementAt(dateList.length -1) == '') {42 _dateText = '';43 }44 dateList.add(_dateText);45 }46 47 48 Widget build(BuildContext context) {49 50 return DefaultTabController(51 initialIndex: 0,52 length: 2,53 child: Scaffold(54 appBar: AppBar(55 backgroundColor: Theme.of(context).colorScheme.inversePrimary,56 title: const Text('ForStudents'),57 bottom: const TabBar(58 tabs: <Widget>[59 Tab(60 child: Row(61 children: [62 Icon(Icons.checklist),63 Text('今日の取り組み'),64 ]65 )66 ),67 Tab(68 child: Row(69 children: [70 Icon(Icons.event_note),71 Text('予定'),72 ],73 ),74 ),75 ],76 ),77 ),78 body: TabBarView(79 children: <Widget>[80 Column(81 children: <Widget>[82 Padding(83 padding: EdgeInsets.only(top: 8),84 child: Text('~まであと〇日'),85 ),86 87 Expanded(88 child: FutureBuilder<List<String>> (89 future: spm.loadDoneList(),90 builder: (BuildContext context, AsyncSnapshot<List<String>> snapshot) {91 if (snapshot.hasData) {92 doneList = snapshot.data!;93 94 return FutureBuilder<List<String>> (95 future: spm.loadStudyTimeList(),96 builder: (BuildContext context, AsyncSnapshot<List<String>> snapshot) {97 if (snapshot.hasData) {98 studyTimeList = snapshot.data!;99 100 return FutureBuilder(101 future: spm.loadSubjectNameList(),102 builder: (BuildContext context, AsyncSnapshot<List<String>> snapshot) {103 if (snapshot.hasData) {104 subjectNameList = snapshot.data!;105 106 return FutureBuilder(107 future: spm.loadDateList(),108 builder: (BuildContext context, AsyncSnapshot<List<String>> snapshot) {109 if (snapshot.hasData) {110 dateList = snapshot.data!;111 112 return ListView.builder(113 padding: const EdgeInsets.all(8),114 itemCount: doneList.length,115 itemBuilder: (BuildContext context, int index) {116 return Column(117 children: <Widget>[118 Text(dateList.elementAt(index)),119 Card(120 shape: RoundedRectangleBorder( //枠線121 borderRadius: BorderRadius.circular(10),122 ),123 color: Theme.of(context).colorScheme.inversePrimary,124 child: Column(125 children: [126 ListTile(127 title: Text(doneList.elementAt(index)),128 subtitle: Text(studyTimeList.elementAt(index)),129 ),130 Padding(131 padding: EdgeInsets.only(bottom: 12),132 child: Text(subjectNameList.elementAt(index)),133 )134 ],135 ),136 )137 ],138 );139 }140 );141 } else {142 return Text('データが見つかりません');143 }144 },145 );146 } else {147 return Text('データが見つかりません');148 }149 }150 );151 } else {152 return Text('データが見つかりません');153 }154 }155 );156 } else {157 return Text('データが見つかりません');158 }159 }160 )161 )162 ],163 ),

コメントを投稿

0 コメント