emojiDayOrNight property

String? get emojiDayOrNight

Returns TimeEmojiUtils.sunEmoji if the DateTime's hour is between 8am (exclusive of 7am) and 5pm (exclusive of 6pm), otherwise returns TimeEmojiUtils.moonEmoji.

This is a convenient way to get the day/night emoji based on a DateTime instance.

Example:

DateTime now = DateTime.now();
String? emoji = now.emojiDayOrNight; // Returns '☀️' or '🌙' based on the current hour.

Implementation

String? get emojiDayOrNight => TimeEmojiUtils.getEmojiDayOrNight(hour);