简体   繁体   English

你如何处理 Dart / Flutter Web 应用程序中的 HTTP 请求?

[英]How do you handle HTTP Requests in Dart / Flutter Web Applications?

I see there is an HTTP Dart Package found at https://pub.dev/packages/http我看到在https://pub.dev/packages/http 上找到了一个 HTTP Dart 包

The documentation & examples provided look acceptable.提供的文档和示例看起来可以接受。

Is this an easy way to learn HTTP requests in Dart / Flutter, or should I take a different approach?这是在 Dart/Flutter 中学习 HTTP 请求的简单方法,还是我应该采取不同的方法?

My end goal is OpenID Connect & OAuth for QuickBooks Online, so I cannot use Google and other popular OAuth providers.我的最终目标是 QuickBooks Online 的 OpenID Connect 和 OAuth,因此我无法使用 Google 和其他流行的 OAuth 提供商。

This is the official Http package for dart from the dart team.这是 dart 团队为 dart 提供的官方 Http 包。 I say, stay with this package for http requests in Dart/Flutter and if this package doesn't cover your needs later on, there are probably another package that will.我说,在 Dart/Flutter 中使用这个包来处理 http 请求,如果这个包以后不能满足你的需求,那么可能还有另一个包可以满足。

I recommend to use import prefix on this package so it doesn't conflict with any other package you might use我建议在这个包上使用 import 前缀,这样它就不会与你可能使用的任何其他包冲突

import 'package:http/http.dart' as http;

example:例子:

final response = await http.post(url, body: ...);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM