[英]Invalid argument(s) (input): Must not be null
Error I got: The following ArgumentError was thrown building FutureBuilder<List<Transaction>>(dirty, state: _FutureBuilderState<List<Transaction>>#b741e):
Invalid argument(s) (input): Must not be null
When the exception was thrown, this was the stack:
#0 _RegExp.firstMatch (dart:core-patch/regexp_patch.dart:221:24)
#1 DateTime.parse (dart:core/date_time.dart:266:23)
#2 new transactionByDate (package:bug3t/widgets/transactionByDate.dart:16:20)
#3 _BudgetDateRangePickerState.build.<anonymous closure> (package:bug3t/widgets/date_picker.dart:80:19)
#4 _FutureBuilderState.build (package:flutter/src/widgets/async.dart:773:55)
#1 date_time.dart (lib) #1 date_time.dart (lib)
static DateTime parse(String formattedString) {
var re = _parseFormat;
**Match? match = re.firstMatch(formattedString);**
if (match != null) {
int parseIntOrZero(String? matched) {
if (matched == null) return 0;
return int.parse(matched);
}
#2 transactionByDate.dart( I use this one to filter transactions in JSON file) #2 transactionByDate.dart(我用这个来过滤 JSON 文件中的交易)
class transactionByDate extends StatelessWidget {
final List<Transaction> transactions;
final DateTime from;
final DateTime to;
transactionByDate( this.transactions, this.from, this.to) {
for (int i = 0; i < transactions.length; i++) {
**if (DateTime.parse(transactions[i].date).isAfter(this.to) || DateTime.parse(transactions[i].date).isBefore(this.from))** {
this.transactions.remove(transactions[i]);
}
}
}
#3 date_picker.dart( I use this class to pass data from datepicker and JSON list fetched from the internet) #3 date_picker.dart(我使用这个 class 传递来自 datepicker 的数据和从 Internet 获取的 JSON 列表)
child: new FutureBuilder<List<Transaction>>(
future: fetchBudgetTrans(new http.Client()),builder: (context, snapshot) {if (snapshot.hasError) print(snapshot.error);
if (snapshot.hasData) {
**transactionByDate tl = new transactionByDate(snapshot.data,_fromDate,_toDate);**
return Flexible(child: tl);} else return new Center(child: new CircularProgressIndicator()); },)
if(formattedString == null)
Do sth
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.