Migrate some widgets to null safety

This commit is contained in:
Vishesh Handa
2021-05-17 23:03:52 +02:00
parent d035238d92
commit 53fd080214
4 changed files with 22 additions and 28 deletions

View File

@ -1,5 +1,3 @@
// @dart=2.9
import 'package:flutter/material.dart';
import 'package:easy_localization/easy_localization.dart';
@ -13,7 +11,7 @@ class ProOverlay extends StatelessWidget {
final Widget child;
final Feature feature;
ProOverlay({@required this.child, @required this.feature}) {
ProOverlay({required this.child, required this.feature}) {
assert(feature.pro == true);
}

View File

@ -1,5 +1,3 @@
// @dart=2.9
import 'dart:io';
import 'package:flutter/material.dart';
@ -14,9 +12,9 @@ class RenameDialog extends StatefulWidget {
final String dialogTitle;
RenameDialog({
@required this.oldPath,
@required this.inputDecoration,
@required this.dialogTitle,
required this.oldPath,
required this.inputDecoration,
required this.dialogTitle,
});
@override
@ -24,7 +22,7 @@ class RenameDialog extends StatefulWidget {
}
class _RenameDialogState extends State<RenameDialog> {
TextEditingController _textController;
late TextEditingController _textController;
final _formKey = GlobalKey<FormState>();
@override
@ -43,7 +41,7 @@ class _RenameDialogState extends State<RenameDialog> {
TextFormField(
decoration: InputDecoration(labelText: widget.inputDecoration),
validator: (value) {
if (value.isEmpty) {
if (value!.isEmpty) {
return tr('widgets.rename.validator.empty');
}
@ -76,7 +74,7 @@ class _RenameDialogState extends State<RenameDialog> {
),
TextButton(
onPressed: () {
if (_formKey.currentState.validate()) {
if (_formKey.currentState!.validate()) {
var newName = _textController.text;
Navigator.of(context).pop(newName);
}

View File

@ -1,5 +1,3 @@
// @dart=2.9
import 'package:flutter/material.dart';
import 'package:easy_localization/easy_localization.dart';
@ -17,8 +15,8 @@ class SortingModeSelector extends StatefulWidget {
}
class _SortingModeSelectorState extends State<SortingModeSelector> {
SortingField field;
SortingOrder order;
late SortingField field;
late SortingOrder order;
@override
void initState() {
@ -68,9 +66,9 @@ class _SortingModeSelectorState extends State<SortingModeSelector> {
title: Text(sf.toPublicString()),
value: sf,
groupValue: field,
onChanged: (SortingField sf) {
onChanged: (SortingField? sf) {
setState(() {
field = sf;
field = sf!;
});
},
);
@ -81,9 +79,9 @@ class _SortingModeSelectorState extends State<SortingModeSelector> {
title: Text(so.toPublicString()),
value: so,
groupValue: order,
onChanged: (SortingOrder so) {
onChanged: (SortingOrder? so) {
setState(() {
order = so;
order = so!;
});
},
);

View File

@ -1,4 +1,4 @@
// @dart=2.9
import 'dart:async';
@ -19,8 +19,8 @@ class SyncButton extends StatefulWidget {
}
class _SyncButtonState extends State<SyncButton> {
StreamSubscription<ConnectivityResult> subscription;
ConnectivityResult _connectivity;
late StreamSubscription<ConnectivityResult> subscription;
ConnectivityResult? _connectivity;
@override
void initState() {
@ -126,7 +126,7 @@ class BlinkingIcon extends StatefulWidget {
final Widget child;
final int interval;
BlinkingIcon({@required this.child, this.interval = 500, Key key})
BlinkingIcon({required this.child, this.interval = 500, Key? key})
: super(key: key);
@override
@ -135,8 +135,8 @@ class BlinkingIcon extends StatefulWidget {
class _BlinkingIconState extends State<BlinkingIcon>
with SingleTickerProviderStateMixin {
AnimationController _controller;
Animation<double> _animation;
late AnimationController _controller;
late Animation<double> _animation;
@override
void initState() {
@ -172,13 +172,13 @@ class _BlinkingIconState extends State<BlinkingIcon>
class GitPendingChangesBadge extends StatelessWidget {
final Widget child;
GitPendingChangesBadge({@required this.child});
GitPendingChangesBadge({required this.child});
@override
Widget build(BuildContext context) {
var theme = Theme.of(context);
var darkMode = theme.brightness == Brightness.dark;
var style = theme.textTheme.caption.copyWith(
var style = theme.textTheme.caption!.copyWith(
fontSize: 6.0,
color: darkMode ? Colors.black : Colors.white,
);
@ -188,7 +188,7 @@ class GitPendingChangesBadge extends StatelessWidget {
return Badge(
badgeContent: Text(repo.numChanges.toString(), style: style),
showBadge: repo.numChanges != 0,
badgeColor: theme.iconTheme.color,
badgeColor: theme.iconTheme.color!,
position: BadgePosition.topEnd(top: 10.0, end: 4.0),
child: child,
);