-
Notifications
You must be signed in to change notification settings - Fork 14
Usage
Easily integrate WordPress functionalities into your Dart project with the wordpress_client
package.
Add wordpress_client
to your project's pubspec.yaml
file:
dependencies:
wordpress_client: ^{latest}
Make sure to check the Package Page for the most recent version.
Integrate the library into the desired Dart class:
import 'package:wordpress_client/wordpress_client.dart';
Initialize the WordpressClient
using either the simple or advanced method. Ensure to initialize the client once and store its instance for subsequent usage.
final baseUrl = Uri.parse('https://example.com/wp-json/wp/v2');
final client = WordpressClient(baseUrl: baseUrl);
final baseUrl = Uri.parse('https://example.com/wp-json/wp/v2');
final client = WordpressClient(
baseUrl: baseUrl,
bootstrapper: (bootstrapper) => bootstrapper
.withStatisticDelegate((baseUrl, requestCount) {
print('$baseUrl -> $requestCount');
})
.withDebugMode(true)
.withDefaultAuthorization(
UsefulJwtAuth(
userName: 'username',
password: 'password',
),
)
.build(),
);
wordpress_client
also offers the flexibility of using a custom Dio
instance with the client. This can be achieved by calling WordpressClient.fromDioInstance(...)
constructor and by passing the Dio
instance via the instance
parameter.
That's it! You're now equipped to seamlessly integrate WordPress functionalities into your Dart project using wordpress_client
. Happy coding!