wordpress_client 6.3.0 copy "wordpress_client: ^6.3.0" to clipboard
wordpress_client: ^6.3.0 copied to clipboard

outdated

A library written purely in dart to interact with Wordpress REST API in a fluent manner. Supports Authorization as well.

example/wordpress_client_example.dart

// ignore_for_file: avoid_redundant_argument_values, omit_local_variable_types, avoid_print

import 'package:wordpress_client/authorization.dart';
import 'package:wordpress_client/requests.dart';
import 'package:wordpress_client/responses.dart';
import 'package:wordpress_client/wordpress_client.dart';

Future<void> main() async {
  WordpressClient client;

  // Simple Usage
  client = WordpressClient.initialize(
    'https://example.com/',
    'wp-json/wp/v2',
    bootstrapper: (bootstrapper) => bootstrapper
        .withDebugMode(true)
        .withDefaultAuthorization(
          UsefulJwtAuth(
            'username',
            'password',
            callback: WordpressCallback(
              unhandledExceptionCallback: (dynamic unhandledException) {
                print('Unhandled Exception: $unhandledException');
              },
              requestErrorCallback: (errorContainer) {
                print('Request Error: ${errorContainer.errorResponse}');
              },
              responseCallback: (dynamic response) {
                print('Response: $response');
              },
            ),
          ),
        )
        .build(),
  );

  WordpressResponse<List<User>?> userResponse = await client.users.list(
    WordpressRequest(
      requestData: ListUserRequest()
        ..page = 1
        ..perPage = 10
        ..order = Order.asc,
    ),
  );

  userResponse = await client.users.list(
    WordpressRequest(
      requestData: ListUserRequest()
        ..page = 1
        ..perPage = 10
        ..order = Order.asc,
    ),
  );

  print(userResponse.message);

  if (userResponse.isSuccess) {
    for (final user in userResponse.data!) {
      print(user.name);
    }
  }
}
32
likes
0
pub points
80%
popularity

Publisher

verified publisherarunprakashg.com

A library written purely in dart to interact with Wordpress REST API in a fluent manner. Supports Authorization as well.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

cookie_jar, dio, dio_cookie_manager, http_parser, path, synchronized

More

Packages that depend on wordpress_client