wordpress_api 0.1.2+5 copy "wordpress_api: ^0.1.2+5" to clipboard
wordpress_api: ^0.1.2+5 copied to clipboard

outdated

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

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:wordpress_api/wordpress_api.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'WPAPI Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: Home(),
    );
  }
}

class Home extends StatelessWidget {
  final wp = WordPressAPI('260blog.com');
  final List<Map<String, dynamic>> posts = [];

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('WPAPI Demo'),
      ),
      body: FutureBuilder(
        builder: (BuildContext context,
            AsyncSnapshot<Map<String, dynamic>> snapshot) {
          if (snapshot.hasError) {
            return Center(
              child: Text(snapshot.error),
            );
          }

          switch (snapshot.connectionState) {
            case ConnectionState.waiting:
              return Center(
                child: CircularProgressIndicator(),
              );
              break;
            default:
              final posts = snapshot.data['data'];
              return ListView.separated(
                itemBuilder: (BuildContext context, int index) {
                  return ListTile(
                    title: Text(posts[index]['title']['rendered']),
                  );
                },
                itemCount: posts.length,
                separatorBuilder: (BuildContext context, int index) {
                  return Divider(height: 16.0);
                },
              );
          }
        },
        future: wp.getAsync('posts'),
      ),
    );
  }
}
99
likes
0
pub points
76%
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