null safety++

This commit is contained in:
Vishesh Handa
2021-05-18 11:19:57 +02:00
parent 54195a16da
commit e0311e598e
8 changed files with 40 additions and 44 deletions

View File

@ -0,0 +1,6 @@
enum FolderViewType {
Standard,
Journal,
Card,
Grid,
}

View File

@ -1,5 +1,3 @@
// @dart=2.9
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
@ -55,7 +53,7 @@ class FeatureTile extends StatelessWidget {
subtitle += ' - ' + feature.subtitle;
}
Color color;
late Color color;
var theme = Theme.of(context);
if (feature.pro) {
@ -82,19 +80,19 @@ class _Tile extends StatelessWidget {
final Color iconColor;
_Tile({
@required this.title,
@required this.subTitle,
@required this.iconText,
@required this.iconColor,
required this.title,
required this.subTitle,
required this.iconText,
required this.iconColor,
});
@override
Widget build(BuildContext context) {
var theme = Theme.of(context);
var textTheme = theme.textTheme;
var titleTextStyle = textTheme.subtitle1.copyWith();
var subTitleTextStyle = textTheme.bodyText2.copyWith(
color: textTheme.caption.color,
var titleTextStyle = textTheme.subtitle1!.copyWith();
var subTitleTextStyle = textTheme.bodyText2!.copyWith(
color: textTheme.caption!.color,
);
return Container(
@ -137,7 +135,7 @@ class _Tile extends StatelessWidget {
class _Sign extends StatelessWidget {
final String text;
final Color color;
final Color? color;
_Sign(this.text, this.color);
@ -146,7 +144,7 @@ class _Sign extends StatelessWidget {
var theme = Theme.of(context);
var textStyle = theme.textTheme.subtitle2;
if (color != null) {
textStyle = textStyle.copyWith(color: color);
textStyle = textStyle!.copyWith(color: color);
}
return Text(text, style: textStyle);

View File

@ -1,4 +1,4 @@
// @dart=2.9
import 'package:flutter/material.dart';
@ -17,8 +17,8 @@ class HomeScreen extends StatefulWidget {
}
class _HomeScreenState extends State<HomeScreen> {
NotesFolder notesFolder;
NotesFolderFS rootFolder;
NotesFolder? notesFolder;
NotesFolderFS? rootFolder;
@override
void initState() {

View File

@ -1,5 +1,3 @@
// @dart=2.9
/*
Copyright 2020-2021 Roland Fredenhagen <important@van-fredenhagen.de>
@ -93,7 +91,7 @@ class SettingsDisplayImagesScreenState
)
: Text(
NumberFormat("##.0").format(settings.maxImageZoom),
style: theme.textTheme.subtitle2
style: theme.textTheme.subtitle2!
.copyWith(color: theme.accentColor),
textAlign: TextAlign.center,
))

View File

@ -1,21 +1,19 @@
// @dart=2.9
import 'package:flutter/material.dart';
import 'package:easy_localization/easy_localization.dart';
class ListPreference extends StatelessWidget {
final String title;
final String currentOption;
final String? currentOption;
final List<String> options;
final Function onChange;
final bool enabled;
ListPreference({
@required this.title,
@required this.currentOption,
@required this.options,
@required this.onChange,
required this.title,
required this.currentOption,
required this.options,
required this.onChange,
this.enabled = true,
});
@ -23,14 +21,14 @@ class ListPreference extends StatelessWidget {
Widget build(BuildContext context) {
return ListTile(
title: Text(title),
subtitle: Text(currentOption),
subtitle: Text(currentOption!),
onTap: () async {
var option = await showDialog<String>(
context: context,
builder: (BuildContext context) {
var children = <Widget>[];
for (var o in options) {
var tile = LabeledRadio(
var tile = _LabeledRadio(
label: o,
value: o,
groupValue: currentOption,
@ -66,17 +64,17 @@ class ListPreference extends StatelessWidget {
}
}
class LabeledRadio extends StatelessWidget {
const LabeledRadio({
this.label,
this.groupValue,
this.value,
this.onChanged,
class _LabeledRadio extends StatelessWidget {
const _LabeledRadio({
required this.label,
required this.groupValue,
required this.value,
required this.onChanged,
});
final String label;
final String groupValue;
final String value;
final String? groupValue;
final String? value;
final Function onChanged;
@override
@ -87,10 +85,10 @@ class LabeledRadio extends StatelessWidget {
},
child: Row(
children: <Widget>[
Radio<String>(
Radio<String?>(
groupValue: groupValue,
value: value,
onChanged: onChanged,
onChanged: onChanged as void Function(String?)?,
),
Text(label),
],

View File

@ -1,11 +1,9 @@
// @dart=2.9
import 'package:flutter/material.dart';
import 'package:gitjournal/screens/login_screen.dart';
class SignUpScreen extends StatefulWidget {
SignUpScreen({Key key}) : super(key: key);
SignUpScreen({Key? key}) : super(key: key);
@override
_SignUpScreenState createState() => _SignUpScreenState();

View File

@ -1,4 +1,4 @@
// @dart=2.9
import 'package:flutter/material.dart';
@ -60,7 +60,7 @@ class TagListingScreen extends StatelessWidget {
Widget _buildTagTile(BuildContext context, String tag) {
var theme = Theme.of(context);
var titleColor = theme.textTheme.headline1.color;
var titleColor = theme.textTheme.headline1!.color;
return ListTile(
leading: FaIcon(FontAwesomeIcons.tag, color: titleColor),

View File

@ -1,5 +1,3 @@
// @dart=2.9
import 'package:flutter/material.dart';
import 'package:easy_localization/easy_localization.dart';