前提
画面を作っている時にBoxConstraints has a negative minimum height.
The offending constraints were: BoxConstraints(w=375.0, h=-109.0; NOT NORMALIZED)というエラーが発生しました。このエラーに対してどうやったら解決できるかわかりません。 何方かわかる方は教えて貰えると助かります。
発生している問題・エラーメッセージ
BoxConstraints has a negative minimum height. The offending constraints were: BoxConstraints(w=375.0, h=-109.0; NOT NORMALIZED)```
該当のソースコード
dart
1import 'package:flutter/material.dart'; 2import 'package:flutter_localizations/flutter_localizations.dart'; 3import 'package:medicine/calendar_add_model.dart'; 4import 'package:medicine/utils.dart'; 5import 'package:provider/provider.dart'; 6 7class CalendarAddDate extends StatelessWidget { 8 9 Widget build(BuildContext context) { 10 return MaterialApp( 11 localizationsDelegates: const [ 12 GlobalCupertinoLocalizations.delegate, 13 GlobalMaterialLocalizations.delegate, 14 GlobalWidgetsLocalizations.delegate, 15 ], 16 supportedLocales: [ 17 const Locale('ja'), 18 ], 19 title: 'お薬手帳リスト', 20 theme: ThemeData( 21 primaryColor: Colors.pink[100], 22 ), 23 home: CalendarAddPage(), 24 ); 25 } 26} 27 28class CalendarAddPage extends StatelessWidget { 29 CalendarAddPage({this.dete}); 30 DateTime? dete; 31 32 Widget build(BuildContext context) { 33 final textEditingController = TextEditingController(); 34 return ChangeNotifierProvider<CalemdarAddModel>.value( 35 value: CalemdarAddModel(date: dete), 36 child: Consumer<CalemdarAddModel>( 37 builder: (context, model, child) { 38 return Scaffold( 39 appBar: AppBar( 40 backgroundColor: Colors.pink[100], 41 title: const Text('新しい予定'), 42 leading: IconButton( 43 onPressed: () { 44 Navigator.pop(context); 45 }, 46 icon: const Icon(Icons.arrow_back_ios), 47 ), 48 actions: <Widget>[ 49 TextButton( 50 onPressed: () async { 51 await addDialog(model, context); 52 }, 53 child: const Text('保存'), 54 ), 55 ], 56 ), 57 body: SingleChildScrollView( 58 padding: const EdgeInsets.all(14), 59 child: Column( 60 mainAxisSize: MainAxisSize.min, 61 children: <Widget>[ 62 Column( 63 crossAxisAlignment: CrossAxisAlignment.start, 64 children: <Widget>[ 65 //予定 66 SizedBox( 67 height: 40, 68 child: TextFormField( 69 style: const TextStyle(fontSize: 13), 70 decoration: const InputDecoration( 71 border: UnderlineInputBorder(), hintText: '予定'), 72 onChanged: (text) { 73 model.scheduleText = text; 74 }, 75 ), 76 ), 77 const SizedBox(height: 20), 78 Column( 79 crossAxisAlignment: CrossAxisAlignment.start, 80 children: [ 81 //開始時間 82 const Text('開始時間', 83 style: TextStyle(fontWeight: FontWeight.bold)), 84 Row( 85 children: [ 86 Expanded( 87 flex: 2, 88 child: buildDropdownField( 89 text: model.startDate == "" 90 ? Utils.toDate(model.dateTime()) 91 : Utils.toDate(model.fromDate), 92 onClicked: () { 93 model.pickStartDateTime(context, 94 pickDate: true); 95 }), 96 ), 97 Expanded( 98 child: buildDropdownField( 99 text: model.startDate == "" 100 ? Utils.toTime(model.dateTime()) 101 : Utils.toTime(model.fromDate), 102 onClicked: () { 103 model.pickStartDateTime(context, 104 pickDate: false); 105 })), 106 ], 107 ), 108 //終了時間 109 const Text('終了時間', 110 style: TextStyle(fontWeight: FontWeight.bold)), 111 Row( 112 children: [ 113 Expanded( 114 flex: 2, 115 child: buildDropdownField( 116 text: model.endDate == "" 117 ? Utils.toDate(model.dateTime()) 118 : Utils.toDate(model.toDate), 119 onClicked: () { 120 model.pickEndDateTime(context, 121 pickDate: true); 122 }), 123 ), 124 Expanded( 125 child: buildDropdownField( 126 text: model.endDate == "" 127 ? Utils.toTime(model.dateTime()) 128 : Utils.toTime(model.toDate), 129 onClicked: () { 130 model.pickEndDateTime(context, 131 pickDate: false); 132 })), 133 ], 134 ), 135 ], 136 ), 137 const SizedBox(height: 20), 138 TextField( 139 decoration: const InputDecoration( 140 hintText: "病院名または診察科目を検索", 141 prefixIcon: Icon(Icons.note_alt), 142 border: OutlineInputBorder( 143 borderRadius: 144 BorderRadius.all(Radius.circular(25.0)))), 145 onChanged: (text) { 146 model.memoText = text; 147 }, 148 ), 149 ], 150 ), 151 ], 152 ), 153 ), 154 ); 155 }, 156 ), 157 ); 158 }
あなたの回答
tips
プレビュー