flutter_next_base 0.2.0
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_lengthto 20 when it is not sent, so any query without an explicit page length quietly returned at most 20 records.QueryOptionsnow always sends one (QueryOptions.defaultPageLength, 100). PasslimitPageLength: 0for no limit, or use the newgetAllPages(). - 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 textfrappe.throw()showed the user, HTML stripped), falling back throughmessage,exceptionandexc_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 toApiResult.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 yieldsFrappeException.timeoutStatus.
Added #
Submittable documents — ERPNext's core workflow, previously unreachable:
submit(docType, name)andsubmitDoc(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.filterListtakes them.QueryOptions.orFilters,.groupBy,.parent(required for child tables such asSales Invoice Item— Frappe raisesPermissionErrorwithout it).getAllPages()— walks pagination until the last page.getResourceListAs<T>()— returnsResourceListResponse<T>, which until now was exported but unused.getCount()viafrappe.client.get_count.
Other endpoints:
searchLink()— Link-field autocomplete viafrappe.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 implementingCookieManager. Wire it toflutter_next_authin one line:sessionProvider: () async => await flutternext.cookieHeader().apiKey/apiSecretfor 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 endpointfrappe.desk.form.load.getdoc, but its documentation now states what that means: the document arrives under adocskey, 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/.... loggingoutput is only formatted when the level is actually enabled.CookieManagerremains supported. ItssaveCookiesis documented as never being called by the client — it never capturedSet-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