如何使用颤振中的提供程序将接收到的 SignalR 消息发送到特定类
我的 main.dart 文件有以下提供者:
providers: [
ChangeNotifierProvider(create: (_) => NotificationService()),
],
child: MaterialApp()
//below is my notification service:
this.connection.on('ReceiveMessage', (message) {
_taskCallBackData = "message";
notifyListeners();
});
//on _taskCallBackData change I want to fetch it from another class test class
Widget build(BuildContext context) {
final data=context.watch<NotificationService>().taskCallBackData;
return Scaffold(
appBar: AppBar(
title: Text('Zenople'),
centerTitle: true,
backgroundColor: Colors.orange,
),
body: Column(
children: [
//some widgets
],
));
}