refactor: Update to Dart 3.10 with . shorthands
This commit is contained in:
parent
75a37f3f7c
commit
1ea649f01e
167 changed files with 3351 additions and 3912 deletions
|
|
@ -15,17 +15,14 @@ import 'package:fluffychat/widgets/future_loading_dialog.dart';
|
|||
|
||||
class KeyVerificationDialog extends StatefulWidget {
|
||||
Future<bool?> show(BuildContext context) => showAdaptiveDialog<bool>(
|
||||
context: context,
|
||||
builder: (context) => this,
|
||||
barrierDismissible: false,
|
||||
);
|
||||
context: context,
|
||||
builder: (context) => this,
|
||||
barrierDismissible: false,
|
||||
);
|
||||
|
||||
final KeyVerification request;
|
||||
|
||||
const KeyVerificationDialog({
|
||||
super.key,
|
||||
required this.request,
|
||||
});
|
||||
const KeyVerificationDialog({super.key, required this.request});
|
||||
|
||||
@override
|
||||
KeyVerificationPageState createState() => KeyVerificationPageState();
|
||||
|
|
@ -57,8 +54,10 @@ class KeyVerificationPageState extends State<KeyVerificationDialog> {
|
|||
void dispose() {
|
||||
widget.request.onUpdate =
|
||||
originalOnUpdate; // don't want to get updates anymore
|
||||
if (![KeyVerificationState.error, KeyVerificationState.done]
|
||||
.contains(widget.request.state)) {
|
||||
if (![
|
||||
KeyVerificationState.error,
|
||||
KeyVerificationState.done,
|
||||
].contains(widget.request.state)) {
|
||||
widget.request.cancel('m.user');
|
||||
}
|
||||
super.dispose();
|
||||
|
|
@ -98,8 +97,9 @@ class KeyVerificationPageState extends State<KeyVerificationDialog> {
|
|||
final theme = Theme.of(context);
|
||||
|
||||
User? user;
|
||||
final directChatId =
|
||||
widget.request.client.getDirectChatFromUserId(widget.request.userId);
|
||||
final directChatId = widget.request.client.getDirectChatFromUserId(
|
||||
widget.request.userId,
|
||||
);
|
||||
if (directChatId != null) {
|
||||
user = widget.request.client
|
||||
.getRoomById(directChatId)!
|
||||
|
|
@ -122,7 +122,7 @@ class KeyVerificationPageState extends State<KeyVerificationDialog> {
|
|||
body = Container(
|
||||
margin: const EdgeInsets.only(left: 8.0, right: 8.0),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
mainAxisSize: .min,
|
||||
children: <Widget>[
|
||||
Text(
|
||||
L10n.of(context).askSSSSSign,
|
||||
|
|
@ -152,17 +152,13 @@ class KeyVerificationPageState extends State<KeyVerificationDialog> {
|
|||
);
|
||||
buttons.add(
|
||||
AdaptiveDialogAction(
|
||||
child: Text(
|
||||
L10n.of(context).submit,
|
||||
),
|
||||
child: Text(L10n.of(context).submit),
|
||||
onPressed: () => checkInput(textEditingController.text),
|
||||
),
|
||||
);
|
||||
buttons.add(
|
||||
AdaptiveDialogAction(
|
||||
child: Text(
|
||||
L10n.of(context).skip,
|
||||
),
|
||||
child: Text(L10n.of(context).skip),
|
||||
onPressed: () => widget.request.openSSSS(skip: true),
|
||||
),
|
||||
);
|
||||
|
|
@ -170,7 +166,7 @@ class KeyVerificationPageState extends State<KeyVerificationDialog> {
|
|||
case KeyVerificationState.askAccept:
|
||||
title = Text(L10n.of(context).newVerificationRequest);
|
||||
body = Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
mainAxisSize: .min,
|
||||
children: [
|
||||
const SizedBox(height: 16),
|
||||
Avatar(
|
||||
|
|
@ -179,16 +175,14 @@ class KeyVerificationPageState extends State<KeyVerificationDialog> {
|
|||
size: Avatar.defaultSize * 2,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Text(
|
||||
L10n.of(context).askVerificationRequest(displayName),
|
||||
),
|
||||
Text(L10n.of(context).askVerificationRequest(displayName)),
|
||||
],
|
||||
);
|
||||
buttons.add(
|
||||
AdaptiveDialogAction(
|
||||
onPressed: () => widget.request.rejectVerification().then(
|
||||
(_) => Navigator.of(context, rootNavigator: false).pop(false),
|
||||
),
|
||||
(_) => Navigator.of(context, rootNavigator: false).pop(false),
|
||||
),
|
||||
child: Text(
|
||||
L10n.of(context).reject,
|
||||
style: TextStyle(color: theme.colorScheme.error),
|
||||
|
|
@ -211,10 +205,7 @@ class KeyVerificationPageState extends State<KeyVerificationDialog> {
|
|||
Stack(
|
||||
alignment: Alignment.center,
|
||||
children: [
|
||||
Avatar(
|
||||
mxContent: user?.avatarUrl,
|
||||
name: displayName,
|
||||
),
|
||||
Avatar(mxContent: user?.avatarUrl, name: displayName),
|
||||
const SizedBox(
|
||||
width: Avatar.defaultSize + 2,
|
||||
height: Avatar.defaultSize + 2,
|
||||
|
|
@ -258,16 +249,15 @@ class KeyVerificationPageState extends State<KeyVerificationDialog> {
|
|||
title = Text(L10n.of(context).compareNumbersMatch);
|
||||
final numbers = widget.request.sasNumbers;
|
||||
final numbstr = '${numbers[0]}-${numbers[1]}-${numbers[2]}';
|
||||
compareWidget =
|
||||
TextSpan(text: numbstr, style: const TextStyle(fontSize: 40));
|
||||
compareWidget = TextSpan(
|
||||
text: numbstr,
|
||||
style: const TextStyle(fontSize: 40),
|
||||
);
|
||||
}
|
||||
body = Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
mainAxisSize: .min,
|
||||
children: <Widget>[
|
||||
Text.rich(
|
||||
compareWidget,
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
Text.rich(compareWidget, textAlign: TextAlign.center),
|
||||
],
|
||||
);
|
||||
buttons.add(
|
||||
|
|
@ -291,15 +281,12 @@ class KeyVerificationPageState extends State<KeyVerificationDialog> {
|
|||
? L10n.of(context).waitingPartnerEmoji
|
||||
: L10n.of(context).waitingPartnerNumbers;
|
||||
body = Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
mainAxisSize: .min,
|
||||
children: <Widget>[
|
||||
const SizedBox(height: 16),
|
||||
const CircularProgressIndicator.adaptive(strokeWidth: 2),
|
||||
const SizedBox(height: 16),
|
||||
Text(
|
||||
acceptText,
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
Text(acceptText, textAlign: TextAlign.center),
|
||||
],
|
||||
);
|
||||
break;
|
||||
|
|
@ -315,9 +302,7 @@ class KeyVerificationPageState extends State<KeyVerificationDialog> {
|
|||
);
|
||||
buttons.add(
|
||||
AdaptiveDialogAction(
|
||||
child: Text(
|
||||
L10n.of(context).close,
|
||||
),
|
||||
child: Text(L10n.of(context).close),
|
||||
onPressed: () =>
|
||||
Navigator.of(context, rootNavigator: false).pop(true),
|
||||
),
|
||||
|
|
@ -326,7 +311,7 @@ class KeyVerificationPageState extends State<KeyVerificationDialog> {
|
|||
case KeyVerificationState.error:
|
||||
title = const Text('');
|
||||
body = Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
mainAxisSize: .min,
|
||||
children: <Widget>[
|
||||
const SizedBox(height: 16),
|
||||
Icon(Icons.cancel, color: theme.colorScheme.error, size: 64.0),
|
||||
|
|
@ -340,9 +325,7 @@ class KeyVerificationPageState extends State<KeyVerificationDialog> {
|
|||
);
|
||||
buttons.add(
|
||||
AdaptiveDialogAction(
|
||||
child: Text(
|
||||
L10n.of(context).close,
|
||||
),
|
||||
child: Text(L10n.of(context).close),
|
||||
onPressed: () =>
|
||||
Navigator.of(context, rootNavigator: false).pop(false),
|
||||
),
|
||||
|
|
@ -355,9 +338,7 @@ class KeyVerificationPageState extends State<KeyVerificationDialog> {
|
|||
content: SizedBox(
|
||||
height: 256,
|
||||
width: 256,
|
||||
child: ListView(
|
||||
children: [body],
|
||||
),
|
||||
child: ListView(children: [body]),
|
||||
),
|
||||
actions: buttons,
|
||||
);
|
||||
|
|
@ -399,7 +380,7 @@ class _Emoji extends StatelessWidget {
|
|||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
mainAxisSize: .min,
|
||||
children: <Widget>[
|
||||
Text(emoji.emoji, style: const TextStyle(fontSize: 50)),
|
||||
Padding(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue