Skip to content

Commit

Permalink
fix flutter analyze issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Romasav committed Dec 2, 2024
1 parent 68d978a commit c993afb
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 64 deletions.
1 change: 1 addition & 0 deletions lib/domain/entities/settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class Settings {
/// Band pass low cut
final double bandPassLowCutOff;

/// Copy with method
Settings copyWith({
double? bandPassHighCutOff,
double? bandPassLowCutOff,
Expand Down
132 changes: 68 additions & 64 deletions lib/presentation/widgets/settings_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,73 +14,77 @@ class SettingsDialog extends ConsumerWidget {
Widget build(BuildContext context, WidgetRef ref) {
final settings = ref.watch(settingsNotifierProvider);
final settingsNotifier = ref.read(settingsNotifierProvider.notifier);
return settings.when(data: (data) {
_bandPassHighCutOffController.text = data.bandPassHighCutOff.toString();
_bandPassLowCutOffController.text = data.bandPassLowCutOff.toString();
return AlertDialog(
title: const Text('Settings'),
content: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
TextField(
controller: _bandPassHighCutOffController,
decoration: const InputDecoration(
labelText: 'Band Pass High Cut Off',
return settings.when(
data: (data) {
_bandPassHighCutOffController.text = data.bandPassHighCutOff.toString();
_bandPassLowCutOffController.text = data.bandPassLowCutOff.toString();
return AlertDialog(
title: const Text('Settings'),
content: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
TextField(
controller: _bandPassHighCutOffController,
decoration: const InputDecoration(
labelText: 'Band Pass High Cut Off',
),
keyboardType: TextInputType.number,
),
keyboardType: TextInputType.number,
),
TextField(
controller: _bandPassLowCutOffController,
decoration: const InputDecoration(
labelText: 'Band Pass Low Cut Off',
TextField(
controller: _bandPassLowCutOffController,
decoration: const InputDecoration(
labelText: 'Band Pass Low Cut Off',
),
keyboardType: TextInputType.number,
),
keyboardType: TextInputType.number,
],
),
actions: <Widget>[
TextButton(
onPressed: () {
Navigator.of(context).pop();
},
child: const Text('Cancel'),
),
TextButton(
onPressed: () async {
final newSettings = data.copyWith(
bandPassHighCutOff:
double.tryParse(_bandPassHighCutOffController.text),
bandPassLowCutOff:
double.tryParse(_bandPassLowCutOffController.text),
);
final result = await settingsNotifier.saveSettings(newSettings);
result.fold(
(failure) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(failure.message),
),
);
},
(_) {
Navigator.of(context).pop();
},
);
},
child: const Text('Confirm'),
),
],
),
actions: <Widget>[
TextButton(
onPressed: () {
Navigator.of(context).pop();
},
child: const Text('Cancel'),
),
TextButton(
onPressed: () async {
final newSettings = data.copyWith(
bandPassHighCutOff:
double.tryParse(_bandPassHighCutOffController.text),
bandPassLowCutOff:
double.tryParse(_bandPassLowCutOffController.text),
);
final result = await settingsNotifier.saveSettings(newSettings);
result.fold(
(failure) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(failure.message),
),
);
},
(_) {
Navigator.of(context).pop();
},
);
},
child: const Text('Confirm'),
),
],
);
}, error: (e, s) {
return AlertDialog(
title: const Text('Error'),
content: Text(e.toString()),
);
}, loading: () {
return const AlertDialog(
title: Text('Loading'),
content: Center(child: CircularProgressIndicator()),
);
});
);
},
error: (e, s) {
return AlertDialog(
title: const Text('Error'),
content: Text(e.toString()),
);
},
loading: () {
return const AlertDialog(
title: Text('Loading'),
content: Center(child: CircularProgressIndicator()),
);
},
);
}
}

0 comments on commit c993afb

Please sign in to comment.