Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: analyzer issues in amiapp_flutter #140

Merged
merged 1 commit into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading