Messages
Send broadcasts to parents and direct messages.
Get Contacts
GET /teacher/message/get-contacts
Returns list of parents/guardians the teacher can message.
Get Broadcast Messages
GET /teacher/message/get-broadcast-message
Send Broadcast
POST /teacher/message/send-broadcast
{
"data": {
"title": "Exam Reminder",
"body": "Please ensure your child prepares for the upcoming exams.",
"targetClassId": "uuid"
}
}
Get Chat Messages
GET /teacher/message/get-messages?contactId={uuid}
Send Direct Message
POST /teacher/message/create-message
{
"data": {
"recipientId": "parent-uuid",
"body": "Please ensure John attends school tomorrow."
}
}
UI — Broadcast Composer
class BroadcastScreen extends StatefulWidget {
@override
State<BroadcastScreen> createState() => _BroadcastScreenState();
}
class _BroadcastScreenState extends State<BroadcastScreen> {
String _title = '';
String _body = '';
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('Send Broadcast')),
body: Column(
children: [
TextFormField(
decoration: const InputDecoration(labelText: 'Title'),
onChanged: (v) => setState(() => _title = v),
),
TextFormField(
decoration: const InputDecoration(labelText: 'Message'),
maxLines: 4,
onChanged: (v) => setState(() => _body = v),
),
Padding(
padding: const EdgeInsets.all(16),
child: ElevatedButton(
onPressed: _title.isNotEmpty && _body.isNotEmpty
? () => context.read<MessageViewModel>().sendBroadcast(_title, _body)
: null,
child: const Text('Send Broadcast'),
),
),
],
),
);
}
}