wordpress_api 0.1.0 copy "wordpress_api: ^0.1.0" to clipboard
wordpress_api: ^0.1.0 copied to clipboard

outdated

A WordPress API client for flutter with support for WooCommerce and custom namespaces.

WordPress API client for Dart (Flutter) #

Description #

A WordPress API client for flutter with support for WooCommerce and custom namespaces.

Features #

  • Retrieve data from any endpoint.
  • Retrieve data from any namespace.

Installation #

In the dependencies: section of your pubspec.yaml, add the following line:

wordpress_api: <latest_version>

Usage Example #

The complete example is available here

import 'package:wordpress_api/wordpress_api.dart';

class MyWidget extends StatelessWidget {
  WordPressAPI api = WordPressAPI('site.com);
  List posts = []

  @override
  Widget build(BuildContext context) {
     return Scaffold(
      appBar: AppBar(
        title: 'WordPress API Example',
      ),
      body: ListView.builder(
        itemBuilder: (BuildContext context, int index) {
          Map<String, dynamic> post = posts[index];
          return Container(
            color: Colors.white,
            margin: EdgeInsets.all(8.0),
            child: ListTile(
              title: Padding(
                padding: const EdgeInsets.symmetric(vertical: 8.0),
                child: Text(
                  post['title']['rendered'],
                ),
              ),
              subtitle: Text(
                post['excerpt']['rendered'],
              ),
            ),
          );
        },
        itemCount: posts.length,
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: _fetchPosts,
        tooltip: 'Fetch Posts',
        child: Icon(Icons.arrow_downward),
      ),
    );
  }

  void _fetchPosts() async {
    final res = api.getAsync('posts');

    if(res['data'] != null) {
      posts.addAll(res['data'])
    }
  }
}

To Do #

  • Add authentication function
  • Add postAsync function

Contributions are welcome, report any issues here

99
likes
0
pub points
74%
popularity

Publisher

verified publisherdhmgroup.net

A WordPress API client for flutter with support for WooCommerce and custom namespaces.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

flutter, http

More

Packages that depend on wordpress_api