Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated the null check condition on taskserver page #309

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 2 additions & 10 deletions lib/drawer/nav_drawer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import 'package:taskwarrior/config/app_settings.dart';
import 'package:taskwarrior/config/taskwarriorcolors.dart';
import 'package:taskwarrior/config/taskwarriorfonts.dart';
import 'package:taskwarrior/model/storage/storage_widget.dart';
import 'package:taskwarrior/utility/utilities.dart';
import 'package:taskwarrior/views/about/about.dart';
import 'package:taskwarrior/views/profile/profile.dart';
import 'package:taskwarrior/views/reports/reports_home.dart';
Expand Down Expand Up @@ -211,16 +212,7 @@ Future<void> _showExitConfirmationDialog(BuildContext context) async {
context: context,
barrierDismissible: false, // Prevents closing the dialog by tapping outside
builder: (BuildContext context) {
return AlertDialog(
surfaceTintColor: AppSettings.isDarkMode
? TaskWarriorColors.kdialogBackGroundColor
: TaskWarriorColors.kLightDialogBackGroundColor,
shadowColor: AppSettings.isDarkMode
? TaskWarriorColors.kdialogBackGroundColor
: TaskWarriorColors.kLightDialogBackGroundColor,
backgroundColor: AppSettings.isDarkMode
? TaskWarriorColors.kdialogBackGroundColor
: TaskWarriorColors.kLightDialogBackGroundColor,
return Utils.showAlertDialog(
title: Text(
'Exit App',
style: TextStyle(
Expand Down
23 changes: 3 additions & 20 deletions lib/services/task_details.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import 'package:taskwarrior/config/app_settings.dart';
import 'package:taskwarrior/config/taskwarriorcolors.dart';
import 'package:taskwarrior/config/taskwarriorfonts.dart';
import 'package:taskwarrior/model/storage/storage_widget.dart';
import 'package:taskwarrior/utility/utilities.dart';
import 'package:taskwarrior/views/home/home.dart';
import 'package:taskwarrior/widgets/pallete.dart';
import 'package:taskwarrior/widgets/taskdetails.dart';
Expand Down Expand Up @@ -86,16 +87,7 @@ class _DetailRouteState extends State<DetailRoute> {
return showDialog(
context: context,
builder: (context) {
return AlertDialog(
surfaceTintColor: AppSettings.isDarkMode
? TaskWarriorColors.kdialogBackGroundColor
: TaskWarriorColors.kLightDialogBackGroundColor,
shadowColor: AppSettings.isDarkMode
? TaskWarriorColors.kdialogBackGroundColor
: TaskWarriorColors.kLightDialogBackGroundColor,
backgroundColor: AppSettings.isDarkMode
? TaskWarriorColors.kdialogBackGroundColor
: TaskWarriorColors.kLightDialogBackGroundColor,
return Utils.showAlertDialog(
title: Text(
'Do you want to save changes?',
style: TextStyle(
Expand Down Expand Up @@ -219,16 +211,7 @@ class _DetailRouteState extends State<DetailRoute> {
showDialog(
context: context,
builder: (context) {
return AlertDialog(
surfaceTintColor: AppSettings.isDarkMode
? TaskWarriorColors.kdialogBackGroundColor
: TaskWarriorColors.kLightDialogBackGroundColor,
shadowColor: AppSettings.isDarkMode
? TaskWarriorColors.kdialogBackGroundColor
: TaskWarriorColors.kLightDialogBackGroundColor,
backgroundColor: AppSettings.isDarkMode
? TaskWarriorColors.kdialogBackGroundColor
: TaskWarriorColors.kLightDialogBackGroundColor,
return Utils.showAlertDialog(
scrollable: true,
title: Text(
'Review changes:',
Expand Down
27 changes: 6 additions & 21 deletions lib/taskserver/ntaskserver.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'package:get/get.dart';
import 'package:loggy/loggy.dart';
import 'package:taskwarrior/config/taskwarriorcolors.dart';
import 'package:taskwarrior/config/taskwarriorfonts.dart';
import 'package:taskwarrior/utility/utilities.dart';
import 'package:taskwarrior/widgets/taskdetails/profiles_widget.dart';
// ignore_for_file: use_build_context_synchronously

Expand Down Expand Up @@ -77,16 +78,7 @@ class _ManageTaskServerState extends State<ManageTaskServer> {
context: context,
barrierDismissible: false,
builder: (context) {
return AlertDialog(
surfaceTintColor: AppSettings.isDarkMode
? TaskWarriorColors.kdialogBackGroundColor
: TaskWarriorColors.kLightDialogBackGroundColor,
shadowColor: AppSettings.isDarkMode
? TaskWarriorColors.kdialogBackGroundColor
: TaskWarriorColors.kLightDialogBackGroundColor,
backgroundColor: AppSettings.isDarkMode
? TaskWarriorColors.kdialogBackGroundColor
: TaskWarriorColors.kLightDialogBackGroundColor,
return Utils.showAlertDialog(
title: const Text('Fetching statistics...'),
content: const Column(
mainAxisSize: MainAxisSize.min,
Expand Down Expand Up @@ -114,16 +106,7 @@ class _ManageTaskServerState extends State<ManageTaskServer> {
// Show statistics in a dialog
await showDialog(
context: context,
builder: (context) => AlertDialog(
surfaceTintColor: AppSettings.isDarkMode
? TaskWarriorColors.kdialogBackGroundColor
: TaskWarriorColors.kLightDialogBackGroundColor,
shadowColor: AppSettings.isDarkMode
? TaskWarriorColors.kdialogBackGroundColor
: TaskWarriorColors.kLightDialogBackGroundColor,
backgroundColor: AppSettings.isDarkMode
? TaskWarriorColors.kdialogBackGroundColor
: TaskWarriorColors.kLightDialogBackGroundColor,
builder: (context) => Utils.showAlertDialog(
scrollable: true,
title: Text(
'Statistics:',
Expand Down Expand Up @@ -840,7 +823,9 @@ class _PemWidgetState extends State<PemWidget> {
var name = widget.storage.guiPemFiles.pemFilename(widget.pem);
String identifier = "";
try {
identifier = fingerprint(contents!).toUpperCase();
if (contents != null) {
identifier = fingerprint(contents).toUpperCase(); // Null check removed
}
} catch (e) {
debugPrint(e.toString());
}
Expand Down
64 changes: 64 additions & 0 deletions lib/utility/utilities.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
import 'package:taskwarrior/config/app_settings.dart';
import 'package:taskwarrior/config/taskwarriorcolors.dart';

class Utils {
static String getWeekNumber(DateTime? date) {
Expand Down Expand Up @@ -48,4 +51,65 @@ class Utils {
return '';
}
}

static AlertDialog showAlertDialog({
Key? key,
Widget? icon,
EdgeInsetsGeometry? iconPadding,
Color? iconColor,
Widget? title,
EdgeInsetsGeometry? titlePadding,
TextStyle? titleTextStyle,
Widget? content,
EdgeInsetsGeometry? contentPadding,
TextStyle? contentTextStyle,
List<Widget>? actions,
EdgeInsetsGeometry? actionsPadding,
MainAxisAlignment? actionsAlignment,
OverflowBarAlignment? actionsOverflowAlignment,
VerticalDirection? actionsOverflowDirection,
double? actionsOverflowButtonSpacing,
EdgeInsetsGeometry? buttonPadding,
Color? backgroundColor,
double? elevation,
Color? shadowColor,
Color? surfaceTintColor,
String? semanticLabel,
Clip clipBehavior = Clip.none,
ShapeBorder? shape,
AlignmentGeometry? alignment,
bool scrollable = false,
}) {
return AlertDialog(
surfaceTintColor: AppSettings.isDarkMode
? TaskWarriorColors.kdialogBackGroundColor
: TaskWarriorColors.kLightDialogBackGroundColor,
shadowColor: AppSettings.isDarkMode
? TaskWarriorColors.kdialogBackGroundColor
: TaskWarriorColors.kLightDialogBackGroundColor,
backgroundColor: AppSettings.isDarkMode
? TaskWarriorColors.kdialogBackGroundColor
: TaskWarriorColors.kLightDialogBackGroundColor,
key: key,
title: title,
titlePadding: titlePadding,
titleTextStyle: titleTextStyle,
content: content,
contentPadding: contentPadding,
contentTextStyle: contentTextStyle,
actions: actions,
actionsPadding: actionsPadding,
actionsAlignment: actionsAlignment,
actionsOverflowAlignment: actionsOverflowAlignment,
actionsOverflowDirection: actionsOverflowDirection,
actionsOverflowButtonSpacing: actionsOverflowButtonSpacing,
buttonPadding: buttonPadding,
elevation: elevation,
semanticLabel: semanticLabel,
clipBehavior: clipBehavior,
shape: shape,
alignment: alignment,
scrollable: scrollable,
);
}
}
12 changes: 2 additions & 10 deletions lib/views/profile/profile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import 'package:taskwarrior/config/app_settings.dart';
import 'package:taskwarrior/config/taskwarriorcolors.dart';
import 'package:taskwarrior/model/storage/savefile.dart';
import 'package:taskwarrior/taskserver/ntaskserver.dart';
import 'package:taskwarrior/utility/utilities.dart';
import 'package:taskwarrior/widgets/pallete.dart';
import 'package:taskwarrior/widgets/profilefunctions.dart';
import 'package:taskwarrior/widgets/taskdetails.dart';
Expand Down Expand Up @@ -85,16 +86,7 @@ class _ProfilePageState extends State<ProfilePage> {
showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
surfaceTintColor: AppSettings.isDarkMode
? TaskWarriorColors.kdialogBackGroundColor
: TaskWarriorColors.kLightDialogBackGroundColor,
shadowColor: AppSettings.isDarkMode
? TaskWarriorColors.kdialogBackGroundColor
: TaskWarriorColors.kLightDialogBackGroundColor,
backgroundColor: AppSettings.isDarkMode
? TaskWarriorColors.kdialogBackGroundColor
: TaskWarriorColors.kLightDialogBackGroundColor,
return Utils.showAlertDialog(
title: Text(
"Export Format",
style: TextStyle(
Expand Down
29 changes: 3 additions & 26 deletions lib/views/settings/settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import 'package:file_picker/file_picker.dart';
import 'package:taskwarrior/config/app_settings.dart';
import 'package:taskwarrior/config/taskwarriorcolors.dart';
import 'package:taskwarrior/config/taskwarriorfonts.dart';
import 'package:taskwarrior/utility/utilities.dart';
import 'package:taskwarrior/widgets/pallete.dart';
import 'package:taskwarrior/widgets/taskdetails/profiles_widget.dart';

Expand Down Expand Up @@ -260,22 +261,7 @@ class _SettingsPageState extends State<SettingsPage> {
showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
surfaceTintColor: AppSettings.isDarkMode
? TaskWarriorColors
.kdialogBackGroundColor
: TaskWarriorColors
.kLightDialogBackGroundColor,
shadowColor: AppSettings.isDarkMode
? TaskWarriorColors
.kdialogBackGroundColor
: TaskWarriorColors
.kLightDialogBackGroundColor,
backgroundColor: AppSettings.isDarkMode
? TaskWarriorColors
.kdialogBackGroundColor
: TaskWarriorColors
.kLightDialogBackGroundColor,
return Utils.showAlertDialog(
title: Text(
'Reset to default',
style: GoogleFonts.poppins(
Expand Down Expand Up @@ -414,16 +400,7 @@ class _SettingsPageState extends State<SettingsPage> {
showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
surfaceTintColor: AppSettings.isDarkMode
? TaskWarriorColors.kdialogBackGroundColor
: TaskWarriorColors.kLightDialogBackGroundColor,
shadowColor: AppSettings.isDarkMode
? TaskWarriorColors.kdialogBackGroundColor
: TaskWarriorColors.kLightDialogBackGroundColor,
backgroundColor: AppSettings.isDarkMode
? TaskWarriorColors.kdialogBackGroundColor
: TaskWarriorColors.kLightDialogBackGroundColor,
return Utils.showAlertDialog(
title: Text(
'Error',
style: GoogleFonts.poppins(
Expand Down
12 changes: 2 additions & 10 deletions lib/widgets/add_Task.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import 'package:taskwarrior/config/taskwarriorcolors.dart';
import 'package:taskwarrior/config/taskwarriorfonts.dart';
import 'package:taskwarrior/controller/WidgetController.dart';
import 'package:taskwarrior/model/storage/storage_widget.dart';
import 'package:taskwarrior/utility/utilities.dart';
import 'package:taskwarrior/widgets/taskfunctions/taskparser.dart';
import 'package:taskwarrior/widgets/taskw.dart';

Expand Down Expand Up @@ -49,16 +50,7 @@ class _AddTaskBottomSheetState extends State<AddTaskBottomSheet> {

return Center(
child: SingleChildScrollView(
child: AlertDialog(
surfaceTintColor: AppSettings.isDarkMode
? TaskWarriorColors.kdialogBackGroundColor
: TaskWarriorColors.kLightDialogBackGroundColor,
shadowColor: AppSettings.isDarkMode
? TaskWarriorColors.kdialogBackGroundColor
: TaskWarriorColors.kLightDialogBackGroundColor,
backgroundColor: AppSettings.isDarkMode
? TaskWarriorColors.kdialogBackGroundColor
: TaskWarriorColors.kLightDialogBackGroundColor,
child: Utils.showAlertDialog(
title: Center(
child: Text(
title,
Expand Down
12 changes: 2 additions & 10 deletions lib/widgets/profilefunctions/deleteprofiledialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'package:flutter/material.dart';

import 'package:taskwarrior/config/app_settings.dart';
import 'package:taskwarrior/config/taskwarriorcolors.dart';
import 'package:taskwarrior/utility/utilities.dart';
import 'package:taskwarrior/widgets/taskdetails/profiles_widget.dart';

class DeleteProfileDialog extends StatelessWidget {
Expand All @@ -19,16 +20,7 @@ class DeleteProfileDialog extends StatelessWidget {
return Center(
child: SingleChildScrollView(
child: Center(
child: AlertDialog(
surfaceTintColor: AppSettings.isDarkMode
? TaskWarriorColors.kdialogBackGroundColor
: TaskWarriorColors.kLightDialogBackGroundColor,
shadowColor: AppSettings.isDarkMode
? TaskWarriorColors.kdialogBackGroundColor
: TaskWarriorColors.kLightDialogBackGroundColor,
backgroundColor: AppSettings.isDarkMode
? TaskWarriorColors.kdialogBackGroundColor
: TaskWarriorColors.kLightDialogBackGroundColor,
child: Utils.showAlertDialog(
scrollable: true,
title: Text(
'Delete Profile?',
Expand Down
12 changes: 2 additions & 10 deletions lib/widgets/profilefunctions/renameprofiledialog.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import 'package:taskwarrior/config/app_settings.dart';
import 'package:taskwarrior/config/taskwarriorcolors.dart';
import 'package:taskwarrior/utility/utilities.dart';

import 'package:taskwarrior/widgets/taskdetails.dart';

Expand All @@ -22,16 +23,7 @@ class RenameProfileDialog extends StatelessWidget {

return SingleChildScrollView(
child: Center(
child: AlertDialog(
surfaceTintColor: AppSettings.isDarkMode
? TaskWarriorColors.kdialogBackGroundColor
: TaskWarriorColors.kLightDialogBackGroundColor,
shadowColor: AppSettings.isDarkMode
? TaskWarriorColors.kdialogBackGroundColor
: TaskWarriorColors.kLightDialogBackGroundColor,
backgroundColor: AppSettings.isDarkMode
? TaskWarriorColors.kdialogBackGroundColor
: TaskWarriorColors.kLightDialogBackGroundColor,
child: Utils.showAlertDialog(
scrollable: true,
title: Text(
'Rename Alias',
Expand Down
23 changes: 3 additions & 20 deletions lib/widgets/taskdetails/description_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import 'package:loggy/loggy.dart';
import 'package:taskwarrior/config/app_settings.dart';
import 'package:taskwarrior/config/taskwarriorcolors.dart';
import 'package:taskwarrior/config/taskwarriorfonts.dart';
import 'package:taskwarrior/utility/utilities.dart';

class DescriptionWidget extends StatelessWidget {
const DescriptionWidget(
Expand Down Expand Up @@ -66,16 +67,7 @@ class DescriptionWidget extends StatelessWidget {
);
showDialog(
context: context,
builder: (context) => AlertDialog(
surfaceTintColor: AppSettings.isDarkMode
? TaskWarriorColors.kdialogBackGroundColor
: TaskWarriorColors.kLightDialogBackGroundColor,
shadowColor: AppSettings.isDarkMode
? TaskWarriorColors.kdialogBackGroundColor
: TaskWarriorColors.kLightDialogBackGroundColor,
backgroundColor: AppSettings.isDarkMode
? TaskWarriorColors.kdialogBackGroundColor
: TaskWarriorColors.kLightDialogBackGroundColor,
builder: (context) => Utils.showAlertDialog(
scrollable: true,
title: Text(
'Edit description',
Expand Down Expand Up @@ -195,16 +187,7 @@ class ProjectWidget extends StatelessWidget {
);
showDialog(
context: context,
builder: (context) => AlertDialog(
surfaceTintColor: AppSettings.isDarkMode
? TaskWarriorColors.kdialogBackGroundColor
: TaskWarriorColors.kLightDialogBackGroundColor,
shadowColor: AppSettings.isDarkMode
? TaskWarriorColors.kdialogBackGroundColor
: TaskWarriorColors.kLightDialogBackGroundColor,
backgroundColor: AppSettings.isDarkMode
? TaskWarriorColors.kdialogBackGroundColor
: TaskWarriorColors.kLightDialogBackGroundColor,
builder: (context) => Utils.showAlertDialog(
scrollable: true,
title: Text(
'Edit project',
Expand Down
Loading
Loading