如何通过BLOC创建一个简单的帖子请求?

发布于 2025-02-01 11:15:00 字数 443 浏览 3 评论 0原文

我需要通过Bloc创建一个简单的帖子请求。单击按钮时发送它。我该怎么做? 我需要一个简单的请求而无需解析。只是发送。 我的按钮:

OutlinedButton(
  onPressed: _sendReq,
  child: Text("Send request"),
),

Future<void> _sendReq() async {
}

我的API:

https://api.dev.certihire.com/api/v1/admin-sessions

I need to create a simple POST request via bloc. To send it when the button is clicked. How can i do this?
I need a simple request without parsing. Just send.
My button:

OutlinedButton(
  onPressed: _sendReq,
  child: Text("Send request"),
),

Future<void> _sendReq() async {
}

My API:

https://api.dev.certihire.com/api/v1/admin-sessions

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

﹎☆浅夏丿初晴 2025-02-08 11:15:00

请查看下面的文章,通过Retrofit+Dio致电API,以获取BLOC状态管理技术

https://medium.flutterdevs.com/flutter-bloct-bloc-for-state-management-using-dio-with-with-with-with-retrofit-ca87746363634d

Please check below article to call the API via retrofit+Dio for BLoC state management techniques

https://medium.flutterdevs.com/flutter-bloc-for-state-management-using-dio-with-retrofit-ca877463634d

青春如此纠结 2025-02-08 11:15:00

您可以简单地使用Bloc和Firebase创建发布请求。创建Firebase收集并将数据发布到它。为此,您需要调用FirebaseFirestore实例的add()方法。如

FirebaseFirestore.instance.Collection(“产品”);

这里的产品是收藏名称。

从UI导致事件调用add()方法。此方法应在您的存储库中。
这里更多
https://youtu.be/peqnfcispak

You can simple use bloc and firebase to create post request. Create firebase collection and post data to it. To do it you need call add() method of FirebaseFirestore instance. like below

FirebaseFirestore.instance.collection("products");

Here products is the collection name.

From UI cause events to call add() method. This method should be inside your repository.
Here more
https://youtu.be/PEQnFCIspAk

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文