From c65ec96da224c29e987b519a9269d84941b6b0fb Mon Sep 17 00:00:00 2001 From: Vishesh Handa Date: Mon, 2 Mar 2020 17:37:47 +0100 Subject: [PATCH] Fix bug when you have less than 10 notes Fixes #73 --- lib/core/notes_cache.dart | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/core/notes_cache.dart b/lib/core/notes_cache.dart index d6c54d4b..fa0c2885 100644 --- a/lib/core/notes_cache.dart +++ b/lib/core/notes_cache.dart @@ -1,5 +1,6 @@ import 'dart:convert'; import 'dart:io'; +import 'dart:math'; import 'package:flutter/material.dart'; import 'package:path/path.dart' as p; @@ -61,7 +62,7 @@ class NotesCache { assert(files.every((n) => n.loadState == NoteLoadState.Loaded)); files.sort(sortingMode.sortingFunction()); - files = files.sublist(0, 10); + files = files.sublist(0, min(10, files.length)); var fileList = files.map((f) => f.filePath).toList(); return saveToDisk(fileList);