Comments (3)
Is the error occurring when you update/create your collection or when you update/create role?
Are you providing converter?
I this the problem is here:
/// directus_response.dart
/// Constructor that converts [Dio] [Response] to [DirectusResponse].
DirectusResponse(Response dioResponse, {ItemsConverter? converter}) {
converter ??= MapItemsConverter();
var data = dioResponse.data['data'];
if (data is List) {
throw DirectusError(message: 'List should use DirectusListResponse.');
} else if (data is Map<String, Object?>) {
this.data = converter.fromJson(data);
} else {
this.data = data;
}
}
If data is not Map
or List
it simply returns received, but that data does not fit return type, so it throws an error.
Maybe we should set this.data = {"response": data }
in else
, so it does not return an error, but that might confuse users who expect that returned Map
is created item. We can
But I don't know if this should be changed in Dart SDK or in Directus, cause their API reference says that it returns created object. Maybe API should return empty object if no field is allowed to be read?
Can you try this branch? I don't have time today to test it, this is maybe dirty fix. https://github.com/apstanisic/directus-dart/tree/fix-no-data
It simply allows returning nullable values for create/update endpoints.
You can add package directly from GitHub https://stackoverflow.com/questions/54022704/how-to-add-a-package-from-github-in-flutter
from directus-dart.
With your branch unfortunately the build fails because of a nullable error.
: Error: A value of type 'Future<DirectusResponse<DirectusSettings?>>' can't be returned from a function with return type 'Future<DirectusResponse<DirectusSettings>>' because 'DirectusSettings?' is nullable and 'DirectusSettings' isn't.
../…/settings/settings_handler.dart:24
- 'Future' is from 'dart:async'.
- 'DirectusResponse' is from 'package:directus/src/data_classes/directus_response.dart' ('../../Tools/flutter/.pub-cache/git/directus-dart-bb639c48a0b71008e0299b63c834a874b9ee5aab/lib/src/data_classes/directus_response.dart').
package:directus/…/data_classes/directus_response.dart:1
- 'DirectusSettings' is from 'package:directus/src/modules/settings/directus_settings.dart' ('../../Tools/flutter/.pub-cache/git/directus-dart-bb639c48a0b71008e0299b63c834a874b9ee5aab/lib/src/modules/settings/directus_settings.dart').
package:directus/…/settings/directus_settings.dart:1
items.updateOne(data: data, id: '1');
Sadly I currently have no time to look into it myself.
Directus-wise I think it makes sense to return nothing if you dont't even have the permissions to access the item.
Like with readMany you dont get an array of empty objects but an empty array.
from directus-dart.
Can you check 0.9.1, it should fix it. Reopen if error still exists.
from directus-dart.
Related Issues (20)
- Solution: createMany() throws an error "Problem with Directus". HOT 2
- `sdk.fields` doesn't work with new api HOT 2
- How to get custom user fields? HOT 2
- Expose transport like JS SDK HOT 2
- fix items -> updateMany HOT 2
- refresh token interceptor bug fix HOT 2
- Unhandled Exception: type 'String' is not a subtype of type 'int' of 'index' HOT 4
- Auth Refresh fails and soft locks users out of the system HOT 4
- Deep Filter for translations HOT 5
- Making AuthResponse public so as to use this: "directus.auth.storage.storeLoginData(data)" HOT 1
- How do you Sign up a new user from the SDK HOT 1
- Broken link in code documentation HOT 4
- Upgrade the packages to Dart 3.0 HOT 2
- Why there is a Flutter Dependency in Directus Dart Package for shared_preferences? HOT 4
- Create a Flutter Project in example of `directus` package
- SSO support
- Example of using typedItems with subentities
- Real time subscription
- Support for SSO and OAuth login
- Please export the ItemsHandler
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from directus-dart.