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

outdated

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

example/lib/main.dart

import 'dart:convert';

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: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(title: 'WPAPI Demo'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);

  final String title;

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  final wp = WordPressAPI('260blog.com');
  List<Map<String, dynamic>> posts;

  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          // Here we take the value from the MyHomePage object that was created by
          // the App.build method, and use it to set our appbar title.
          title: Text(widget.title),
        ),
        body: FutureBuilder(
          builder: (BuildContext context,
              AsyncSnapshot<Map<String, dynamic>> snapshot) {
            switch (snapshot.connectionState) {
              case ConnectionState.waiting:
                return Center(
                  child: CircularProgressIndicator(),
                );

                break;
              default:
                final posts = json.decode(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
71%
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