Skip to content

Commit

Permalink
chore: analyzer issues in amiapp_flutter (#140)
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcinusX authored Sep 4, 2024
1 parent 1635acf commit aa5af46
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
8 changes: 6 additions & 2 deletions apps/amiapp_flutter/lib/src/screens/dashboard.dart
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,9 @@ class _ActionList extends StatelessWidget {

void _showPushPermissionStatus(BuildContext context) {
Permission.notification.status.then((status) {
if (status.isGranted) {
if (!context.mounted) {
return;
} else if (status.isGranted) {
context.showMessageDialog(_pushPermissionAlertTitle,
'Push notifications are enabled on this device');
} else if (status.isDenied) {
Expand All @@ -196,7 +198,9 @@ class _ActionList extends StatelessWidget {

void _requestPushPermission(BuildContext context) {
Permission.notification.request().then((status) {
if (status.isGranted) {
if (!context.mounted) {
return;
} else if (status.isGranted) {
context.showSnackBar('Push notifications are enabled on this device');
} else {
_onPushPermissionPermanentlyDenied(context);
Expand Down
20 changes: 13 additions & 7 deletions apps/amiapp_flutter/lib/src/screens/settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class _SettingsScreenState extends State<SettingsScreen> {
super.initState();
}

void _saveSettings() {
void _saveSettings(BuildContext context) {
if (!_formKey.currentState!.validate()) {
return;
}
Expand All @@ -88,7 +88,9 @@ class _SettingsScreenState extends State<SettingsScreen> {
debugModeEnabled: _featureDebugMode,
);
widget._customerIOSDK.saveConfigToPreferences(newConfig).then((success) {
if (success) {
if (!context.mounted) {
return;
} else if (success) {
context.showSnackBar('Settings saved successfully');
Navigator.of(context).pop();
// Restart app here
Expand Down Expand Up @@ -118,7 +120,7 @@ class _SettingsScreenState extends State<SettingsScreen> {
_featureTrackDeviceAttributes =
defaultConfig.deviceAttributesTrackingEnabled;
_featureDebugMode = defaultConfig.debugModeEnabled;
_saveSettings();
_saveSettings(context);
});
}

Expand All @@ -127,7 +129,7 @@ class _SettingsScreenState extends State<SettingsScreen> {
final Sizes sizes = Theme.of(context).extension<Sizes>()!;

return PopScope(
onPopInvoked: (bool didPop) {
onPopInvokedWithResult: (bool didPop, result) {
if (widget.auth.signedIn == false) {
context.go(Screen.login.location);
}
Expand Down Expand Up @@ -166,9 +168,13 @@ class _SettingsScreenState extends State<SettingsScreen> {
onPressed: () {
final clipboardData = ClipboardData(
text: _deviceTokenValueController.text);
Clipboard.setData(clipboardData).then((_) =>
Clipboard.setData(clipboardData).then((_) {
if (context.mounted) {
context.showSnackBar(
'Device Token copied to clipboard'));
'Device Token copied to clipboard',
);
}
});
},
),
),
Expand Down Expand Up @@ -284,7 +290,7 @@ class _SettingsScreenState extends State<SettingsScreen> {
style: FilledButton.styleFrom(
minimumSize: sizes.buttonDefault(),
),
onPressed: () => _saveSettings(),
onPressed: () => _saveSettings(context),
child: Text(
'Save'.toUpperCase(),
semanticsLabel: 'Save Settings Button',
Expand Down

0 comments on commit aa5af46

Please sign in to comment.