flutter_next_base 0.2.0 copy "flutter_next_base: ^0.2.0" to clipboard
flutter_next_base: ^0.2.0 copied to clipboard

A Frappe/ERPNext REST client for Flutter. Resource CRUD, submit and cancel, permission checks, link search, bulk writes, file upload and typed error handling.

Changelog #

0.2.0 #

Correctness fixes and a much wider slice of the Frappe API. getDoc, getValue, setValue, callMethod, getResourceList and the rest keep their signatures — existing code compiles unchanged.

Fixed #

  • Lists no longer truncate silently at 20 rows. Frappe's REST handler defaults limit_page_length to 20 when it is not sent, so any query without an explicit page length quietly returned at most 20 records. QueryOptions now always sends one (QueryOptions.defaultPageLength, 100). Pass limitPageLength: 0 for no limit, or use the new getAllPages().
  • Frappe error messages survive. The error path did jsonData['message'] as String?, which throws whenever Frappe puts a map or list there — and it usually does. The real message was replaced by "Failed to parse response: type '_Map<...>' is not a subtype of 'String?'". Errors are now read from _server_messages (the text frappe.throw() showed the user, HTML stripped), falling back through message, exception and exc_type. Non-JSON bodies such as nginx error pages are handled too.
  • ApiResult.map() no longer crashes on a successful null payload. It fell through to ApiResult.failure(error!) with a null error.
  • Every request now has a timeout. Previously a request on a flaky connection hung until the OS gave up. Configurable via timeout, default 30s; exceeding it yields FrappeException.timeoutStatus.

Added #

Submittable documents — ERPNext's core workflow, previously unreachable:

  • submit(docType, name) and submitDoc(doc)
  • cancel(docType, name)
  • isDocumentAmended(docType, name)

Permissions — what the desk itself checks, stable on Frappe v13 to v16:

  • hasPermission(docType, docName:, permType:)
  • getDocPermissions(docType, docName)

Queries:

  • FrappeFilter — typed filter conditions (FrappeFilter.equals, .like, .isIn, .between, .greaterThan, .isSet, ...) instead of hand-written JSON strings. QueryOptions.filterList takes them.
  • QueryOptions.orFilters, .groupBy, .parent (required for child tables such as Sales Invoice Item — Frappe raises PermissionError without it).
  • getAllPages() — walks pagination until the last page.
  • getResourceListAs<T>() — returns ResourceListResponse<T>, which until now was exported but unused.
  • getCount() via frappe.client.get_count.

Other endpoints:

  • searchLink() — Link-field autocomplete via frappe.desk.search.search_link.
  • validateLink(), getSingleValue(), getValues(), setValues(), renameDoc(), insertMany(), bulkUpdate(), getVersions().
  • uploadFile() — multipart upload, defaulting to private files.

Authentication:

  • sessionProvider — a single callback instead of implementing CookieManager. Wire it to flutter_next_auth in one line: sessionProvider: () async => await flutternext.cookieHeader().
  • apiKey / apiSecret for token authentication.
  • csrfToken, for sessions that originated in a browser.

Errors: FrappeException.excType, .isAuthError, .isTransportError, .isValidationError, .isPermissionError, .isNotFound.

Results: ApiResult.when() and .valueOr().

Changed #

  • getDoc() still calls the desk endpoint frappe.desk.form.load.getdoc, but its documentation now states what that means: the document arrives under a docs key, desk access is required, and a lot of docinfo is assembled. For the document alone, getResource() is cheaper and already includes child tables.
  • Base URLs are normalised, so a trailing slash no longer produces //api/....
  • logging output is only formatted when the level is actually enabled.
  • CookieManager remains supported. Its saveCookies is documented as never being called by the client — it never captured Set-Cookie.
  • Minimum SDK is now Dart 3.8 / Flutter 3.32.

Added tests #

26 tests covering page-length defaults, filter building, error extraction, error classification, timeouts, authentication headers, pagination and result mapping.

0.1.0 #

  • Initial release
  • Resource API operations (GET, POST, PUT, DELETE)
  • DocType operations (getDoc, getValue, setValue)
  • Custom method calls
  • Comprehensive error handling
  • Logging support
  • Filters, sorting, and pagination for resource queries
1
likes
160
points
82
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

A Frappe/ERPNext REST client for Flutter. Resource CRUD, submit and cancel, permission checks, link search, bulk writes, file upload and typed error handling.

Repository (GitHub)
View/report issues

Topics

#frappe #erpnext #rest-client #api #doctype

License

MIT (license)

Dependencies

flutter, http, logging

More

Packages that depend on flutter_next_base