import 'package:flutter/material.dart'; /// A scheduled time in the operator's local time, 24-hour as the chat's /// message timestamps are: "15:01" today, "Fri 28 Nov 15:01" on another day. String chatScheduleTime( BuildContext context, DateTime at, { DateTime Function() now = DateTime.now, }) { final local = at.toLocal(); final material = MaterialLocalizations.of(context); final time = material.formatTimeOfDay( TimeOfDay.fromDateTime(local), alwaysUse24HourFormat: true, ); final today = now().toLocal(); if (local.year == today.year && local.month == today.month && local.day == today.day) { return time; } return '${material.formatMediumDate(local)} $time'; }