Let me show you the WordPress Pages JSON API and how to display them in a Simple Flutter Web App.
The Data Model
I’ll first start by explaining the Data Model. You could open the pages from URL template like this: https://<wp>/wp-json/wp/v2/pages. The JSON Model is as follows:
- id: Integer
- title: Object with field “rendered” (could have HTML symbols)
- excerpt: Object that contains field “rendered. It is short version of content (could have HTML symbols)
- content: Object with field “rendered”. Most probably contains HTML code.
- status: String of predefined list of values
- slug: String – an URL friendly name
- date/date_gmt: String dates in format like “2020-02-10T18:58:04“
- comment_status: Boolean – is commenting allowed
- author – an ID of the creator
- parent – present when the Pages are filled-in in structural order
- menu_order:Int – optional number that apps could use for sorting
- featured_media: Int – an ID of a WordPress Media
How to display the WordPress Pages in a Simple Flutter Web Application.
Here is a Demo of Flutter Web App Loading The pages from the current Site: https://programtom.com/dev_examples/wp_pages/. There are several things to point out.
In this and in many previous Examples – the package flutter_html was used. Some of the settings needed are:
Html(data: widget.wpPage.content, onLinkTap: (url){ html.window.location.href = url; },)
We used the Database Application Generator with options Indexed DB to produce the Demo in a matter of hour or two. Happy coding.