在哪里放置警报箱?
我有一个使用烧瓶作为后端的颤音应用程序,当后端有一些数据更改时,我想向用户发送一个警报对话框。尽管我知道如何使用警报框,但我很困惑应该放置该代码的位置,因为我使用3个屏幕并通过pageview导航。
我的用例是,我有一个配备了PIR传感器到Raspberry Pi上,并且当检测到运动时,Motion_Status值将变为true,并通过Blask应用程序发送到Flutter App。
我对需要放置“警报”对话框小部件的位置感到困惑,以便无论我在哪个屏幕上都会获得警报框。
I have a flutter app that uses flask as backend and when ever some data changes in the backend, I want to send an Alert Dialog to user. Although I know how to use Alert Box, I'm confused where the code for it should be placed as I'm using 3 screens and navigating then via PageView.
My use case is that I have a PIR sensor equipped onto a raspberry pi and when ever motion is detected, motion_status value turns to true and sends to flutter app via flask app.
I'm confused about where i need to place the Alert Dialog widget so that when ever movement happens, no matter what screen i'm in i should get alert box .
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
因此,当后端发生更新时,您有几种不同的方法来获取有关更改的通知的应用程序,
1-首先,您会在flutter应用程序中创建一个tream,请呼叫服务器以检查是否发生了任何更改,该流式流程重新占有每一个几分钟或几秒钟,但这不是一个好的解决方案,因为将有很多电话到服务器的电话,并且信息不会瞬间。
2-使用Web插座系统
最佳解决方案
3-使用FCM Firebase Cloud Messaging System,每当后端发生更改时,您都会编写一个代码,该代码调用与Flutter App关联的Firebase帐户,您的Firebase帐户将将带有数据加载的通知发送到您的应用程序,当您的应用接收到实时通知时,您可以向用户显示警报对话框
So when an update happen in the backend, you have couple different ways to get the app notified about the change just happened,
1- first you create a stream in the flutter app calling the server to check if any change happened, that stream reoccurs every few minutes or seconds, but that's not a good solution because there will be a lot of calls to the server and the info won't be instant.
2- use a web socket system
Best solution
3- use FCM Firebase cloud messaging system, whenever a change happened in the backend you write a code that calls Firebase account associated with your flutter app and your Firebase account will send a notification with data load to your app, when your app receives that real time notification you can then show to the user the alert dialog