SignalR 使用提供程序颤振接收到类的消息

时间:2021-06-18 08:38:57

标签: flutter signalr provider

如何使用颤振中的提供程序将接收到的 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
          ],
        ));
  }
 

0 个答案:

没有答案