WtModel<T> class
abstract
Base Model — a thin, typed HTTP client (the Flutter equivalent of a PHP
model). v1.1 makes it production-ready:
• injects Authorization: Bearer <token> from the session automatically,
• unwraps an optional response envelope (WtConfig.envelopeKey),
• surfaces the server error message (WtConfig.messageKey),
• exposes low-level getJson/postJson/putJson/deleteJson/
postMultipart so action-style endpoints and file uploads are easy.
The high-level fetch/fetchAll/create/update/delete helpers remain for plain REST resources and are now envelope- and token-aware.
Constructors
- WtModel()
Properties
- endpoint → String
-
Resource endpoint used by the REST helpers (e.g.
/users).no setter -
extraHeaders
→ Map<
String, String> -
Extra per-model request headers (override to add your own).
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
create(
Map< String, dynamic> data) → Future<T> -
delete(
String id) → Future< bool> -
deleteJson(
String path, {Object? body}) → Future -
fetch(
{Map< String, String> ? params}) → Future<T> -
fetchAll(
{Map< String, String> ? params}) → Future<List< T> > -
fromJson(
Map< String, dynamic> json) → T -
fromJsonList(
List jsonList) → List< T> -
getJson(
String path, {Map< String, String> ? query}) → Future -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
postJson(
String path, {Object? body}) → Future -
postMultipart(
String path, {Map< String, String> ? fields, List<WtUpload> ? files}) → Future - POST a multipart/form-data request (text fields + files).
-
putJson(
String path, {Object? body}) → Future -
toString(
) → String -
A string representation of this object.
inherited
-
update(
String id, Map< String, dynamic> data) → Future<T>
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited