mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-06-26 08:36:50 +08:00
CheckList: NullSafety
This commit is contained in:
@ -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,
|
||||
|
@ -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__');
|
||||
|
Reference in New Issue
Block a user