From 862ac6f1377d6b7189eef179a230bac2329142b2 Mon Sep 17 00:00:00 2001 From: Vishesh Handa Date: Wed, 19 May 2021 12:45:26 +0200 Subject: [PATCH] CheckList: NullSafety --- lib/core/checklist.dart | 22 +++++++++++----------- test/checklist_test.dart | 4 +--- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/lib/core/checklist.dart b/lib/core/checklist.dart index a7d62412..2d94d86a 100644 --- a/lib/core/checklist.dart +++ b/lib/core/checklist.dart @@ -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 items = []; - List _lines; - bool endsWithNewLine; + late List _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, diff --git a/test/checklist_test.dart b/test/checklist_test.dart index 419d7930..d951daca 100644 --- a/test/checklist_test.dart +++ b/test/checklist_test.dart @@ -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__');