本日の予定をListvew に表示させたいのですが、Date=current timeでフィルター設定しても表示されません。
どのようにすれば本日の予定のみを表示させることができるでしょうか?
原則、Current Time で時間も含まれているので、時間も一致しないとフィルターかけられないです。
本日の予定のみにする場合には、CostomActionで
今日の0時 と今日の24時 の間を値をフィルターする。。という動作が必要です。
私の方で、作った関数は以下の通りです。
今日の0時と24時の間でフィルターをかけてます。
今日の0時の関数
import ‘dart:convert’;
import ‘dart:math’ as math;
import ‘package:flutter/material.dart’;
import ‘package:google_fonts/google_fonts.dart’;
import ‘package:intl/intl.dart’;
import ‘package:timeago/timeago.dart’ as timeago;
import ‘/flutter_flow/lat_lng.dart’;
import ‘/flutter_flow/place.dart’;
import ‘/flutter_flow/uploaded_file.dart’;
import ‘/flutter_flow/custom_functions.dart’;
import ‘/backend/backend.dart’;
import ‘package:cloud_firestore/cloud_firestore.dart’;
import ‘/auth/firebase_auth/auth_util.dart’;
DateTime? today0ji() {
/// MODIFY CODE ONLY BELOW THIS LINE
// Get today’s date out However, the time shall be midnight
return DateTime.now().subtract(Duration(
hours: DateTime.now().hour,
minutes: DateTime.now().minute,
seconds: DateTime.now().second,
milliseconds: DateTime.now().millisecond,
microseconds: DateTime.now().microsecond));
/// MODIFY CODE ONLY ABOVE THIS LINE
}
ーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーー
今日の24時の関数
import ‘dart:convert’;
import ‘dart:math’ as math;
import ‘package:flutter/material.dart’;
import ‘package:google_fonts/google_fonts.dart’;
import ‘package:intl/intl.dart’;
import ‘package:timeago/timeago.dart’ as timeago;
import ‘/flutter_flow/lat_lng.dart’;
import ‘/flutter_flow/place.dart’;
import ‘/flutter_flow/uploaded_file.dart’;
import ‘/flutter_flow/custom_functions.dart’;
import ‘/backend/backend.dart’;
import ‘package:cloud_firestore/cloud_firestore.dart’;
import ‘/auth/firebase_auth/auth_util.dart’;
DateTime? today24ji() {
/// MODIFY CODE ONLY BELOW THIS LINE
// Today Month day However, please output the time as 23:59:00
// Get today’s date, but set the time to 23:59:00
return DateTime.now()
.subtract(Duration(
hours: DateTime.now().hour,
minutes: DateTime.now().minute,
seconds: DateTime.now().second,
milliseconds: DateTime.now().millisecond,
microseconds: DateTime.now().microsecond))
.add(Duration(hours: 23, minutes: 59, seconds: 0));
/// MODIFY CODE ONLY ABOVE THIS LINE
}
細かい内容は、以下のブログでも書いたので、参考にどうぞ
いつもありがとうございます!
参考にさせていただきます!!
がんばってくださいね^^
先日教えていただいた日付指定のカスタムコードにエラーが出るようになってしまったのですが、エラー内容が解読できず困っております。。。
わかりますか?
【エラー内容】
FakeDocumentReference.snapshots’ (‘Stream<DocumentSnapshot<Object?>> Function({bool includeMetadataChanges})’) isn’t a valid override of ‘DocumentReference.snapshots’ (‘Stream<DocumentSnapshot<Object?>> Function({bool includeMetadataChanges, ListenSource source})’).
うーん、これだけだと良く分からないです。
エラー内容は、変数などが入力と出力で一致してないっていうエラーです。
多分、ですが、以下のどっちかではないですかね?
型の不一致:
- 変数や関数の戻り値の型が期待されるものと異なる
- Nullableな型とNon-nullableな型の混在
未定義の変数や関数:
- 使用している変数や関数が定義されていない
あまり、参考にならず申し訳ないですが。
ありがとうございます!