mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-06-26 00:29:20 +08:00
Migrate some widgets to null safety
This commit is contained in:
@ -1,5 +1,3 @@
|
|||||||
// @dart=2.9
|
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import 'package:easy_localization/easy_localization.dart';
|
import 'package:easy_localization/easy_localization.dart';
|
||||||
@ -13,7 +11,7 @@ class ProOverlay extends StatelessWidget {
|
|||||||
final Widget child;
|
final Widget child;
|
||||||
final Feature feature;
|
final Feature feature;
|
||||||
|
|
||||||
ProOverlay({@required this.child, @required this.feature}) {
|
ProOverlay({required this.child, required this.feature}) {
|
||||||
assert(feature.pro == true);
|
assert(feature.pro == true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
// @dart=2.9
|
|
||||||
|
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
@ -14,9 +12,9 @@ class RenameDialog extends StatefulWidget {
|
|||||||
final String dialogTitle;
|
final String dialogTitle;
|
||||||
|
|
||||||
RenameDialog({
|
RenameDialog({
|
||||||
@required this.oldPath,
|
required this.oldPath,
|
||||||
@required this.inputDecoration,
|
required this.inputDecoration,
|
||||||
@required this.dialogTitle,
|
required this.dialogTitle,
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -24,7 +22,7 @@ class RenameDialog extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _RenameDialogState extends State<RenameDialog> {
|
class _RenameDialogState extends State<RenameDialog> {
|
||||||
TextEditingController _textController;
|
late TextEditingController _textController;
|
||||||
final _formKey = GlobalKey<FormState>();
|
final _formKey = GlobalKey<FormState>();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -43,7 +41,7 @@ class _RenameDialogState extends State<RenameDialog> {
|
|||||||
TextFormField(
|
TextFormField(
|
||||||
decoration: InputDecoration(labelText: widget.inputDecoration),
|
decoration: InputDecoration(labelText: widget.inputDecoration),
|
||||||
validator: (value) {
|
validator: (value) {
|
||||||
if (value.isEmpty) {
|
if (value!.isEmpty) {
|
||||||
return tr('widgets.rename.validator.empty');
|
return tr('widgets.rename.validator.empty');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,7 +74,7 @@ class _RenameDialogState extends State<RenameDialog> {
|
|||||||
),
|
),
|
||||||
TextButton(
|
TextButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
if (_formKey.currentState.validate()) {
|
if (_formKey.currentState!.validate()) {
|
||||||
var newName = _textController.text;
|
var newName = _textController.text;
|
||||||
Navigator.of(context).pop(newName);
|
Navigator.of(context).pop(newName);
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
// @dart=2.9
|
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import 'package:easy_localization/easy_localization.dart';
|
import 'package:easy_localization/easy_localization.dart';
|
||||||
@ -17,8 +15,8 @@ class SortingModeSelector extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _SortingModeSelectorState extends State<SortingModeSelector> {
|
class _SortingModeSelectorState extends State<SortingModeSelector> {
|
||||||
SortingField field;
|
late SortingField field;
|
||||||
SortingOrder order;
|
late SortingOrder order;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
@ -68,9 +66,9 @@ class _SortingModeSelectorState extends State<SortingModeSelector> {
|
|||||||
title: Text(sf.toPublicString()),
|
title: Text(sf.toPublicString()),
|
||||||
value: sf,
|
value: sf,
|
||||||
groupValue: field,
|
groupValue: field,
|
||||||
onChanged: (SortingField sf) {
|
onChanged: (SortingField? sf) {
|
||||||
setState(() {
|
setState(() {
|
||||||
field = sf;
|
field = sf!;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@ -81,9 +79,9 @@ class _SortingModeSelectorState extends State<SortingModeSelector> {
|
|||||||
title: Text(so.toPublicString()),
|
title: Text(so.toPublicString()),
|
||||||
value: so,
|
value: so,
|
||||||
groupValue: order,
|
groupValue: order,
|
||||||
onChanged: (SortingOrder so) {
|
onChanged: (SortingOrder? so) {
|
||||||
setState(() {
|
setState(() {
|
||||||
order = so;
|
order = so!;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// @dart=2.9
|
|
||||||
|
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
@ -19,8 +19,8 @@ class SyncButton extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _SyncButtonState extends State<SyncButton> {
|
class _SyncButtonState extends State<SyncButton> {
|
||||||
StreamSubscription<ConnectivityResult> subscription;
|
late StreamSubscription<ConnectivityResult> subscription;
|
||||||
ConnectivityResult _connectivity;
|
ConnectivityResult? _connectivity;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
@ -126,7 +126,7 @@ class BlinkingIcon extends StatefulWidget {
|
|||||||
final Widget child;
|
final Widget child;
|
||||||
final int interval;
|
final int interval;
|
||||||
|
|
||||||
BlinkingIcon({@required this.child, this.interval = 500, Key key})
|
BlinkingIcon({required this.child, this.interval = 500, Key? key})
|
||||||
: super(key: key);
|
: super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -135,8 +135,8 @@ class BlinkingIcon extends StatefulWidget {
|
|||||||
|
|
||||||
class _BlinkingIconState extends State<BlinkingIcon>
|
class _BlinkingIconState extends State<BlinkingIcon>
|
||||||
with SingleTickerProviderStateMixin {
|
with SingleTickerProviderStateMixin {
|
||||||
AnimationController _controller;
|
late AnimationController _controller;
|
||||||
Animation<double> _animation;
|
late Animation<double> _animation;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
@ -172,13 +172,13 @@ class _BlinkingIconState extends State<BlinkingIcon>
|
|||||||
class GitPendingChangesBadge extends StatelessWidget {
|
class GitPendingChangesBadge extends StatelessWidget {
|
||||||
final Widget child;
|
final Widget child;
|
||||||
|
|
||||||
GitPendingChangesBadge({@required this.child});
|
GitPendingChangesBadge({required this.child});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
var theme = Theme.of(context);
|
var theme = Theme.of(context);
|
||||||
var darkMode = theme.brightness == Brightness.dark;
|
var darkMode = theme.brightness == Brightness.dark;
|
||||||
var style = theme.textTheme.caption.copyWith(
|
var style = theme.textTheme.caption!.copyWith(
|
||||||
fontSize: 6.0,
|
fontSize: 6.0,
|
||||||
color: darkMode ? Colors.black : Colors.white,
|
color: darkMode ? Colors.black : Colors.white,
|
||||||
);
|
);
|
||||||
@ -188,7 +188,7 @@ class GitPendingChangesBadge extends StatelessWidget {
|
|||||||
return Badge(
|
return Badge(
|
||||||
badgeContent: Text(repo.numChanges.toString(), style: style),
|
badgeContent: Text(repo.numChanges.toString(), style: style),
|
||||||
showBadge: repo.numChanges != 0,
|
showBadge: repo.numChanges != 0,
|
||||||
badgeColor: theme.iconTheme.color,
|
badgeColor: theme.iconTheme.color!,
|
||||||
position: BadgePosition.topEnd(top: 10.0, end: 4.0),
|
position: BadgePosition.topEnd(top: 10.0, end: 4.0),
|
||||||
child: child,
|
child: child,
|
||||||
);
|
);
|
||||||
|
Reference in New Issue
Block a user