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
|
|
@ -45,11 +45,8 @@ class SettingsNotificationsController extends State<SettingsNotifications> {
|
|||
final success = await showFutureLoadingDialog(
|
||||
context: context,
|
||||
future: () => Matrix.of(context).client.deletePusher(
|
||||
PusherId(
|
||||
appId: pusher.appId,
|
||||
pushkey: pusher.pushkey,
|
||||
),
|
||||
),
|
||||
PusherId(appId: pusher.appId, pushkey: pusher.pushkey),
|
||||
),
|
||||
);
|
||||
|
||||
if (success.error != null) return;
|
||||
|
|
@ -66,10 +63,7 @@ class SettingsNotificationsController extends State<SettingsNotifications> {
|
|||
isLoading = true;
|
||||
});
|
||||
try {
|
||||
final updateFromSync = Matrix.of(context)
|
||||
.client
|
||||
.onSync
|
||||
.stream
|
||||
final updateFromSync = Matrix.of(context).client.onSync.stream
|
||||
.where(
|
||||
(syncUpdate) =>
|
||||
syncUpdate.accountData?.any(
|
||||
|
|
@ -78,17 +72,16 @@ class SettingsNotificationsController extends State<SettingsNotifications> {
|
|||
false,
|
||||
)
|
||||
.first;
|
||||
await Matrix.of(context).client.setPushRuleEnabled(
|
||||
kind,
|
||||
pushRule.ruleId,
|
||||
!pushRule.enabled,
|
||||
);
|
||||
await Matrix.of(
|
||||
context,
|
||||
).client.setPushRuleEnabled(kind, pushRule.ruleId, !pushRule.enabled);
|
||||
await updateFromSync;
|
||||
} catch (e, s) {
|
||||
Logs().w('Unable to toggle push rule', e, s);
|
||||
if (!mounted) return;
|
||||
ScaffoldMessenger.of(context)
|
||||
.showSnackBar(SnackBar(content: Text(e.toLocalizedString(context))));
|
||||
ScaffoldMessenger.of(
|
||||
context,
|
||||
).showSnackBar(SnackBar(content: Text(e.toLocalizedString(context))));
|
||||
} finally {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
|
|
@ -116,9 +109,7 @@ class SettingsNotificationsController extends State<SettingsNotifications> {
|
|||
scrollDirection: Axis.horizontal,
|
||||
child: SelectableText(
|
||||
prettyJson(rule.toJson()),
|
||||
style: TextStyle(
|
||||
color: theme.colorScheme.onSurface,
|
||||
),
|
||||
style: TextStyle(color: theme.colorScheme.onSurface),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
|
@ -158,10 +149,7 @@ class SettingsNotificationsController extends State<SettingsNotifications> {
|
|||
isLoading = true;
|
||||
});
|
||||
try {
|
||||
final updateFromSync = Matrix.of(context)
|
||||
.client
|
||||
.onSync
|
||||
.stream
|
||||
final updateFromSync = Matrix.of(context).client.onSync.stream
|
||||
.where(
|
||||
(syncUpdate) =>
|
||||
syncUpdate.accountData?.any(
|
||||
|
|
@ -170,17 +158,14 @@ class SettingsNotificationsController extends State<SettingsNotifications> {
|
|||
false,
|
||||
)
|
||||
.first;
|
||||
await Matrix.of(context).client.deletePushRule(
|
||||
kind,
|
||||
rule.ruleId,
|
||||
);
|
||||
await Matrix.of(context).client.deletePushRule(kind, rule.ruleId);
|
||||
await updateFromSync;
|
||||
} catch (e, s) {
|
||||
Logs().w('Unable to delete push rule', e, s);
|
||||
if (!mounted) return;
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text(e.toLocalizedString(context))),
|
||||
);
|
||||
ScaffoldMessenger.of(
|
||||
context,
|
||||
).showSnackBar(SnackBar(content: Text(e.toLocalizedString(context))));
|
||||
} finally {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
|
|
|
|||
|
|
@ -37,12 +37,12 @@ class SettingsNotificationsView extends StatelessWidget {
|
|||
body: MaxWidthBody(
|
||||
child: StreamBuilder(
|
||||
stream: Matrix.of(context).client.onSync.stream.where(
|
||||
(syncUpdate) =>
|
||||
syncUpdate.accountData?.any(
|
||||
(accountData) => accountData.type == 'm.push_rules',
|
||||
) ??
|
||||
false,
|
||||
),
|
||||
(syncUpdate) =>
|
||||
syncUpdate.accountData?.any(
|
||||
(accountData) => accountData.type == 'm.push_rules',
|
||||
) ??
|
||||
false,
|
||||
),
|
||||
builder: (BuildContext context, _) {
|
||||
final theme = Theme.of(context);
|
||||
return SelectionArea(
|
||||
|
|
@ -96,14 +96,14 @@ class SettingsNotificationsView extends StatelessWidget {
|
|||
onChanged: controller.isLoading
|
||||
? null
|
||||
: rule.ruleId != '.m.rule.master' &&
|
||||
Matrix.of(context)
|
||||
.client
|
||||
.allPushNotificationsMuted
|
||||
? null
|
||||
: (_) => controller.togglePushRule(
|
||||
category.kind,
|
||||
rule,
|
||||
),
|
||||
Matrix.of(
|
||||
context,
|
||||
).client.allPushNotificationsMuted
|
||||
? null
|
||||
: (_) => controller.togglePushRule(
|
||||
category.kind,
|
||||
rule,
|
||||
),
|
||||
),
|
||||
),
|
||||
Divider(color: theme.dividerColor),
|
||||
|
|
@ -118,8 +118,9 @@ class SettingsNotificationsView extends StatelessWidget {
|
|||
),
|
||||
),
|
||||
FutureBuilder<List<Pusher>?>(
|
||||
future: controller.pusherFuture ??=
|
||||
Matrix.of(context).client.getPushers(),
|
||||
future: controller.pusherFuture ??= Matrix.of(
|
||||
context,
|
||||
).client.getPushers(),
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.hasError) {
|
||||
Center(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue