Skip to content

Commit 0e84165

Browse files
Add snackbar in accelerometer_screen.dart
1 parent 9c706bd commit 0e84165

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

lib/view/accelerometer_screen.dart

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ class _AccelerometerScreenState extends State<AccelerometerScreen> {
184184
return AlertDialog(
185185
title: Text(appLocalizations.saveRecording),
186186
content: TextField(
187+
maxLength: 200,
187188
controller: filenameController,
188189
decoration: InputDecoration(
189190
hintText: appLocalizations.enterFileName,
@@ -193,11 +194,22 @@ class _AccelerometerScreenState extends State<AccelerometerScreen> {
193194
actions: [
194195
TextButton(
195196
onPressed: () => Navigator.pop(context),
196-
child: Text(appLocalizations.cancel.toUpperCase()),
197+
child: Text(appLocalizations.cancel),
197198
),
198199
ElevatedButton(
199200
onPressed: () {
200-
Navigator.pop(context, filenameController.text);
201+
final text = filenameController.text.trim();
202+
if (text.length > 200) {
203+
ScaffoldMessenger.of(context).showSnackBar(
204+
const SnackBar(
205+
content: Text(
206+
'File name must be less than 200 characters.',
207+
),
208+
),
209+
);
210+
return;
211+
}
212+
Navigator.pop(context, text);
201213
},
202214
child: Text(appLocalizations.save),
203215
),

0 commit comments

Comments
 (0)