mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-06-28 18:03:14 +08:00
CheckList: NullSafety
This commit is contained in:
@ -1,9 +1,5 @@
|
|||||||
// @dart=2.9
|
|
||||||
|
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
import 'package:meta/meta.dart';
|
|
||||||
|
|
||||||
import 'package:gitjournal/core/note.dart';
|
import 'package:gitjournal/core/note.dart';
|
||||||
import 'package:gitjournal/error_reporting.dart';
|
import 'package:gitjournal/error_reporting.dart';
|
||||||
|
|
||||||
@ -11,13 +7,13 @@ class ChecklistItem {
|
|||||||
bool checked;
|
bool checked;
|
||||||
String text;
|
String text;
|
||||||
|
|
||||||
String pre;
|
String? pre;
|
||||||
bool upperCase;
|
bool upperCase;
|
||||||
int lineNo;
|
int lineNo;
|
||||||
|
|
||||||
ChecklistItem({
|
ChecklistItem({
|
||||||
@required this.checked,
|
required this.checked,
|
||||||
@required this.text,
|
required this.text,
|
||||||
this.pre = '',
|
this.pre = '',
|
||||||
this.upperCase = false,
|
this.upperCase = false,
|
||||||
this.lineNo = -1,
|
this.lineNo = -1,
|
||||||
@ -26,7 +22,11 @@ class ChecklistItem {
|
|||||||
@override
|
@override
|
||||||
String toString() => '$pre- [$_x] $text';
|
String toString() => '$pre- [$_x] $text';
|
||||||
|
|
||||||
String get _x => checked ? upperCase ? 'X' : 'x' : ' ';
|
String get _x => checked
|
||||||
|
? upperCase
|
||||||
|
? 'X'
|
||||||
|
: 'x'
|
||||||
|
: ' ';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool operator ==(Object other) =>
|
bool operator ==(Object other) =>
|
||||||
@ -58,8 +58,8 @@ class Checklist {
|
|||||||
Note _note;
|
Note _note;
|
||||||
List<ChecklistItem> items = [];
|
List<ChecklistItem> items = [];
|
||||||
|
|
||||||
List<String> _lines;
|
late List<String> _lines;
|
||||||
bool endsWithNewLine;
|
late bool endsWithNewLine;
|
||||||
|
|
||||||
Checklist(this._note) {
|
Checklist(this._note) {
|
||||||
_lines = LineSplitter.split(_note.body).toList();
|
_lines = LineSplitter.split(_note.body).toList();
|
||||||
@ -79,7 +79,7 @@ class Checklist {
|
|||||||
|
|
||||||
var pre = match.group(1);
|
var pre = match.group(1);
|
||||||
var state = match.group(2);
|
var state = match.group(2);
|
||||||
var post = match.group(3);
|
var post = match.group(3)!;
|
||||||
|
|
||||||
var item = ChecklistItem(
|
var item = ChecklistItem(
|
||||||
pre: pre,
|
pre: pre,
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
// @dart=2.9
|
|
||||||
|
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:path/path.dart' as p;
|
import 'package:path/path.dart' as p;
|
||||||
@ -12,7 +10,7 @@ import 'package:gitjournal/settings.dart';
|
|||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
group('Note', () {
|
group('Note', () {
|
||||||
Directory tempDir;
|
late Directory tempDir;
|
||||||
|
|
||||||
setUpAll(() async {
|
setUpAll(() async {
|
||||||
tempDir = await Directory.systemTemp.createTemp('__notes_test__');
|
tempDir = await Directory.systemTemp.createTemp('__notes_test__');
|
||||||
|
Reference in New Issue
Block a user