-
Notifications
You must be signed in to change notification settings - Fork 14
Usage
Arun Prakash edited this page Mar 17, 2024
·
12 revisions
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);
// Typically invoked during app initialization (e.g., on a splash screen)
client.initialize();
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(),
);
client.initialize();
That's it! You're now equipped to seamlessly integrate WordPress functionalities into your Dart project using wordpress_client
. Happy coding!