Debug screen: Cache the logs

Avoiding opening the file again and again
This commit is contained in:
Vishesh Handa
2020-06-10 13:34:36 +02:00
parent b3014d4186
commit 8811f08b0e

View File

@ -12,10 +12,13 @@ class _DebugScreenState extends State<DebugScreen> {
ScrollController _controller = ScrollController();
String filterLevel = Settings.instance.debugLogLevel;
List<LogMessage> _logs;
@override
void initState() {
super.initState();
_logs = Log.fetchLogs().toList();
WidgetsBinding.instance.addPostFrameCallback((_) => _scrollToBottom());
}
@ -99,7 +102,7 @@ class _DebugScreenState extends State<DebugScreen> {
Iterable<Widget> _fetchLogWidgets() sync* {
var prevDate = "";
for (var msg in Log.fetchLogs()) {
for (var msg in _logs) {
if (!_shouldDisplay(msg)) {
continue;
}