refactor: Migrate to null safety

This commit is contained in:
Krille Fear 2022-01-29 12:35:03 +01:00 committed by Christian Pauly
commit 55f0300f9f
163 changed files with 1759 additions and 1903 deletions

View file

@ -11,7 +11,7 @@ import 'package:fluffychat/utils/url_launcher.dart';
import 'package:fluffychat/widgets/matrix.dart';
class NewPrivateChat extends StatefulWidget {
const NewPrivateChat({Key key}) : super(key: key);
const NewPrivateChat({Key? key}) : super(key: key);
@override
NewPrivateChatController createState() => NewPrivateChatController();
@ -48,20 +48,20 @@ class NewPrivateChatController extends State<NewPrivateChat> {
void submitAction([_]) async {
controller.text = controller.text.trim();
if (!formKey.currentState.validate()) return;
if (!formKey.currentState!.validate()) return;
UrlLauncher(context, '$prefix${controller.text}').openMatrixToUrl();
}
String validateForm(String value) {
if (value.isEmpty) {
return L10n.of(context).pleaseEnterAMatrixIdentifier;
String? validateForm(String? value) {
if (value!.isEmpty) {
return L10n.of(context)!.pleaseEnterAMatrixIdentifier;
}
if (!controller.text.isValidMatrixId ||
!supportedSigils.contains(controller.text.sigil)) {
return L10n.of(context).makeSureTheIdentifierIsValid;
return L10n.of(context)!.makeSureTheIdentifierIsValid;
}
if (controller.text == Matrix.of(context).client.userID) {
return L10n.of(context).youCannotInviteYourself;
return L10n.of(context)!.youCannotInviteYourself;
}
return null;
}

View file

@ -15,7 +15,7 @@ import 'package:fluffychat/widgets/matrix.dart';
class NewPrivateChatView extends StatelessWidget {
final NewPrivateChatController controller;
const NewPrivateChatView(this.controller, {Key key}) : super(key: key);
const NewPrivateChatView(this.controller, {Key? key}) : super(key: key);
static const double _qrCodePadding = 8;
@ -24,13 +24,13 @@ class NewPrivateChatView extends StatelessWidget {
return Scaffold(
appBar: AppBar(
leading: const BackButton(),
title: Text(L10n.of(context).newChat),
title: Text(L10n.of(context)!.newChat),
backgroundColor: Theme.of(context).scaffoldBackgroundColor,
actions: [
TextButton(
onPressed: () => VRouter.of(context).to('/newgroup'),
child: Text(
L10n.of(context).createNewGroup,
L10n.of(context)!.createNewGroup,
style: TextStyle(color: Theme.of(context).colorScheme.secondary),
),
)
@ -67,7 +67,7 @@ class NewPrivateChatView extends StatelessWidget {
),
),
ListTile(
subtitle: Text(L10n.of(context).createNewChatExplaination),
subtitle: Text(L10n.of(context)!.createNewChatExplaination),
),
Padding(
padding: const EdgeInsets.all(12),
@ -81,7 +81,7 @@ class NewPrivateChatView extends StatelessWidget {
onFieldSubmitted: controller.submitAction,
validator: controller.validateForm,
decoration: InputDecoration(
labelText: L10n.of(context).typeInInviteLinkManually,
labelText: L10n.of(context)!.typeInInviteLinkManually,
hintText: '@username',
prefixText: 'matrix.to/#/',
suffixIcon: IconButton(
@ -105,7 +105,7 @@ class NewPrivateChatView extends StatelessWidget {
floatingActionButton: PlatformInfos.isMobile && !controller.hideFab
? FloatingActionButton.extended(
onPressed: controller.openScannerAction,
label: Text(L10n.of(context).scanQrCode),
label: Text(L10n.of(context)!.scanQrCode),
icon: const Icon(Icons.camera_alt_outlined),
)
: null,

View file

@ -9,7 +9,7 @@ import 'package:qr_code_scanner/qr_code_scanner.dart';
import 'package:fluffychat/utils/url_launcher.dart';
class QrScannerModal extends StatefulWidget {
const QrScannerModal({Key key}) : super(key: key);
const QrScannerModal({Key? key}) : super(key: key);
@override
_QrScannerModalState createState() => _QrScannerModalState();
@ -17,15 +17,15 @@ class QrScannerModal extends StatefulWidget {
class _QrScannerModalState extends State<QrScannerModal> {
final GlobalKey qrKey = GlobalKey(debugLabel: 'QR');
QRViewController controller;
QRViewController? controller;
@override
void reassemble() {
super.reassemble();
if (Platform.isAndroid) {
controller.pauseCamera();
controller!.pauseCamera();
} else if (Platform.isIOS) {
controller.resumeCamera();
controller!.resumeCamera();
}
}
@ -36,9 +36,9 @@ class _QrScannerModalState extends State<QrScannerModal> {
leading: IconButton(
icon: const Icon(Icons.close_outlined),
onPressed: Navigator.of(context).pop,
tooltip: L10n.of(context).close,
tooltip: L10n.of(context)!.close,
),
title: Text(L10n.of(context).scanQrCode),
title: Text(L10n.of(context)!.scanQrCode),
),
body: Stack(
children: [
@ -59,7 +59,7 @@ class _QrScannerModalState extends State<QrScannerModal> {
void _onQRViewCreated(QRViewController controller) {
this.controller = controller;
StreamSubscription sub;
late StreamSubscription sub;
sub = controller.scannedDataStream.listen((scanData) {
sub.cancel();
Navigator.of(context).pop();