패키지, 저장소 및 앱 카테고리 검색

패키지 상세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 백엔드 서비스 간의 원활한 통합을 가능하게 합니다. 인증, 데이터 조회 및 CRUD 작업을 지원하는 깔끔하고 타입 안전한 API를 제공하여 Strapi의 RESTful 엔드포인트와 상호 작용할 수 있습니다. Strapi를 헤드리스 CMS 또는 백엔드로 사용하는 앱 개발자를 위한 것으로, 다양한 플랫폼 간 API 통신을 단순화합니다.

사용 사례

  • Flutter 앱을 Strapi V4 백엔드와 통합하기
  • 헤드리스 CMS에서 콘텐츠를 가져오고 관리하기
  • Strapi를 사용한 사용자 인증 구현
  • 실시간 데이터를 사용하여 동적 웹 및 모바일 앱 구축
  • 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 개

소스 저장소

이 패키지를 사용하는 프로젝트

아직 데이터가 없습니다.