CheckList: NullSafety

This commit is contained in:
Vishesh Handa
2021-05-19 12:45:26 +02:00
parent 9493dba851
commit 862ac6f137
2 changed files with 12 additions and 14 deletions

View File

@ -1,9 +1,5 @@
// @dart=2.9
import 'dart:convert';
import 'package:meta/meta.dart';
import 'package:gitjournal/core/note.dart';
import 'package:gitjournal/error_reporting.dart';
@ -11,13 +7,13 @@ class ChecklistItem {
bool checked;
String text;
String pre;
String? pre;
bool upperCase;
int lineNo;
ChecklistItem({
@required this.checked,
@required this.text,
required this.checked,
required this.text,
this.pre = '',
this.upperCase = false,
this.lineNo = -1,
@ -26,7 +22,11 @@ class ChecklistItem {
@override
String toString() => '$pre- [$_x] $text';
String get _x => checked ? upperCase ? 'X' : 'x' : ' ';
String get _x => checked
? upperCase
? 'X'
: 'x'
: ' ';
@override
bool operator ==(Object other) =>
@ -58,8 +58,8 @@ class Checklist {
Note _note;
List<ChecklistItem> items = [];
List<String> _lines;
bool endsWithNewLine;
late List<String> _lines;
late bool endsWithNewLine;
Checklist(this._note) {
_lines = LineSplitter.split(_note.body).toList();
@ -79,7 +79,7 @@ class Checklist {
var pre = match.group(1);
var state = match.group(2);
var post = match.group(3);
var post = match.group(3)!;
var item = ChecklistItem(
pre: pre,

View File

@ -1,5 +1,3 @@
// @dart=2.9
import 'dart:io';
import 'package:path/path.dart' as p;
@ -12,7 +10,7 @@ import 'package:gitjournal/settings.dart';
void main() {
group('Note', () {
Directory tempDir;
late Directory tempDir;
setUpAll(() async {
tempDir = await Directory.systemTemp.createTemp('__notes_test__');