NullSafety++

This commit is contained in:
Vishesh Handa
2021-05-17 16:55:50 +02:00
parent ec600198a3
commit 5e5de203da
6 changed files with 14 additions and 32 deletions

View File

@ -1,13 +1,10 @@
// @dart=2.9
import 'package:equatable/equatable.dart'; import 'package:equatable/equatable.dart';
import 'package:meta/meta.dart';
class NoteImage extends Equatable { class NoteImage extends Equatable {
final String url; final String url;
final String alt; final String alt;
NoteImage({@required this.url, @required this.alt}); NoteImage({required this.url, required this.alt});
@override @override
List<Object> get props => [url, alt]; List<Object> get props => [url, alt];
@ -26,7 +23,7 @@ class ImageExtractor {
var alt = match.group(1); var alt = match.group(1);
var url = match.group(2); var url = match.group(2);
images.add(NoteImage(alt: alt, url: url)); images.add(NoteImage(alt: alt ?? "", url: url ?? ""));
} }
return images; return images;

View File

@ -1,5 +1,3 @@
// @dart=2.9
/* /*
(c) Copyright 2020 Vishesh Handa (c) Copyright 2020 Vishesh Handa
@ -26,12 +24,10 @@
THE SOFTWARE. THE SOFTWARE.
*/ */
import 'package:meta/meta.dart';
class InlineTagsProcessor { class InlineTagsProcessor {
final Set<String> tagPrefixes; final Set<String> tagPrefixes;
InlineTagsProcessor({@required this.tagPrefixes}); InlineTagsProcessor({required this.tagPrefixes});
Set<String> extractTags(String text) { Set<String> extractTags(String text) {
var tags = <String>{}; var tags = <String>{};
@ -46,7 +42,7 @@ class InlineTagsProcessor {
var regexp = RegExp(r'(^|\s)' + p + r'([^\s]+)(\s|$)'); var regexp = RegExp(r'(^|\s)' + p + r'([^\s]+)(\s|$)');
var matches = regexp.allMatches(text); var matches = regexp.allMatches(text);
for (var match in matches) { for (var match in matches) {
var tag = match.group(2); var tag = match.group(2)!;
if (tag.endsWith('.') || tag.endsWith('!') || tag.endsWith('?')) { if (tag.endsWith('.') || tag.endsWith('!') || tag.endsWith('?')) {
tag = tag.substring(0, tag.length - 1); tag = tag.substring(0, tag.length - 1);

View File

@ -1,5 +1,3 @@
// @dart=2.9
/* /*
Code adapted from https://github.com/TheAlphamerc/flutter_login_signup/ Code adapted from https://github.com/TheAlphamerc/flutter_login_signup/
@ -43,9 +41,9 @@ import 'package:gitjournal/widgets/scroll_view_without_animation.dart';
// const _prodServer = 'https://api.gitjournal.io/auth/'; // const _prodServer = 'https://api.gitjournal.io/auth/';
class LoginPage extends StatefulWidget { class LoginPage extends StatefulWidget {
LoginPage({Key key, this.title}) : super(key: key); LoginPage({Key? key, this.title}) : super(key: key);
final String title; final String? title;
@override @override
_LoginPageState createState() => _LoginPageState(); _LoginPageState createState() => _LoginPageState();
@ -90,9 +88,7 @@ class _LoginPageState extends State<LoginPage> {
); );
return InkWell( return InkWell(
onTap: () { onTap: _loginAction,
_loginAction();
},
child: c, child: c,
); );
} }
@ -318,7 +314,7 @@ class FormTitle extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
var textTheme = Theme.of(context).textTheme; var textTheme = Theme.of(context).textTheme;
var style = textTheme.headline2.copyWith(fontFamily: "Lato"); var style = textTheme.headline2!.copyWith(fontFamily: "Lato");
return Text('GitJournal', style: style); return Text('GitJournal', style: style);
} }
} }

View File

@ -1,5 +1,3 @@
// @dart=2.9
/* /*
Copyright 2020-2021 Vishesh Handa <me@vhanda.in> Copyright 2020-2021 Vishesh Handa <me@vhanda.in>

View File

@ -1,9 +1,6 @@
// @dart=2.9
import 'dart:io'; import 'dart:io';
import 'package:git_bindings/git_bindings.dart' as gb; import 'package:git_bindings/git_bindings.dart' as gb;
import 'package:meta/meta.dart';
import 'package:path/path.dart' as p; import 'package:path/path.dart' as p;
import 'package:gitjournal/utils/logger.dart'; import 'package:gitjournal/utils/logger.dart';
@ -16,15 +13,15 @@ class SshKey {
final String password; final String password;
const SshKey({ const SshKey({
@required this.publicKey, required this.publicKey,
@required this.privateKey, required this.privateKey,
@required this.password, required this.password,
}); });
} }
final bool useDartKeyGen = false; final bool useDartKeyGen = false;
Future<SshKey> generateSSHKeys({@required String comment}) async { Future<SshKey?> generateSSHKeys({required String comment}) async {
if (useDartKeyGen) { if (useDartKeyGen) {
//return generateSSHKeysDart(comment: comment); //return generateSSHKeysDart(comment: comment);
} else {} } else {}
@ -51,7 +48,7 @@ Future<SshKey> generateSSHKeysDart({@required String comment}) async {
} }
*/ */
Future<SshKey> generateSSHKeysNative({@required String comment}) async { Future<SshKey?> generateSSHKeysNative({required String comment}) async {
try { try {
var stopwatch = Stopwatch()..start(); var stopwatch = Stopwatch()..start();
var dir = await Directory.systemTemp.createTemp('keys'); var dir = await Directory.systemTemp.createTemp('keys');

View File

@ -1,5 +1,3 @@
// @dart=2.9
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
class ScrollViewWithoutAnimation extends StatelessWidget { class ScrollViewWithoutAnimation extends StatelessWidget {
@ -7,7 +5,7 @@ class ScrollViewWithoutAnimation extends StatelessWidget {
final Axis scrollDirection; final Axis scrollDirection;
ScrollViewWithoutAnimation({ ScrollViewWithoutAnimation({
@required this.child, required this.child,
this.scrollDirection = Axis.vertical, this.scrollDirection = Axis.vertical,
}); });