Aus öffentlichen Paketdaten erstellte Orientierung.
Ein Flutter/Dart-Paket, das nahtlose Interaktion mit der WordPress REST-API ermöglicht. Es unterstützt gängige Endpunkte und vollständige CRUD-Operationen für Beiträge, Seiten, Kommentare und mehr. Speziell für Entwickler konzipiert, die Apps erstellen, die mit WordPress-betriebenen Websites integriert sind, vereinfacht es die Datenabruf- und Verwaltung über mehrere Plattformen hinweg. Die Bibliothek ist leichtgewichtig, gut dokumentiert und aktiv gepflegt.
Anwendungsfälle
Hole Blogbeiträge und Seiten ab
Inhalt programmgesteuert erstellen und aktualisieren
Kommentare und Medien verwalten
Benutzerdefinierte WordPress-Frontends erstellen
WordPress als headless CMS integrieren
Hauptmerkmale
Vollständiger CRUD-Support für zentrale Endpunkte
Plattformübergreifende Kompatibilität
Einfache, intuitive API
Unterstützt die Authentifizierung über Tokens
Eingebaute Fehlerbehandlung und Antwortanalyse
Geeignet für
Flutter-Apps, die eine WordPress-Integration benötigen
Headless-CMS-Anwendungen
inhaltsbasierte mobile und Web-Anwendungen
Entwickler, die WordPress als Backend verwenden
Hinweise
Gültiger Zugriff auf die WordPress REST-API erforderlich
Authentifizierungseinstellung für geschützte Endpunkte erforderlich
Beschränkt auf WordPress REST-API-Funktionen
Nicht geeignet für komplexe, WordPress-spezifische Logik
Abhängig von der Stabilität des externen WordPress-Servers
Original-README
Originaler README-Schnappschuss aus dem verknüpften Quell-Repository. Aktuelle Inhalte finden Sie im Repository.
WordPress Client
The modern, strongly‑typed WordPress REST API client for Dart & Flutter — fast, flexible, and production‑ready.
🚀 Features
📦 API discovery support.
⏲️ Measures request completion time.
📝 Supports all CRUD operations.
🌐 Supports all common REST endpoints.
🧩 GraphQL (WPGraphQL) support: client.graphql.query/mutate/raw() with auth.
🎨 Custom Requests & Authorization systems.
🔐 3 Popular authorization methods.
🗄️ Third‑party Database integration.
🔧 Middlewares for request & response operations.
🎣 Events for preprocessing response.
🚀 Execute requests in Parallel (with configurable error handling).
🧠 Optional in‑memory caching for GET requests.
🌊 Polling-based streaming for single-resource retrieve endpoints (works great with Riverpod's StreamProvider).
📦 Install
Add wordpress_client to your pubspec.yaml:
dependencies:
wordpress_client: ^9.2.0
Then run flutter pub get or dart pub get.
🔧 Quick start
Import and initialize:
import'package:wordpress_client/wordpress_client.dart';
final client = WordpressClient.forSite(
siteUrl: Uri.parse('https://example.com'),
// or: baseUrl via WordpressClient(baseUrl: Uri.parse('.../wp-json/wp/v2'))
);
🧩 GraphQL (WPGraphQL)
If your site uses the WPGraphQL plugin (canonical), you can send GraphQL operations using the same client and auth.
final client = WordpressClient.forSite(
siteUrl: Uri.parse('https://example.com'),
bootstrapper: (b) => b
.withDefaultAuthorization(
WordpressAuth.appPassword(user: 'user', appPassword: 'xxxx-xxxx'),
)
.build(),
);
// Auto-resolves https://example.com/graphql from the REST base.final result = await client.graphql.query<List<Map<String, dynamic>>>(
document: '''
query Posts($limit: Int!) {
posts(first: $limit) {
nodes { id title }
}
}
''',
variables: { 'limit': 5 },
parseData: (data) {
final nodes = (data['posts']?['nodes'] asList<dynamic>? ?? const [])
.cast<Map<String, dynamic>>();
return nodes;
},
requireAuth: false, // set true for restricted queries/mutations
);
switch (result) {
caseWordpressSuccessResponse():
print(result.data);
caseWordpressFailureResponse():
print('GraphQL error: ${result.error}');
}
// Custom endpoint path if your site exposes a different GraphQL path
client.graphql.setEndpointPath('/custom-graphql');