Skip to main content

smf_dio 0.8.0 copy "smf_dio: ^0.8.0" to clipboard
smf_dio: ^0.8.0 copied to clipboard

The SMF module of the REST role with dio for the Flutter app that SMF generates. It sends the requests of the client of the role, with its guarantees, over Dio.

smf_dio #

The SMF module of REST requests with dio. It provides the REST role of SMF: the code of the app calls appRest.get('notes') without knowing the package behind it.

The role generates the client, and this module sends its requests over a Dio. What holds with this provider, as with any other:

  • A path joins the address of the API, REST_BASE_URL in .env. While that is empty, a relative path fails with notConfigured and names the key, and the app still builds and starts.
  • A call fails only with a RestFailure, whose reason comes from a closed set.
  • In an app with sign-in, the token of the user goes only to the origin of that address, also after a redirect.
  • A 401 gets a new token once and repeats once, and requests at the same time share one refresh.
  • GET and HEAD repeat after a broken connection and after 429, 502, 503 and 504, keeping to Retry-After. Other methods never repeat.
  • A timeout covers a whole attempt and a cancel ends a call at once. Each closes the connection, unless it is still being made: then the socket closes once the connect or the TLS handshake ends.
  • A debug build logs the origin and the path of each attempt, and no token and no query.
  • A release build for Android has the INTERNET permission.

createDio() in the app is where an interceptor goes, such as one of a tracing service. What it adds to a request goes to every address, so a credential goes through the token of the session or headers: of the call.

Several set-cookie values cannot be told apart in the headers of a response. An API with cookies reads them in an interceptor.

Use with the SMF CLI #

smf create my_app -m dio

You don't add this package to an app yourself: smf create of the SMF CLI puts what the module generates into the app.

SMF generates apps for Flutter 3.44 or newer and Dart 3.12 or newer. It is tested on macOS, Linux and Windows.

Documentation #

0
likes
160
points
--
downloads

Documentation

Documentation
API reference

Publisher

verified publishersaymyframe.com

Weekly Downloads

The SMF module of the REST role with dio for the Flutter app that SMF generates. It sends the requests of the client of the role, with its guarantees, over Dio.

Homepage
Repository (GitHub)
View/report issues
Contributing

Topics

#flutter #http #rest #dio #networking

License

Apache-2.0 (license)

Dependencies

mason, smf_contracts

More

Packages that depend on smf_dio