1
0
mirror of https://github.com/GitJournal/GitJournal.git synced 2025-07-23 02:07:26 +08:00

DebugScreen: Port to null safety

This commit is contained in:
Vishesh Handa
2021-05-17 15:58:21 +02:00
parent c756f73818
commit 6c0abffbe8
3 changed files with 14 additions and 16 deletions

@ -1,5 +1,3 @@
// @dart=2.9
/*
Copyright 2020-2021 Vishesh Handa <me@vhanda.in>
@ -43,7 +41,7 @@ class AppSettings extends ChangeNotifier {
var proExpirationDate = "";
var validateProMode = true;
String _pseudoId;
late String _pseudoId;
String get pseudoId => _pseudoId;
var debugLogLevel = 'v';
@ -71,10 +69,12 @@ class AppSettings extends ChangeNotifier {
pref.getString("proExpirationDate") ?? proExpirationDate;
validateProMode = pref.getBool("validateProMode") ?? validateProMode;
_pseudoId = pref.getString("pseudoId");
if (_pseudoId == null) {
var p = pref.getString("pseudoId");
if (p == null) {
_pseudoId = const Uuid().v4();
pref.setString("pseudoId", _pseudoId);
} else {
_pseudoId = p;
}
debugLogLevel = pref.getString("debugLogLevel") ?? debugLogLevel;

@ -1,5 +1,3 @@
// @dart=2.9
import 'dart:convert';
import 'package:flutter/material.dart';
@ -20,14 +18,14 @@ class DebugScreen extends StatefulWidget {
class _DebugScreenState extends State<DebugScreen> {
ScrollController _controller = ScrollController();
List<LogMessage> _logs;
late List<LogMessage> _logs;
@override
void initState() {
super.initState();
_logs = Log.fetchLogs().toList();
WidgetsBinding.instance.addPostFrameCallback((_) => _scrollToBottom());
WidgetsBinding.instance!.addPostFrameCallback((_) => _scrollToBottom());
}
void _scrollToTop() {
@ -146,7 +144,7 @@ class _DebugScreenState extends State<DebugScreen> {
Widget _buildLogWidget(LogMessage msg) {
var textStyle = Theme.of(context)
.textTheme
.bodyText2
.bodyText2!
.copyWith(fontFamily: "Roboto Mono");
textStyle = textStyle.copyWith(color: _colorForLevel(msg.l));
@ -156,7 +154,7 @@ class _DebugScreenState extends State<DebugScreen> {
var str = ' ' + msg.msg;
if (msg.ex != null) {
str += ' ' + msg.ex;
str += ' ' + msg.ex!;
}
if (msg.stack != null) {
str += ' ' + msg.stack.toString();
@ -204,7 +202,7 @@ class _DebugScreenState extends State<DebugScreen> {
Widget _buildDateWidget(DateTime dt) {
var textStyle = Theme.of(context)
.textTheme
.headline6
.headline6!
.copyWith(fontFamily: "Roboto Mono");
var text = dt.toIso8601String().substring(0, 10);
@ -264,7 +262,7 @@ class FilterListTile extends StatelessWidget {
Icon _getIcon(BuildContext context) {
var theme = Theme.of(context);
var color = theme.textTheme.headline6.color;
var color = theme.textTheme.headline6!.color;
if (_isSelected()) {
switch (theme.brightness) {
case Brightness.light:

@ -211,9 +211,9 @@ class Log {
}
class LogMessage {
int? t;
String? l;
String? msg;
late int t;
late String l;
late String msg;
String? ex;
List<Map<String, dynamic>>? stack;
Map<String, dynamic>? props;