mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-07-27 14:14:39 +08:00
null safety++
This commit is contained in:
lib
@ -1,5 +1,3 @@
|
||||
// @dart=2.9
|
||||
|
||||
/*
|
||||
Copyright 2020-2021 Vishesh Handa <me@vhanda.in>
|
||||
|
||||
@ -38,7 +36,7 @@ class FolderListingScreen extends StatefulWidget {
|
||||
|
||||
class _FolderListingScreenState extends State<FolderListingScreen> {
|
||||
final _folderTreeViewKey = GlobalKey<FolderTreeViewState>();
|
||||
NotesFolderFS selectedFolder;
|
||||
NotesFolderFS? selectedFolder;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@ -78,7 +76,7 @@ class _FolderListingScreenState extends State<FolderListingScreen> {
|
||||
},
|
||||
);
|
||||
|
||||
Widget action;
|
||||
Widget? action;
|
||||
if (selectedFolder != null) {
|
||||
action = PopupMenuButton(
|
||||
itemBuilder: (context) {
|
||||
@ -99,25 +97,25 @@ class _FolderListingScreenState extends State<FolderListingScreen> {
|
||||
},
|
||||
onSelected: (String value) async {
|
||||
if (value == "Rename") {
|
||||
if (selectedFolder.pathSpec().isEmpty) {
|
||||
if (selectedFolder!.pathSpec().isEmpty) {
|
||||
await showDialog(
|
||||
context: context,
|
||||
builder: (_) => RenameFolderErrorDialog(),
|
||||
);
|
||||
_folderTreeViewKey.currentState.resetSelection();
|
||||
_folderTreeViewKey.currentState!.resetSelection();
|
||||
return;
|
||||
}
|
||||
var folderName = await showDialog(
|
||||
context: context,
|
||||
builder: (_) => RenameDialog(
|
||||
oldPath: selectedFolder.folderPath,
|
||||
oldPath: selectedFolder!.folderPath,
|
||||
inputDecoration: tr("screens.folders.actions.decoration"),
|
||||
dialogTitle: tr("screens.folders.actions.rename"),
|
||||
),
|
||||
);
|
||||
if (folderName is String) {
|
||||
var container = context.read<GitJournalRepo>();
|
||||
container.renameFolder(selectedFolder, folderName);
|
||||
container.renameFolder(selectedFolder!, folderName);
|
||||
}
|
||||
} else if (value == "Create") {
|
||||
var folderName = await showDialog(
|
||||
@ -126,21 +124,21 @@ class _FolderListingScreenState extends State<FolderListingScreen> {
|
||||
);
|
||||
if (folderName is String) {
|
||||
var container = context.read<GitJournalRepo>();
|
||||
container.createFolder(selectedFolder, folderName);
|
||||
container.createFolder(selectedFolder!, folderName);
|
||||
}
|
||||
} else if (value == "Delete") {
|
||||
if (selectedFolder.hasNotesRecursive) {
|
||||
if (selectedFolder!.hasNotesRecursive) {
|
||||
await showDialog(
|
||||
context: context,
|
||||
builder: (_) => DeleteFolderErrorDialog(),
|
||||
);
|
||||
} else {
|
||||
var container = context.read<GitJournalRepo>();
|
||||
container.removeFolder(selectedFolder);
|
||||
container.removeFolder(selectedFolder!);
|
||||
}
|
||||
}
|
||||
|
||||
_folderTreeViewKey.currentState.resetSelection();
|
||||
_folderTreeViewKey.currentState!.resetSelection();
|
||||
},
|
||||
);
|
||||
}
|
||||
@ -148,7 +146,7 @@ class _FolderListingScreenState extends State<FolderListingScreen> {
|
||||
var backButton = IconButton(
|
||||
icon: const Icon(Icons.arrow_back),
|
||||
onPressed: () {
|
||||
_folderTreeViewKey.currentState.resetSelection();
|
||||
_folderTreeViewKey.currentState!.resetSelection();
|
||||
},
|
||||
);
|
||||
|
||||
@ -162,7 +160,7 @@ class _FolderListingScreenState extends State<FolderListingScreen> {
|
||||
title: title,
|
||||
leading: selectedFolder == null ? GJAppBarMenuButton() : backButton,
|
||||
actions: <Widget>[
|
||||
if (selectedFolder != null) action,
|
||||
if (selectedFolder != null) action!,
|
||||
],
|
||||
),
|
||||
body: Scrollbar(child: treeView),
|
||||
@ -215,7 +213,7 @@ class _CreateFolderAlertDialogState extends State<CreateFolderAlertDialog> {
|
||||
labelText: tr("screens.folders.actions.decoration"),
|
||||
),
|
||||
validator: (value) {
|
||||
if (value.isEmpty) return tr("screens.folders.actions.empty");
|
||||
if (value!.isEmpty) return tr("screens.folders.actions.empty");
|
||||
return "";
|
||||
},
|
||||
autofocus: true,
|
||||
|
@ -1,5 +1,3 @@
|
||||
// @dart=2.9
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:auto_size_text/auto_size_text.dart';
|
||||
@ -153,9 +151,9 @@ class OnBoardingBottomButton extends StatelessWidget {
|
||||
final String text;
|
||||
|
||||
OnBoardingBottomButton({
|
||||
Key key,
|
||||
@required this.text,
|
||||
@required this.onPressed,
|
||||
Key? key,
|
||||
required this.text,
|
||||
required this.onPressed,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
@ -177,7 +175,7 @@ class OnBoardingPage1 extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var textTheme = Theme.of(context).textTheme;
|
||||
var headerTextStyle = textTheme.headline2.copyWith(fontFamily: "Lato");
|
||||
var headerTextStyle = textTheme.headline2!.copyWith(fontFamily: "Lato");
|
||||
var header = Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
|
@ -1,25 +1,23 @@
|
||||
// @dart=2.9
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'error.dart';
|
||||
import 'loading.dart';
|
||||
|
||||
class GitHostSetupLoadingErrorPage extends StatelessWidget {
|
||||
final String errorMessage;
|
||||
final String? errorMessage;
|
||||
final String loadingMessage;
|
||||
|
||||
GitHostSetupLoadingErrorPage({
|
||||
@required this.errorMessage,
|
||||
@required this.loadingMessage,
|
||||
required this.errorMessage,
|
||||
required this.loadingMessage,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (errorMessage == null || errorMessage.isEmpty) {
|
||||
if (errorMessage == null || errorMessage!.isEmpty) {
|
||||
return GitHostSetupLoadingPage(loadingMessage);
|
||||
}
|
||||
|
||||
return GitHostSetupErrorPage(errorMessage);
|
||||
return GitHostSetupErrorPage(errorMessage!);
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,3 @@
|
||||
// @dart=2.9
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:easy_localization/easy_localization.dart';
|
||||
@ -13,21 +11,21 @@ class GitHostSetupSshKeyKnownProvider extends StatelessWidget {
|
||||
final Func0<void> doneFunction;
|
||||
final Func0<void> regenerateFunction;
|
||||
final Func1<BuildContext, void> copyKeyFunction;
|
||||
final String publicKey;
|
||||
final String? publicKey;
|
||||
|
||||
final Func0<void> openDeployKeyPage;
|
||||
|
||||
GitHostSetupSshKeyKnownProvider({
|
||||
@required this.doneFunction,
|
||||
@required this.regenerateFunction,
|
||||
@required this.copyKeyFunction,
|
||||
@required this.openDeployKeyPage,
|
||||
@required this.publicKey,
|
||||
required this.doneFunction,
|
||||
required this.regenerateFunction,
|
||||
required this.copyKeyFunction,
|
||||
required this.openDeployKeyPage,
|
||||
required this.publicKey,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (publicKey == null || publicKey.isEmpty) {
|
||||
if (publicKey == null || publicKey!.isEmpty) {
|
||||
return GitHostSetupLoadingPage(tr("setup.sshKey.generate"));
|
||||
}
|
||||
|
||||
@ -47,7 +45,7 @@ class GitHostSetupSshKeyKnownProvider extends StatelessWidget {
|
||||
style: Theme.of(context).textTheme.subtitle2,
|
||||
),
|
||||
const SizedBox(height: 8.0),
|
||||
PublicKeyWidget(publicKey),
|
||||
PublicKeyWidget(publicKey!),
|
||||
const SizedBox(height: 8.0),
|
||||
|
||||
GitHostSetupButton(
|
||||
@ -97,18 +95,18 @@ class GitHostSetupSshKeyUnknownProvider extends StatelessWidget {
|
||||
final Func0<void> doneFunction;
|
||||
final Func0<void> regenerateFunction;
|
||||
final Func1<BuildContext, void> copyKeyFunction;
|
||||
final String publicKey;
|
||||
final String? publicKey;
|
||||
|
||||
GitHostSetupSshKeyUnknownProvider({
|
||||
@required this.doneFunction,
|
||||
@required this.regenerateFunction,
|
||||
@required this.copyKeyFunction,
|
||||
@required this.publicKey,
|
||||
required this.doneFunction,
|
||||
required this.regenerateFunction,
|
||||
required this.copyKeyFunction,
|
||||
required this.publicKey,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (publicKey == null || publicKey.isEmpty) {
|
||||
if (publicKey == null || publicKey!.isEmpty) {
|
||||
return GitHostSetupLoadingPage(tr("setup.sshKey.generate"));
|
||||
}
|
||||
|
||||
@ -128,7 +126,7 @@ class GitHostSetupSshKeyUnknownProvider extends StatelessWidget {
|
||||
style: Theme.of(context).textTheme.subtitle2,
|
||||
),
|
||||
const SizedBox(height: 8.0),
|
||||
PublicKeyWidget(publicKey),
|
||||
PublicKeyWidget(publicKey!),
|
||||
const SizedBox(height: 8.0),
|
||||
|
||||
GitHostSetupButton(
|
||||
@ -174,8 +172,8 @@ class GitHostSetupKeyChoice extends StatelessWidget {
|
||||
final Func0<void> onUserProvidedKeys;
|
||||
|
||||
GitHostSetupKeyChoice({
|
||||
@required this.onGenerateKeys,
|
||||
@required this.onUserProvidedKeys,
|
||||
required this.onGenerateKeys,
|
||||
required this.onUserProvidedKeys,
|
||||
});
|
||||
|
||||
@override
|
||||
@ -211,7 +209,7 @@ class GitHostUserProvidedKeys extends StatefulWidget {
|
||||
final String saveText;
|
||||
|
||||
GitHostUserProvidedKeys({
|
||||
@required this.doneFunction,
|
||||
required this.doneFunction,
|
||||
this.saveText = "",
|
||||
});
|
||||
|
||||
@ -221,13 +219,13 @@ class GitHostUserProvidedKeys extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _GitHostUserProvidedKeysState extends State<GitHostUserProvidedKeys> {
|
||||
GlobalKey<FormState> _publicFormKey;
|
||||
GlobalKey<FormState> _privateFormKey;
|
||||
TextEditingController _publicKeyController;
|
||||
TextEditingController _privateKeyController;
|
||||
TextEditingController _passwordController;
|
||||
late GlobalKey<FormState> _publicFormKey;
|
||||
late GlobalKey<FormState> _privateFormKey;
|
||||
late TextEditingController _publicKeyController;
|
||||
late TextEditingController _privateKeyController;
|
||||
late TextEditingController _passwordController;
|
||||
|
||||
String saveText;
|
||||
late String saveText;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@ -282,8 +280,8 @@ class _GitHostUserProvidedKeysState extends State<GitHostUserProvidedKeys> {
|
||||
GitHostSetupButton(
|
||||
text: saveText,
|
||||
onPressed: () {
|
||||
var publicValid = _publicFormKey.currentState.validate();
|
||||
var privateValid = _privateFormKey.currentState.validate();
|
||||
var publicValid = _publicFormKey.currentState!.validate();
|
||||
var privateValid = _privateFormKey.currentState!.validate();
|
||||
|
||||
if (!publicValid || !privateValid) {
|
||||
return;
|
||||
|
@ -1,5 +1,3 @@
|
||||
// @dart=2.9
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
@ -17,9 +15,9 @@ class NoteViewer extends StatelessWidget {
|
||||
final Note note;
|
||||
final NotesFolder parentFolder;
|
||||
const NoteViewer({
|
||||
Key key,
|
||||
@required this.note,
|
||||
@required this.parentFolder,
|
||||
Key? key,
|
||||
required this.note,
|
||||
required this.parentFolder,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
|
Reference in New Issue
Block a user