@@ -233,7 +233,9 @@ class HomeState extends State<Home> with SingleTickerProviderStateMixin {
233233 final recipientController = TextEditingController ();
234234 final titleController = TextEditingController ();
235235 final contentController = TextEditingController ();
236- int selectedPriority = 0 ;
236+ int selectedPriority = 1 ;
237+ String ? recipientError;
238+ String ? titleError;
237239
238240 await showDialog (
239241 context: context,
@@ -248,16 +250,17 @@ class HomeState extends State<Home> with SingleTickerProviderStateMixin {
248250 children: [
249251 TextField (
250252 controller: recipientController,
251- decoration: const InputDecoration (
252- labelText: 'Recipient WebID' ,
253- hintText : demoWebID ,
253+ decoration: InputDecoration (
254+ labelText: 'Recipient WebID * ' ,
255+ errorText : recipientError ,
254256 ),
255257 ),
256258 const SizedBox (height: 12 ),
257259 TextField (
258260 controller: titleController,
259- decoration: const InputDecoration (
260- labelText: 'Title' ,
261+ decoration: InputDecoration (
262+ labelText: 'Title *' ,
263+ errorText: titleError,
261264 ),
262265 ),
263266 const SizedBox (height: 12 ),
@@ -281,7 +284,7 @@ class HomeState extends State<Home> with SingleTickerProviderStateMixin {
281284 ],
282285 onChanged: (value) {
283286 setDialogState (() {
284- selectedPriority = value ?? 0 ;
287+ selectedPriority = value ?? 1 ;
285288 });
286289 },
287290 ),
@@ -298,15 +301,18 @@ class HomeState extends State<Home> with SingleTickerProviderStateMixin {
298301 final recipient = recipientController.text.trim ();
299302 final notifTitle = titleController.text.trim ();
300303
301- if (recipient.isEmpty || notifTitle.isEmpty) {
302- ScaffoldMessenger .of (stfContext).showSnackBar (
303- const SnackBar (
304- content:
305- Text ('Recipient WebID and title are required.' ),
306- ),
307- );
308- return ;
309- }
304+ final hasErrors =
305+ recipient.isEmpty || notifTitle.isEmpty;
306+
307+ setDialogState (() {
308+ recipientError = recipient.isEmpty
309+ ? 'Recipient WebID is required'
310+ : null ;
311+ titleError =
312+ notifTitle.isEmpty ? 'Title is required' : null ;
313+ });
314+
315+ if (hasErrors) return ;
310316
311317 Navigator .pop (dialogContext);
312318
0 commit comments