パッケージ、リポジトリ、アプリカテゴリを検索

パッケージ詳細v2.0.0

dart_strapi

Strapi V4用のDartクライアント

AndroidiOSWebmacOSWindowsLinux
30日間ダウンロード
63
いいね数
25
Pub ポイント
130

パッケージをインストール

flutter pub add dart_strapi

パッケージ概要

公開情報に基づく選定ガイドです。参考としてご利用ください。

Strapi V4 用のDartクライアントで、Dart/FlutterアプリケーションとStrapiバックエンドサービスとのシームレスな統合を可能にします。RESTfulエンドポイントとのやり取りにクリーンで型安全なAPIを提供し、認証、データ取得、CRUD操作をサポートしています。StrapiをヘッドレスCMSまたはバックエンドとして使用するアプリ開発向けに設計されており、複数のプラットフォーム間でのAPI通信を簡素化します。

用途

  • FlutterアプリをStrapi V4バックエンドと統合する
  • ヘッドレスCMSからコンテンツを取得および管理する
  • Strapi を使用したユーザー認証の実装
  • リアルタイムデータを使用した動的Webおよびモバイルアプリの構築
  • FlutterクライアントとStrapiサーバー間のデータ同期

主な機能

  • 型安全な API 呼び出し
  • Strapi V4 認証のサポート
  • クロスプラットフォーム互換性
  • Flutter pub による簡単なセットアップ
  • 組み込みのエラー処理と応答パース

適している対象

  • Strapi V4 を使用する Flutter 開発者
  • ヘッドレスCMSで駆動されるアプリを構築するチーム
  • バックエンド統合を必要とするモバイルおよびウェブアプリ
  • 軽量な Strapi クライアントを探している開発者
  • 複数のプラットフォーム間で一貫したAPI相互作用を必要とするプロジェクト

注意事項

  • Strapi V4 バックエンドが必要です
  • REST API に限定(GraphQL 対応なし)
  • StrapiのAPI構造に依存
  • 高度な機能にはカスタム拡張が必要になる場合があります
  • 認証フローには適切な構成が必要です

元の README

関連するソースリポジトリの README 原文のスナップショットです。最新の内容はリポジトリをご覧ください。

dart_strapi

dart client for Strapi V4

For Strapi V3 client check v1.2.0

Example

import 'package:dart_strapi/dart_strapi.dart';

final serverUrl = 'http://localhost:1337';
final authToken = '<token>';
final collection = '<collectionType>';
final single = '<singleType>';

void main() async {
  final client = Strapi(
    serverUrl,
    token: authToken,
  );

  final singleResponse = await client.single.get(single);
  print("Single Response: $singleResponse");
  print("Data: ${singleResponse.item1}");
  print("Meta: ${singleResponse.item2}");
  print("\n----------------------------------------------------\n");

  final singleNotFoundResponse = await client.single.get("lalala");
  print("Single Not Found Response: $singleNotFoundResponse"); // [null, null]
  print("Data: ${singleNotFoundResponse.item1}"); // null
  print("Meta: ${singleNotFoundResponse.item2}"); // null
  print("\n----------------------------------------------------\n");

  final collectionResponse = await client.collection.get(collection);
  print("Collection Response: $collectionResponse");
  print("Data: ${collectionResponse.item1}");
  print("Meta: ${collectionResponse.item2}");
  print("\n----------------------------------------------------\n");

  final collectionNotFoundResponse = await client.collection.get('rarara');
  print("Collection Not Found Response: $collectionNotFoundResponse"); // [null, null]
  print("Data: ${collectionNotFoundResponse.item1}"); // null
  print("Meta: ${collectionNotFoundResponse.item2}"); // null
  print("\n----------------------------------------------------\n");

  final collectionSingleResponse = await client.collection.getOne(collection, 1);
  print("Collection Single Response: $collectionSingleResponse");
  print("Data: ${collectionSingleResponse.item1}");
  print("Meta: ${collectionSingleResponse.item2}");
  print("\n----------------------------------------------------\n");

  final collectionSingleNotFoundResponse = await client.collection.getOne("xaxaxa", 1);
  print("Collection Single Not Found Response: $collectionSingleNotFoundResponse"); // [null, null]
  print("Data: ${collectionSingleNotFoundResponse.item1}"); // null
  print("Meta: ${collectionSingleNotFoundResponse.item2}"); // null
  print("\n----------------------------------------------------\n");

  final resourceSingle = await client.resource.get(single);
  print("Resource Single Response: $resourceSingle"); // Response<Data.single>
  print("\n----------------------------------------------------\n");

  final resourceCollection = await client.resource.get(collection);
  print("Resource Collection Response: $resourceCollection"); // Response<Data.collection>
  print("\n----------------------------------------------------\n");

  final resourceCollectionSingle = await client.resource.get("$collection/1");
  print("Resource Collection Single Response: $resourceCollectionSingle"); // Response<Data.single>
  print("\n----------------------------------------------------\n");

  final resourceNoExists = await client.resource.get("lalala");
  print("Resource Not Found Response: $resourceNoExists"); // Response.error
  print("\n----------------------------------------------------\n");
}

Output

Single Response: [{id: 1, attributes: {...}}, Meta(pagination: null)]
Data: {id: 1, attributes: {...}}
Meta: Meta(pagination: null)

----------------------------------------------------

Single Not Found Response: [null, null]
Data: null
Meta: null

----------------------------------------------------

Collection Response: [[{id: 1, attributes: {...}}, {id: 2, attributes: {...}}], Meta(pagination: Pagination(page: 1, pageSize: 25, pageCount: 1, total: 2))]
Data: [{id: 1, attributes: {...}}, {id: 2, attributes: {...}}]
Meta: Meta(pagination: Pagination(page: 1, pageSize: 25, pageCount: 1, total: 2))

----------------------------------------------------

Collection Not Found Response: [null, null]
Data: null
Meta: null

----------------------------------------------------

Collection Single Response: [{id: 1, attributes: {...}}, Meta(pagination: null)]
Data: {id: 1, attributes: {...}}
Meta: Meta(pagination: null)

----------------------------------------------------

Collection Single Not Found Response: [null, null]
Data: null
Meta: null

----------------------------------------------------

Resource Single Response: Response(data: Data.single(data: {id: 1, attributes: {...}}), meta: Meta(pagination: null))

----------------------------------------------------

Resource Collection Response: Response(data: Data.collection(data: [{id: 1, attributes: {...}}, {id: 2, attributes: {...}}]), meta: Meta(pagination: Pagination(page: 1, pageSize: 25, pageCount: 1, total: 2)))

----------------------------------------------------

Resource Collection Single Response: Response(data: Data.single(data: {id: 1, attributes: {...}}), meta: Meta(pagination: null))

----------------------------------------------------

Resource Not Found Response: Response.error(message: ...)

----------------------------------------------------

This package is in active development process, there are implemented methods to query, if you need create / update / delete or call other api you can use client.httpClient to call Dio client directly.

Check Examples for more

カテゴリー

依存関係

依存関係一覧 4 件

ソースリポジトリ

このパッケージを使用しているプロジェクト

データはまだありません。