Giter Site home page Giter Site logo

Comments (3)

apstanisic avatar apstanisic commented on June 12, 2024

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.

Tapematch avatar Tapematch commented on June 12, 2024

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.

apstanisic avatar apstanisic commented on June 12, 2024

Can you check 0.9.1, it should fix it. Reopen if error still exists.

from directus-dart.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.