1
0
mirror of https://github.com/flutter/samples.git synced 2026-04-05 19:22:08 +00:00

Flutter 3.29 beta (#2571)

This commit is contained in:
Eric Windmill
2025-02-12 18:08:01 -05:00
committed by GitHub
parent d62c784789
commit 719fd72c38
685 changed files with 76244 additions and 53721 deletions

View File

@@ -15,14 +15,20 @@ class EntryTotal {
/// Returns a list of [EntryTotal] objects. Each [EntryTotal] is the sum of
/// the values of all the entries on a given day.
List<EntryTotal> entryTotalsByDay(List<Entry>? entries, int daysAgo,
{DateTime? today}) {
List<EntryTotal> entryTotalsByDay(
List<Entry>? entries,
int daysAgo, {
DateTime? today,
}) {
today ??= DateTime.now();
return _entryTotalsByDay(entries, daysAgo, today).toList();
}
Iterable<EntryTotal> _entryTotalsByDay(
List<Entry>? entries, int daysAgo, DateTime today) sync* {
List<Entry>? entries,
int daysAgo,
DateTime today,
) sync* {
var start = today.subtract(Duration(days: daysAgo));
var entriesByDay = _entriesInRange(start, today, entries);
@@ -42,11 +48,16 @@ Iterable<EntryTotal> _entryTotalsByDay(
/// lists. The outer list represents the number of days since [start], and the
/// inner list is the group of entries on that day.
List<List<Entry>> _entriesInRange(
DateTime start, DateTime end, List<Entry>? entries) =>
_entriesInRangeImpl(start, end, entries).toList();
DateTime start,
DateTime end,
List<Entry>? entries,
) => _entriesInRangeImpl(start, end, entries).toList();
Iterable<List<Entry>> _entriesInRangeImpl(
DateTime start, DateTime end, List<Entry>? entries) sync* {
DateTime start,
DateTime end,
List<Entry>? entries,
) sync* {
start = start.atMidnight;
end = end.atMidnight;
var d = start;