dhmgroup / dart-wp

A WordPress API client for dart with support for WooCommerce and custom namespaces.
https://pub.dev/packages/wordpress_api
BSD 3-Clause "New" or "Revised" License
79 stars 28 forks source link

Flutter 2.0 #20

Closed Sabatin closed 3 years ago

Sabatin commented 3 years ago

I really love this package. Will this package ever be migrated to flutter null safety?

theeomm commented 3 years ago

Yes, the package will soon be migrated provided all dependencies have been migrated.

theeomm commented 3 years ago

The project has now been migrated to null safety from v0.3.0+

Sabatin commented 3 years ago

Wow super fast! Ty so much! But i don't see the featured media... There is a way to provide the image of the post?

theeomm commented 3 years ago

As of now, you can only retrieve the image ID, then call the api.getMedia(id: ID) endpoint. The Media response contains the sourceUrl. Embedded data will be included in the stable v1

Sabatin commented 3 years ago

Ty so much, this is helpful. But i think that there is an error in

factory Media.fromMap(Map<String, dynamic> map) {
    return Media(
      date: map['date'],
      dateGmt: map['date_gmt'],
      guid: map['guid']['rendered'],
      id: map['id'],
      link: map['link'],
      modified: map['modified'],
      modifiedGmt: map['modified_gmt'],
      slug: map['slug'],
      status: map['status'],
      type: map['type'],
      permalinkTemplate: map['permalink_template'],
      generatedSlug: map['generated_slug'],
      title: Utils.renderHtml(map['title']['rendered']),
      author: map['author'],
      commentStatus: map['comment_status'],
      pingStatus: map['ping_status'],
      meta: map['meta'],
      template: map['template'],
      altText: map['altText'],
      caption: map['caption'],
      description: map['description'],
      mediaType: map['media_type'],
      mimeType: map['mime_type'],
      mediaDetails: Map<String, dynamic>.from(map['media_details']),
      post: map['post'],
      sourceUrl: map['source_url'],
    );
  }

[ERROR:flutter/lib/ui/ui_dart_state.cc(186)] Unhandled Exception: type '_InternalLinkedHashMap<String, dynamic>' is not a subtype of type 'String?'

The terminal error point me on the line caption: map['caption'],

theeomm commented 3 years ago

Thank you for reporting this. I Will have this fixed in the next minor update.