├── .gitignore
├── .idea
├── codeStyles
│ └── Project.xml
├── dictionaries
│ └── suraj.xml
├── libraries
│ ├── Dart_Packages.xml
│ ├── Dart_SDK.xml
│ └── Flutter_Plugins.xml
├── modules.xml
├── vcs.xml
└── workspace.xml
├── .metadata
├── CHANGELOG.md
├── LICENSE
├── README.md
├── example
├── .flutter-plugins-dependencies
├── .gitignore
├── .metadata
├── README.md
├── analysis_options.yaml
├── android
│ ├── .gitignore
│ ├── app
│ │ ├── build.gradle
│ │ └── src
│ │ │ ├── debug
│ │ │ └── AndroidManifest.xml
│ │ │ ├── main
│ │ │ ├── AndroidManifest.xml
│ │ │ ├── kotlin
│ │ │ │ └── com
│ │ │ │ │ └── example
│ │ │ │ │ └── example
│ │ │ │ │ └── MainActivity.kt
│ │ │ └── res
│ │ │ │ ├── drawable-v21
│ │ │ │ └── launch_background.xml
│ │ │ │ ├── drawable
│ │ │ │ └── launch_background.xml
│ │ │ │ ├── mipmap-hdpi
│ │ │ │ └── ic_launcher.png
│ │ │ │ ├── mipmap-mdpi
│ │ │ │ └── ic_launcher.png
│ │ │ │ ├── mipmap-xhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ │ ├── mipmap-xxhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ │ ├── mipmap-xxxhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ │ ├── values-night
│ │ │ │ └── styles.xml
│ │ │ │ └── values
│ │ │ │ └── styles.xml
│ │ │ └── profile
│ │ │ └── AndroidManifest.xml
│ ├── build.gradle
│ ├── gradle.properties
│ ├── gradle
│ │ └── wrapper
│ │ │ └── gradle-wrapper.properties
│ └── settings.gradle
├── images
│ └── screenshots
│ │ ├── login.png
│ │ ├── post_comments.png
│ │ └── posts.png
├── ios
│ ├── .gitignore
│ ├── Flutter
│ │ ├── AppFrameworkInfo.plist
│ │ ├── Debug.xcconfig
│ │ ├── Flutter.podspec
│ │ └── Release.xcconfig
│ ├── Podfile
│ ├── Runner.xcodeproj
│ │ ├── project.pbxproj
│ │ ├── project.xcworkspace
│ │ │ ├── contents.xcworkspacedata
│ │ │ └── xcshareddata
│ │ │ │ ├── IDEWorkspaceChecks.plist
│ │ │ │ └── WorkspaceSettings.xcsettings
│ │ └── xcshareddata
│ │ │ └── xcschemes
│ │ │ └── Runner.xcscheme
│ ├── Runner.xcworkspace
│ │ ├── contents.xcworkspacedata
│ │ └── xcshareddata
│ │ │ ├── IDEWorkspaceChecks.plist
│ │ │ └── WorkspaceSettings.xcsettings
│ └── Runner
│ │ ├── AppDelegate.h
│ │ ├── AppDelegate.m
│ │ ├── AppDelegate.swift
│ │ ├── Assets.xcassets
│ │ ├── AppIcon.appiconset
│ │ │ ├── Contents.json
│ │ │ ├── Icon-App-1024x1024@1x.png
│ │ │ ├── Icon-App-20x20@1x.png
│ │ │ ├── Icon-App-20x20@2x.png
│ │ │ ├── Icon-App-20x20@3x.png
│ │ │ ├── Icon-App-29x29@1x.png
│ │ │ ├── Icon-App-29x29@2x.png
│ │ │ ├── Icon-App-29x29@3x.png
│ │ │ ├── Icon-App-40x40@1x.png
│ │ │ ├── Icon-App-40x40@2x.png
│ │ │ ├── Icon-App-40x40@3x.png
│ │ │ ├── Icon-App-60x60@2x.png
│ │ │ ├── Icon-App-60x60@3x.png
│ │ │ ├── Icon-App-76x76@1x.png
│ │ │ ├── Icon-App-76x76@2x.png
│ │ │ └── Icon-App-83.5x83.5@2x.png
│ │ └── LaunchImage.imageset
│ │ │ ├── Contents.json
│ │ │ ├── LaunchImage.png
│ │ │ ├── LaunchImage@2x.png
│ │ │ ├── LaunchImage@3x.png
│ │ │ └── README.md
│ │ ├── Base.lproj
│ │ ├── LaunchScreen.storyboard
│ │ └── Main.storyboard
│ │ ├── Info.plist
│ │ ├── Runner-Bridging-Header.h
│ │ └── main.m
├── lib
│ ├── display_posts.dart
│ ├── generated_plugin_registrant.dart
│ ├── login.dart
│ ├── main.dart
│ └── post_page.dart
├── pubspec.yaml
└── test
│ └── widget_test.dart
├── flutter_wordpress.iml
├── lib
├── constants.dart
├── flutter_wordpress.dart
├── requests
│ ├── params_category_list.dart
│ ├── params_comment_list.dart
│ ├── params_media_list.dart
│ ├── params_page_list.dart
│ ├── params_post_list.dart
│ ├── params_tag_list.dart
│ └── params_user_list.dart
└── schemas
│ ├── avatar_urls.dart
│ ├── capabilities.dart
│ ├── category.dart
│ ├── comment.dart
│ ├── comment_hierarchy.dart
│ ├── content.dart
│ ├── excerpt.dart
│ ├── fetch_user_result.dart
│ ├── guid.dart
│ ├── jwt_response.dart
│ ├── labels.dart
│ ├── links.dart
│ ├── media.dart
│ ├── page.dart
│ ├── post.dart
│ ├── post_statuses.dart
│ ├── post_types.dart
│ ├── settings.dart
│ ├── tag.dart
│ ├── taxonomies.dart
│ ├── title.dart
│ ├── user.dart
│ └── wordpress_error.dart
├── pubspec.lock
└── pubspec.yaml
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | .dart_tool/
3 |
4 | .packages
5 | .pub/
6 |
7 | build/
8 | ios/.generated/
9 | ios/Flutter/Generated.xcconfig
10 | ios/Runner/GeneratedPluginRegistrant.*
11 |
--------------------------------------------------------------------------------
/.idea/codeStyles/Project.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/.idea/dictionaries/suraj.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | wordpress
5 |
6 |
7 |
--------------------------------------------------------------------------------
/.idea/libraries/Dart_Packages.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
239 |
240 |
241 |
242 |
243 |
244 |
245 |
246 |
247 |
248 |
249 |
250 |
251 |
252 |
253 |
254 |
255 |
256 |
257 |
258 |
259 |
260 |
261 |
262 |
263 |
264 |
265 |
266 |
267 |
268 |
269 |
270 |
271 |
272 |
273 |
274 |
275 |
276 |
277 |
278 |
279 |
280 |
--------------------------------------------------------------------------------
/.idea/libraries/Dart_SDK.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/.idea/libraries/Flutter_Plugins.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.metadata:
--------------------------------------------------------------------------------
1 | # This file tracks properties of this Flutter project.
2 | # Used by Flutter tool to assess capabilities and perform upgrades etc.
3 | #
4 | # This file should be version controlled and should not be manually edited.
5 |
6 | version:
7 | revision: 5391447fae6209bb21a89e6a5a6583cac1af9b4b
8 | channel: stable
9 |
10 | project_type: package
11 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | ## [0.3.0-nullsafety.0] - Type Safety
2 |
3 | * Added type safety
4 |
5 | ## [0.2.1] - 26/04/2020
6 | * Custom post types
7 |
8 | ## [0.2.0] - 21/04/2020
9 | * Create, Update and Delete Comments
10 | * Create, Update and Delete Posts
11 | * Update and Delete Users
12 |
13 | ## [0.1.4] - 27/02/2019
14 | * Updated homepage URL
15 |
16 | ## [0.1.3] - 26/02/2019
17 | * Update example. Update post fetching to include author, comments. Add fetching comments as a hierarchy.
18 |
19 | ## [0.1.2] - 16/02/2019
20 | * Add fetch categories, tags, pages. Add create post, comments.
21 |
22 | ## [0.1.1] - 14/02/2019
23 |
24 | * Update README.md. Add fetch users list, fetch comments list.
25 | * Implemented authorization function and fetching of Posts with parameters
26 |
27 | ## [0.1.0] - Added Models
28 |
29 | * Created model classes for Wordpress REST API and implemented user authentication function using JWT authentication system.
30 |
31 |
32 | ## [0.0.1] - TODO: Init.
33 |
34 | * Under Development. Nothing works now.
35 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2018 Sachin Ganesh
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Flutter Wordpress
2 |
3 | [pub.dev](https://pub.dev/packages/flutter_wordpress)
4 |
5 | This library uses [WordPress REST API V2](https://developer.wordpress.org/rest-api/) to provide a way for your application to interact with your WordPress website.
6 |
7 | [Tutorial - by Ritesh Sharma](https://medium.com/flutter-community/building-flutter-apps-with-wordpress-backend-part-1-e56414a4a79b)
8 |
9 | ## Screenshots
10 |
11 |
12 |
13 | ## Requirements
14 |
15 | For authentication and usage of administrator level REST APIs, you need to use either of the two popular authentication plugins in your WordPress site:
16 |
17 | 1. [Application Passwords](https://wordpress.org/plugins/application-passwords/)
18 | 2. [JWT Authentication for WP REST API](https://wordpress.org/plugins/jwt-authentication-for-wp-rest-api/) (recommended)
19 |
20 | ## Getting Started
21 |
22 | ### 1. Import library
23 |
24 | #### First:
25 |
26 | Find your pubspec.yaml in the root of your project and add flutter_wordpress: ^0.2.0 under dependencies:
27 |
28 | #### Second:
29 |
30 | ```dart
31 | import 'package:flutter_wordpress/flutter_wordpress.dart' as wp;
32 | ```
33 |
34 | ### 2. Instantiate WordPress class
35 |
36 | ```dart
37 | wp.WordPress wordPress;
38 |
39 | // adminName and adminKey is needed only for admin level APIs
40 | wordPress = wp.WordPress(
41 | baseUrl: 'http://localhost',
42 | authenticator: wp.WordPressAuthenticator.JWT,
43 | adminName: '',
44 | adminKey: '',
45 | );
46 | ```
47 |
48 | ### 3. Authenticate User
49 |
50 | ```dart
51 | Future response = wordPress.authenticateUser(
52 | username: 'ChiefEditor',
53 | password: 'chiefeditor@123',
54 | );
55 |
56 | response.then((user) {
57 | createPost(user);
58 | }).catchError((err) {
59 | print('Failed to fetch user: $err');
60 | });
61 | ```
62 |
63 | ### 4. Fetch Posts
64 |
65 | ```dart
66 | Future> posts = wordPress.fetchPosts(
67 | postParams: wp.ParamsPostList(
68 | context: wp.WordPressContext.view,
69 | pageNum: 1,
70 | perPage: 20,
71 | order: wp.Order.desc,
72 | orderBy: wp.PostOrderBy.date,
73 | ),
74 | fetchAuthor: true,
75 | fetchFeaturedMedia: true,
76 | fetchComments: true,
77 | postType: 'post'
78 | );
79 | ```
80 |
81 | ### 5. Fetch Users
82 |
83 | ```dart
84 | Future> users = wordPress.fetchUsers(
85 | params: wp.ParamsUserList(
86 | context: wp.WordPressContext.view,
87 | pageNum: 1,
88 | perPage: 30,
89 | order: wp.Order.asc,
90 | orderBy: wp.UsersOrderBy.name,
91 | roles: ['subscriber'],
92 | ),
93 | );
94 | ```
95 |
96 | ### 6. Fetch Comments
97 |
98 | ```dart
99 | Future> comments = wordPress.fetchComments(
100 | params: wp.ParamsCommentList(
101 | context: wp.WordPressContext.view,
102 | pageNum: 1,
103 | perPage: 30,
104 | includePostIDs: [1],
105 | ),
106 | );
107 | ```
108 |
109 | ### 7. Create User
110 |
111 | ```dart
112 | Future createUser({@required String email, @required String username, @required String password, @required List roles}) async {
113 | await widget.wordPress.createUser(
114 | user: wp.User(
115 | email: email,
116 | password: password,
117 | username: username,
118 | roles: roles
119 | )
120 | ).then((p) {
121 | print('User created successfully ${p}');
122 | }).catchError((err) {
123 | print('Failed to create user: $err');
124 | });
125 | }
126 | ```
127 |
128 | ### 8. Create Post
129 |
130 | ```dart
131 | void createPost({@required wp.User user}) {
132 | final post = widget.wordPress.createPost(
133 | post: new wp.Post(
134 | title: 'First post as a Chief Editor',
135 | content: 'Blah! blah! blah!',
136 | excerpt: 'Discussion about blah!',
137 | authorID: user.id,
138 | commentStatus: wp.PostCommentStatus.open,
139 | pingStatus: wp.PostPingStatus.closed,
140 | status: wp.PostPageStatus.publish,
141 | format: wp.PostFormat.standard,
142 | sticky: true,
143 | ),
144 | );
145 |
146 | post.then((p) {
147 | print('Post created successfully with ID: ${p.id}');
148 | }).catchError((err) {
149 | print('Failed to create post: $err');
150 | });
151 | }
152 | ```
153 |
154 | ### 9. create Comment
155 |
156 | ```dart
157 | void createComment({@required int userId, @required int postId}) {
158 | final comment = widget.wordPress.createComment(
159 | comment: new wp.Comment(
160 | author: userId,
161 | post: postId,
162 | content: "First!",
163 | parent: 0,
164 | ),
165 | );
166 |
167 | comment.then((c) {
168 | print('Comment successfully posted with ID: ${c.id}');
169 | }).catchError((err) {
170 | print('Failed to comment: $err');
171 | });
172 | }
173 | ```
174 |
175 | ### 10. Update Comment
176 |
177 | ```dart
178 | Future updateComment({@required int id, @required int postId, @required wp.User user}) async {
179 | await widget.wordPress.updateComment(
180 | comment: new wp.Comment(
181 | content: "Comment Updated2!",
182 | author: user.id,
183 | post: postId,
184 | ),
185 | id: id,
186 | ).then((c) {
187 | print('Comment updated successfully "$c"');
188 | }).catchError((err) {
189 | print('Failed to update Comment: $err');
190 | });
191 | }
192 | ```
193 |
194 | ### 11. Update Post
195 |
196 | ```dart
197 | Future updatePost({@required int id, @required int userId}) async {
198 | await widget.wordPress.updatePost(
199 | post: new wp.Post(
200 | title: 'First post as a Chief Editor',
201 | content: 'Blah! blah! blah!',
202 | excerpt: 'Discussion about blah!',
203 | authorID: userId,
204 | commentStatus: wp.PostCommentStatus.open,
205 | pingStatus: wp.PostPingStatus.closed,
206 | status: wp.PostPageStatus.publish,
207 | format: wp.PostFormat.standard,
208 | sticky: true,
209 | ),
210 | id: id, //
211 | ).then((p) {
212 | print('Post updated successfully with ID ${p}');
213 | }).catchError((err) {
214 | print('Failed to update post: $err');
215 | });
216 | }
217 | ```
218 |
219 | ### 12. Update User
220 |
221 | ```dart
222 | Future updateUser({@required int id, @required String username, @required String email}) async {
223 | await widget.wordPress.updateUser(
224 | user: new wp.User(
225 | description: "This is description for this user",
226 | username: username,
227 | id: id,
228 | email: email
229 | ),
230 | id: id,
231 | ).then((u) {
232 | print('User updated successfully $u');
233 | }).catchError((err) {
234 | print('Failed to update User: $err');
235 | });
236 | }
237 | ```
238 |
239 |
240 | ### 13. Delete Comment
241 |
242 | ```dart
243 | Future deleteComment({@required int id}) async {
244 | await widget.wordPress.deleteComment(id: id).then((c) {
245 | print('Comment Deleted successfully: $c');
246 | }).catchError((err) {
247 | print('Failed to Delete comment: $err');
248 | });
249 | }
250 | ```
251 |
252 | ### 14. Delete Post
253 |
254 | ```dart
255 | Future deletePost({@required int id}) async {
256 | await widget.wordPress.deletePost(id: id).then((p) {
257 | print('Post Deleted successfully: $p');
258 | }).catchError((err) {
259 | print('Failed to Delete post: $err');
260 | });
261 | }
262 | ```
263 |
264 | ### 15. Delete User
265 |
266 | ```dart
267 | Future deleteUser({@required int id, @required int reassign}) async {
268 | await widget.wordPress.deleteUser(id: id, reassign: reassign).then((u) {
269 | print('User Deleted successfully: $u');
270 | }).catchError((err) {
271 | print('Failed to Delete user: $err');
272 | });
273 | }
274 | ```
275 |
276 | ### 16. Upload Media
277 |
278 | ```dart
279 | uploadMedia(File image) async {
280 | var media = await wordPress.uploadMedia(image).then((m) {
281 | print('Media uploaded successfully: $m');
282 | }).catchError((err) {
283 | print('Failed to upload Media: $err');
284 | });
285 | int mediaID = media['id'];
286 | }
287 | ```
288 |
289 | ## Future Work
290 |
291 | 1. Implementing OAuth 2.0 authentication.
292 |
293 | ## Contributors
294 | - [Suraj Shettigar](https://github.com/SurajShettigar)
295 | - [Sachin Ganesh](https://github.com/SachinGanesh)
296 | - [Harm-Jan Roskam](https://github.com/harmjanr)
297 | - [Yahya Makarim](https://github.com/ymakarim)
298 | - [Garv Maggu](https://github.com/GarvMaggu)
299 |
--------------------------------------------------------------------------------
/example/.flutter-plugins-dependencies:
--------------------------------------------------------------------------------
1 | {"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"video_player_avfoundation","path":"/Users/ritheshsalyan/Developer/DevTools/flutter/.pub-cache/hosted/pub.dartlang.org/video_player_avfoundation-2.3.0/","dependencies":[]},{"name":"wakelock","path":"/Users/ritheshsalyan/Developer/DevTools/flutter/.pub-cache/hosted/pub.dartlang.org/wakelock-0.6.1+1/","dependencies":[]},{"name":"webview_flutter_wkwebview","path":"/Users/ritheshsalyan/Developer/DevTools/flutter/.pub-cache/hosted/pub.dartlang.org/webview_flutter_wkwebview-2.7.1/","dependencies":[]}],"android":[{"name":"video_player_android","path":"/Users/ritheshsalyan/Developer/DevTools/flutter/.pub-cache/hosted/pub.dartlang.org/video_player_android-2.3.0/","dependencies":[]},{"name":"wakelock","path":"/Users/ritheshsalyan/Developer/DevTools/flutter/.pub-cache/hosted/pub.dartlang.org/wakelock-0.6.1+1/","dependencies":[]},{"name":"webview_flutter_android","path":"/Users/ritheshsalyan/Developer/DevTools/flutter/.pub-cache/hosted/pub.dartlang.org/webview_flutter_android-2.8.3/","dependencies":[]}],"macos":[{"name":"wakelock_macos","path":"/Users/ritheshsalyan/Developer/DevTools/flutter/.pub-cache/hosted/pub.dartlang.org/wakelock_macos-0.4.0/","dependencies":[]}],"linux":[],"windows":[],"web":[{"name":"video_player_web","path":"/Users/ritheshsalyan/Developer/DevTools/flutter/.pub-cache/hosted/pub.dartlang.org/video_player_web-2.0.7/","dependencies":[]},{"name":"wakelock_web","path":"/Users/ritheshsalyan/Developer/DevTools/flutter/.pub-cache/hosted/pub.dartlang.org/wakelock_web-0.4.0/","dependencies":[]}]},"dependencyGraph":[{"name":"video_player","dependencies":["video_player_android","video_player_avfoundation","video_player_web"]},{"name":"video_player_android","dependencies":[]},{"name":"video_player_avfoundation","dependencies":[]},{"name":"video_player_web","dependencies":[]},{"name":"wakelock","dependencies":["wakelock_macos","wakelock_web"]},{"name":"wakelock_macos","dependencies":[]},{"name":"wakelock_web","dependencies":[]},{"name":"webview_flutter","dependencies":["webview_flutter_android","webview_flutter_wkwebview"]},{"name":"webview_flutter_android","dependencies":[]},{"name":"webview_flutter_wkwebview","dependencies":[]}],"date_created":"2022-02-23 10:31:39.189036","version":"2.8.1"}
--------------------------------------------------------------------------------
/example/.gitignore:
--------------------------------------------------------------------------------
1 | # Miscellaneous
2 | *.class
3 | *.lock
4 | *.log
5 | *.pyc
6 | *.swp
7 | .DS_Store
8 | .atom/
9 | .buildlog/
10 | .history
11 | .svn/
12 | *flutter_export_environment*
13 |
14 | # IntelliJ related
15 | *.iml
16 | *.ipr
17 | *.iws
18 | .idea/
19 |
20 | # Visual Studio Code related
21 | .vscode/
22 |
23 | # Flutter/Dart/Pub related
24 | **/doc/api/
25 | .dart_tool/
26 | .flutter-plugins
27 | .packages
28 | .pub-cache/
29 | .pub/
30 | build/
31 |
32 | # Android related
33 | **/android/**/gradle-wrapper.jar
34 | **/android/.gradle
35 | **/android/captures/
36 | **/android/gradlew
37 | **/android/gradlew.bat
38 | **/android/local.properties
39 | **/android/**/GeneratedPluginRegistrant.java
40 |
41 | # iOS/XCode related
42 | **/ios/**/*.mode1v3
43 | **/ios/**/*.mode2v3
44 | **/ios/**/*.moved-aside
45 | **/ios/**/*.pbxuser
46 | **/ios/**/*.perspectivev3
47 | **/ios/**/*sync/
48 | **/ios/**/.sconsign.dblite
49 | **/ios/**/.tags*
50 | **/ios/**/.vagrant/
51 | **/ios/**/DerivedData/
52 | **/ios/**/Icon?
53 | **/ios/**/Pods/
54 | **/ios/**/.symlinks/
55 | **/ios/**/profile
56 | **/ios/**/xcuserdata
57 | **/ios/.generated/
58 | **/ios/Flutter/App.framework
59 | **/ios/Flutter/Flutter.framework
60 | **/ios/Flutter/Generated.xcconfig
61 | **/ios/Flutter/app.flx
62 | **/ios/Flutter/app.zip
63 | **/ios/Flutter/flutter_assets/
64 | **/ios/ServiceDefinitions.json
65 | **/ios/Runner/GeneratedPluginRegistrant.*
66 |
67 | # Exceptions to above rules.
68 | !**/ios/**/default.mode1v3
69 | !**/ios/**/default.mode2v3
70 | !**/ios/**/default.pbxuser
71 | !**/ios/**/default.perspectivev3
72 | !/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages
73 |
--------------------------------------------------------------------------------
/example/.metadata:
--------------------------------------------------------------------------------
1 | # This file tracks properties of this Flutter project.
2 | # Used by Flutter tool to assess capabilities and perform upgrades etc.
3 | #
4 | # This file should be version controlled and should not be manually edited.
5 |
6 | version:
7 | revision: 5391447fae6209bb21a89e6a5a6583cac1af9b4b
8 | channel: stable
9 |
10 | project_type: app
11 |
--------------------------------------------------------------------------------
/example/README.md:
--------------------------------------------------------------------------------
1 | # Flutter Wordpress Example
2 | Basic login, displaying posts and comments have been implemented in this example flutter app.
3 |
4 | ## Screenshots
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/example/analysis_options.yaml:
--------------------------------------------------------------------------------
1 | # This file configures the analyzer, which statically analyzes Dart code to
2 | # check for errors, warnings, and lints.
3 | #
4 | # The issues identified by the analyzer are surfaced in the UI of Dart-enabled
5 | # IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be
6 | # invoked from the command line by running `flutter analyze`.
7 |
8 | # The following line activates a set of recommended lints for Flutter apps,
9 | # packages, and plugins designed to encourage good coding practices.
10 | include: package:flutter_lints/flutter.yaml
11 |
12 | linter:
13 | # The lint rules applied to this project can be customized in the
14 | # section below to disable rules from the `package:flutter_lints/flutter.yaml`
15 | # included above or to enable additional rules. A list of all available lints
16 | # and their documentation is published at
17 | # https://dart-lang.github.io/linter/lints/index.html.
18 | #
19 | # Instead of disabling a lint rule for the entire project in the
20 | # section below, it can also be suppressed for a single line of code
21 | # or a specific dart file by using the `// ignore: name_of_lint` and
22 | # `// ignore_for_file: name_of_lint` syntax on the line or in the file
23 | # producing the lint.
24 | rules:
25 | # avoid_print: false # Uncomment to disable the `avoid_print` rule
26 | # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule
27 |
28 | # Additional information about this file can be found at
29 | # https://dart.dev/guides/language/analysis-options
30 |
--------------------------------------------------------------------------------
/example/android/.gitignore:
--------------------------------------------------------------------------------
1 | gradle-wrapper.jar
2 | /.gradle
3 | /captures/
4 | /gradlew
5 | /gradlew.bat
6 | /local.properties
7 | GeneratedPluginRegistrant.java
8 |
9 | # Remember to never publicly share your keystore.
10 | # See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app
11 | key.properties
12 | **/*.keystore
13 | **/*.jks
14 |
--------------------------------------------------------------------------------
/example/android/app/build.gradle:
--------------------------------------------------------------------------------
1 | def localProperties = new Properties()
2 | def localPropertiesFile = rootProject.file('local.properties')
3 | if (localPropertiesFile.exists()) {
4 | localPropertiesFile.withReader('UTF-8') { reader ->
5 | localProperties.load(reader)
6 | }
7 | }
8 |
9 | def flutterRoot = localProperties.getProperty('flutter.sdk')
10 | if (flutterRoot == null) {
11 | throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
12 | }
13 |
14 | def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
15 | if (flutterVersionCode == null) {
16 | flutterVersionCode = '1'
17 | }
18 |
19 | def flutterVersionName = localProperties.getProperty('flutter.versionName')
20 | if (flutterVersionName == null) {
21 | flutterVersionName = '1.0'
22 | }
23 |
24 | apply plugin: 'com.android.application'
25 | apply plugin: 'kotlin-android'
26 | apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
27 |
28 | android {
29 | compileSdkVersion flutter.compileSdkVersion
30 |
31 | compileOptions {
32 | sourceCompatibility JavaVersion.VERSION_1_8
33 | targetCompatibility JavaVersion.VERSION_1_8
34 | }
35 |
36 | kotlinOptions {
37 | jvmTarget = '1.8'
38 | }
39 |
40 | sourceSets {
41 | main.java.srcDirs += 'src/main/kotlin'
42 | }
43 |
44 | defaultConfig {
45 | // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
46 | applicationId "com.example.example"
47 | minSdkVersion 19//flutter.minSdkVersion
48 | targetSdkVersion flutter.targetSdkVersion
49 | versionCode flutterVersionCode.toInteger()
50 | versionName flutterVersionName
51 | }
52 |
53 | buildTypes {
54 | release {
55 | // TODO: Add your own signing config for the release build.
56 | // Signing with the debug keys for now, so `flutter run --release` works.
57 | signingConfig signingConfigs.debug
58 | }
59 | }
60 | }
61 |
62 | flutter {
63 | source '../..'
64 | }
65 |
66 | dependencies {
67 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
68 | }
69 |
--------------------------------------------------------------------------------
/example/android/app/src/debug/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/example/android/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
7 |
15 |
19 |
23 |
24 |
25 |
26 |
27 |
28 |
30 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/example/android/app/src/main/kotlin/com/example/example/MainActivity.kt:
--------------------------------------------------------------------------------
1 | package com.example.example
2 |
3 | import io.flutter.embedding.android.FlutterActivity
4 |
5 | class MainActivity: FlutterActivity() {
6 | }
7 |
--------------------------------------------------------------------------------
/example/android/app/src/main/res/drawable-v21/launch_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
12 |
13 |
--------------------------------------------------------------------------------
/example/android/app/src/main/res/drawable/launch_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
12 |
13 |
--------------------------------------------------------------------------------
/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dreamsoftin/flutter_wordpress/06b429fcd3a3d8d6c7cffc9ae9b0a296bb1047b9/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dreamsoftin/flutter_wordpress/06b429fcd3a3d8d6c7cffc9ae9b0a296bb1047b9/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dreamsoftin/flutter_wordpress/06b429fcd3a3d8d6c7cffc9ae9b0a296bb1047b9/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dreamsoftin/flutter_wordpress/06b429fcd3a3d8d6c7cffc9ae9b0a296bb1047b9/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dreamsoftin/flutter_wordpress/06b429fcd3a3d8d6c7cffc9ae9b0a296bb1047b9/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/android/app/src/main/res/values-night/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
9 |
15 |
18 |
19 |
--------------------------------------------------------------------------------
/example/android/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
9 |
15 |
18 |
19 |
--------------------------------------------------------------------------------
/example/android/app/src/profile/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/example/android/build.gradle:
--------------------------------------------------------------------------------
1 | buildscript {
2 | ext.kotlin_version = '1.6.10'
3 | repositories {
4 | google()
5 | mavenCentral()
6 | }
7 |
8 | dependencies {
9 | classpath 'com.android.tools.build:gradle:4.1.0'
10 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
11 | }
12 | }
13 |
14 | allprojects {
15 | repositories {
16 | google()
17 | mavenCentral()
18 | }
19 | }
20 |
21 | rootProject.buildDir = '../build'
22 | subprojects {
23 | project.buildDir = "${rootProject.buildDir}/${project.name}"
24 | }
25 | subprojects {
26 | project.evaluationDependsOn(':app')
27 | }
28 |
29 | task clean(type: Delete) {
30 | delete rootProject.buildDir
31 | }
32 |
--------------------------------------------------------------------------------
/example/android/gradle.properties:
--------------------------------------------------------------------------------
1 | org.gradle.jvmargs=-Xmx1536M
2 | android.useAndroidX=true
3 | android.enableJetifier=true
4 |
--------------------------------------------------------------------------------
/example/android/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Fri Jun 23 08:50:38 CEST 2017
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip
7 |
--------------------------------------------------------------------------------
/example/android/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
3 | def localPropertiesFile = new File(rootProject.projectDir, "local.properties")
4 | def properties = new Properties()
5 |
6 | assert localPropertiesFile.exists()
7 | localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) }
8 |
9 | def flutterSdkPath = properties.getProperty("flutter.sdk")
10 | assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
11 | apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle"
12 |
--------------------------------------------------------------------------------
/example/images/screenshots/login.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dreamsoftin/flutter_wordpress/06b429fcd3a3d8d6c7cffc9ae9b0a296bb1047b9/example/images/screenshots/login.png
--------------------------------------------------------------------------------
/example/images/screenshots/post_comments.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dreamsoftin/flutter_wordpress/06b429fcd3a3d8d6c7cffc9ae9b0a296bb1047b9/example/images/screenshots/post_comments.png
--------------------------------------------------------------------------------
/example/images/screenshots/posts.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dreamsoftin/flutter_wordpress/06b429fcd3a3d8d6c7cffc9ae9b0a296bb1047b9/example/images/screenshots/posts.png
--------------------------------------------------------------------------------
/example/ios/.gitignore:
--------------------------------------------------------------------------------
1 | **/dgph
2 | *.mode1v3
3 | *.mode2v3
4 | *.moved-aside
5 | *.pbxuser
6 | *.perspectivev3
7 | **/*sync/
8 | .sconsign.dblite
9 | .tags*
10 | **/.vagrant/
11 | **/DerivedData/
12 | Icon?
13 | **/Pods/
14 | **/.symlinks/
15 | profile
16 | xcuserdata
17 | **/.generated/
18 | Flutter/App.framework
19 | Flutter/Flutter.framework
20 | Flutter/Flutter.podspec
21 | Flutter/Generated.xcconfig
22 | Flutter/ephemeral/
23 | Flutter/app.flx
24 | Flutter/app.zip
25 | Flutter/flutter_assets/
26 | Flutter/flutter_export_environment.sh
27 | ServiceDefinitions.json
28 | Runner/GeneratedPluginRegistrant.*
29 |
30 | # Exceptions to above rules.
31 | !default.mode1v3
32 | !default.mode2v3
33 | !default.pbxuser
34 | !default.perspectivev3
35 |
--------------------------------------------------------------------------------
/example/ios/Flutter/AppFrameworkInfo.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | App
9 | CFBundleIdentifier
10 | io.flutter.flutter.app
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | App
15 | CFBundlePackageType
16 | FMWK
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1.0
23 | MinimumOSVersion
24 | 8.0
25 |
26 |
27 |
--------------------------------------------------------------------------------
/example/ios/Flutter/Debug.xcconfig:
--------------------------------------------------------------------------------
1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"
2 | #include "Generated.xcconfig"
3 |
--------------------------------------------------------------------------------
/example/ios/Flutter/Flutter.podspec:
--------------------------------------------------------------------------------
1 | #
2 | # NOTE: This podspec is NOT to be published. It is only used as a local source!
3 | #
4 |
5 | Pod::Spec.new do |s|
6 | s.name = 'Flutter'
7 | s.version = '1.0.0'
8 | s.summary = 'High-performance, high-fidelity mobile apps.'
9 | s.description = <<-DESC
10 | Flutter provides an easy and productive way to build and deploy high-performance mobile apps for Android and iOS.
11 | DESC
12 | s.homepage = 'https://flutter.io'
13 | s.license = { :type => 'MIT' }
14 | s.author = { 'Flutter Dev Team' => 'flutter-dev@googlegroups.com' }
15 | s.source = { :git => 'https://github.com/flutter/engine', :tag => s.version.to_s }
16 | s.ios.deployment_target = '8.0'
17 | s.vendored_frameworks = 'Flutter.framework'
18 | end
19 |
--------------------------------------------------------------------------------
/example/ios/Flutter/Release.xcconfig:
--------------------------------------------------------------------------------
1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
2 | #include "Generated.xcconfig"
3 |
--------------------------------------------------------------------------------
/example/ios/Podfile:
--------------------------------------------------------------------------------
1 | # Uncomment this line to define a global platform for your project
2 | # platform :ios, '9.0'
3 |
4 | # CocoaPods analytics sends network stats synchronously affecting flutter build latency.
5 | ENV['COCOAPODS_DISABLE_STATS'] = 'true'
6 |
7 | project 'Runner', {
8 | 'Debug' => :debug,
9 | 'Profile' => :release,
10 | 'Release' => :release,
11 | }
12 |
13 | def flutter_root
14 | generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
15 | unless File.exist?(generated_xcode_build_settings_path)
16 | raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
17 | end
18 |
19 | File.foreach(generated_xcode_build_settings_path) do |line|
20 | matches = line.match(/FLUTTER_ROOT\=(.*)/)
21 | return matches[1].strip if matches
22 | end
23 | raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
24 | end
25 |
26 | require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)
27 |
28 | flutter_ios_podfile_setup
29 |
30 | target 'Runner' do
31 | flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
32 | end
33 |
34 | post_install do |installer|
35 | installer.pods_project.targets.each do |target|
36 | flutter_additional_ios_build_settings(target)
37 | end
38 | end
39 |
--------------------------------------------------------------------------------
/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | PreviewsEnabled
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
31 |
32 |
33 |
34 |
40 |
41 |
42 |
43 |
44 |
45 |
56 |
58 |
64 |
65 |
66 |
67 |
68 |
69 |
75 |
77 |
83 |
84 |
85 |
86 |
88 |
89 |
92 |
93 |
94 |
--------------------------------------------------------------------------------
/example/ios/Runner.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/example/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | PreviewsEnabled
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/example/ios/Runner/AppDelegate.h:
--------------------------------------------------------------------------------
1 | #import
2 | #import
3 |
4 | @interface AppDelegate : FlutterAppDelegate
5 |
6 | @end
7 |
--------------------------------------------------------------------------------
/example/ios/Runner/AppDelegate.m:
--------------------------------------------------------------------------------
1 | #include "AppDelegate.h"
2 | #include "GeneratedPluginRegistrant.h"
3 |
4 | @implementation AppDelegate
5 |
6 | - (BOOL)application:(UIApplication *)application
7 | didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
8 | [GeneratedPluginRegistrant registerWithRegistry:self];
9 | // Override point for customization after application launch.
10 | return [super application:application didFinishLaunchingWithOptions:launchOptions];
11 | }
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/example/ios/Runner/AppDelegate.swift:
--------------------------------------------------------------------------------
1 | import UIKit
2 | import Flutter
3 |
4 | @UIApplicationMain
5 | @objc class AppDelegate: FlutterAppDelegate {
6 | override func application(
7 | _ application: UIApplication,
8 | didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
9 | ) -> Bool {
10 | GeneratedPluginRegistrant.register(with: self)
11 | return super.application(application, didFinishLaunchingWithOptions: launchOptions)
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "size" : "20x20",
5 | "idiom" : "iphone",
6 | "filename" : "Icon-App-20x20@2x.png",
7 | "scale" : "2x"
8 | },
9 | {
10 | "size" : "20x20",
11 | "idiom" : "iphone",
12 | "filename" : "Icon-App-20x20@3x.png",
13 | "scale" : "3x"
14 | },
15 | {
16 | "size" : "29x29",
17 | "idiom" : "iphone",
18 | "filename" : "Icon-App-29x29@1x.png",
19 | "scale" : "1x"
20 | },
21 | {
22 | "size" : "29x29",
23 | "idiom" : "iphone",
24 | "filename" : "Icon-App-29x29@2x.png",
25 | "scale" : "2x"
26 | },
27 | {
28 | "size" : "29x29",
29 | "idiom" : "iphone",
30 | "filename" : "Icon-App-29x29@3x.png",
31 | "scale" : "3x"
32 | },
33 | {
34 | "size" : "40x40",
35 | "idiom" : "iphone",
36 | "filename" : "Icon-App-40x40@2x.png",
37 | "scale" : "2x"
38 | },
39 | {
40 | "size" : "40x40",
41 | "idiom" : "iphone",
42 | "filename" : "Icon-App-40x40@3x.png",
43 | "scale" : "3x"
44 | },
45 | {
46 | "size" : "60x60",
47 | "idiom" : "iphone",
48 | "filename" : "Icon-App-60x60@2x.png",
49 | "scale" : "2x"
50 | },
51 | {
52 | "size" : "60x60",
53 | "idiom" : "iphone",
54 | "filename" : "Icon-App-60x60@3x.png",
55 | "scale" : "3x"
56 | },
57 | {
58 | "size" : "20x20",
59 | "idiom" : "ipad",
60 | "filename" : "Icon-App-20x20@1x.png",
61 | "scale" : "1x"
62 | },
63 | {
64 | "size" : "20x20",
65 | "idiom" : "ipad",
66 | "filename" : "Icon-App-20x20@2x.png",
67 | "scale" : "2x"
68 | },
69 | {
70 | "size" : "29x29",
71 | "idiom" : "ipad",
72 | "filename" : "Icon-App-29x29@1x.png",
73 | "scale" : "1x"
74 | },
75 | {
76 | "size" : "29x29",
77 | "idiom" : "ipad",
78 | "filename" : "Icon-App-29x29@2x.png",
79 | "scale" : "2x"
80 | },
81 | {
82 | "size" : "40x40",
83 | "idiom" : "ipad",
84 | "filename" : "Icon-App-40x40@1x.png",
85 | "scale" : "1x"
86 | },
87 | {
88 | "size" : "40x40",
89 | "idiom" : "ipad",
90 | "filename" : "Icon-App-40x40@2x.png",
91 | "scale" : "2x"
92 | },
93 | {
94 | "size" : "76x76",
95 | "idiom" : "ipad",
96 | "filename" : "Icon-App-76x76@1x.png",
97 | "scale" : "1x"
98 | },
99 | {
100 | "size" : "76x76",
101 | "idiom" : "ipad",
102 | "filename" : "Icon-App-76x76@2x.png",
103 | "scale" : "2x"
104 | },
105 | {
106 | "size" : "83.5x83.5",
107 | "idiom" : "ipad",
108 | "filename" : "Icon-App-83.5x83.5@2x.png",
109 | "scale" : "2x"
110 | },
111 | {
112 | "size" : "1024x1024",
113 | "idiom" : "ios-marketing",
114 | "filename" : "Icon-App-1024x1024@1x.png",
115 | "scale" : "1x"
116 | }
117 | ],
118 | "info" : {
119 | "version" : 1,
120 | "author" : "xcode"
121 | }
122 | }
123 |
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dreamsoftin/flutter_wordpress/06b429fcd3a3d8d6c7cffc9ae9b0a296bb1047b9/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dreamsoftin/flutter_wordpress/06b429fcd3a3d8d6c7cffc9ae9b0a296bb1047b9/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dreamsoftin/flutter_wordpress/06b429fcd3a3d8d6c7cffc9ae9b0a296bb1047b9/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dreamsoftin/flutter_wordpress/06b429fcd3a3d8d6c7cffc9ae9b0a296bb1047b9/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dreamsoftin/flutter_wordpress/06b429fcd3a3d8d6c7cffc9ae9b0a296bb1047b9/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dreamsoftin/flutter_wordpress/06b429fcd3a3d8d6c7cffc9ae9b0a296bb1047b9/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dreamsoftin/flutter_wordpress/06b429fcd3a3d8d6c7cffc9ae9b0a296bb1047b9/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dreamsoftin/flutter_wordpress/06b429fcd3a3d8d6c7cffc9ae9b0a296bb1047b9/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dreamsoftin/flutter_wordpress/06b429fcd3a3d8d6c7cffc9ae9b0a296bb1047b9/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dreamsoftin/flutter_wordpress/06b429fcd3a3d8d6c7cffc9ae9b0a296bb1047b9/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dreamsoftin/flutter_wordpress/06b429fcd3a3d8d6c7cffc9ae9b0a296bb1047b9/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dreamsoftin/flutter_wordpress/06b429fcd3a3d8d6c7cffc9ae9b0a296bb1047b9/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dreamsoftin/flutter_wordpress/06b429fcd3a3d8d6c7cffc9ae9b0a296bb1047b9/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dreamsoftin/flutter_wordpress/06b429fcd3a3d8d6c7cffc9ae9b0a296bb1047b9/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dreamsoftin/flutter_wordpress/06b429fcd3a3d8d6c7cffc9ae9b0a296bb1047b9/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "LaunchImage.png",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "filename" : "LaunchImage@2x.png",
11 | "scale" : "2x"
12 | },
13 | {
14 | "idiom" : "universal",
15 | "filename" : "LaunchImage@3x.png",
16 | "scale" : "3x"
17 | }
18 | ],
19 | "info" : {
20 | "version" : 1,
21 | "author" : "xcode"
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dreamsoftin/flutter_wordpress/06b429fcd3a3d8d6c7cffc9ae9b0a296bb1047b9/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dreamsoftin/flutter_wordpress/06b429fcd3a3d8d6c7cffc9ae9b0a296bb1047b9/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dreamsoftin/flutter_wordpress/06b429fcd3a3d8d6c7cffc9ae9b0a296bb1047b9/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md:
--------------------------------------------------------------------------------
1 | # Launch Screen Assets
2 |
3 | You can customize the launch screen with your own desired assets by replacing the image files in this directory.
4 |
5 | You can also do it by opening your Flutter project's Xcode project with `open ios/Runner.xcworkspace`, selecting `Runner/Assets.xcassets` in the Project Navigator and dropping in the desired images.
--------------------------------------------------------------------------------
/example/ios/Runner/Base.lproj/LaunchScreen.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/example/ios/Runner/Base.lproj/Main.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/example/ios/Runner/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | example
15 | CFBundlePackageType
16 | APPL
17 | CFBundleShortVersionString
18 | $(FLUTTER_BUILD_NAME)
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | $(FLUTTER_BUILD_NUMBER)
23 | LSRequiresIPhoneOS
24 |
25 | UILaunchStoryboardName
26 | LaunchScreen
27 | UIMainStoryboardFile
28 | Main
29 | UISupportedInterfaceOrientations
30 |
31 | UIInterfaceOrientationPortrait
32 | UIInterfaceOrientationLandscapeLeft
33 | UIInterfaceOrientationLandscapeRight
34 |
35 | UISupportedInterfaceOrientations~ipad
36 |
37 | UIInterfaceOrientationPortrait
38 | UIInterfaceOrientationPortraitUpsideDown
39 | UIInterfaceOrientationLandscapeLeft
40 | UIInterfaceOrientationLandscapeRight
41 |
42 | UIViewControllerBasedStatusBarAppearance
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/example/ios/Runner/Runner-Bridging-Header.h:
--------------------------------------------------------------------------------
1 | #import "GeneratedPluginRegistrant.h"
2 |
--------------------------------------------------------------------------------
/example/ios/Runner/main.m:
--------------------------------------------------------------------------------
1 | #import
2 | #import
3 | #import "AppDelegate.h"
4 |
5 | int main(int argc, char* argv[]) {
6 | @autoreleasepool {
7 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/example/lib/display_posts.dart:
--------------------------------------------------------------------------------
1 | import 'dart:async';
2 |
3 | import 'package:flutter/material.dart';
4 | import 'package:flutter_wordpress/flutter_wordpress.dart' as wp;
5 |
6 | import 'post_page.dart';
7 |
8 | class PostListPage extends StatelessWidget {
9 | final wp.WordPress wordPress;
10 | final wp.User user;
11 |
12 | PostListPage({Key key, @required this.wordPress, this.user});
13 |
14 | @override
15 | Widget build(BuildContext context) {
16 | return Scaffold(
17 | appBar: AppBar(
18 | title: Text("Posts"),
19 | ),
20 | body: Center(
21 | child: PostsBuilder(
22 | wordPress: wordPress,
23 | user: user,
24 | ),
25 | ),
26 | );
27 | }
28 | }
29 |
30 | class PostsBuilder extends StatefulWidget {
31 | final wp.WordPress wordPress;
32 | final wp.User user;
33 |
34 | PostsBuilder({Key key, @required this.wordPress, this.user});
35 |
36 | @override
37 | PostsBuilderState createState() => PostsBuilderState();
38 | }
39 |
40 | class PostsBuilderState extends State {
41 | final paddingCardsList = EdgeInsets.symmetric(vertical: 4.0, horizontal: 8.0);
42 | final padding_4 = EdgeInsets.all(4.0);
43 | final padding_8 = EdgeInsets.all(8.0);
44 | final padding_16 = EdgeInsets.all(16.0);
45 |
46 | Future> posts;
47 |
48 | @override
49 | void initState() {
50 | super.initState();
51 |
52 | fetchPosts();
53 | }
54 |
55 | void createPost({@required wp.User user}) {
56 | final post = widget.wordPress.createPost(
57 | post: new wp.Post(
58 | title: 'First post as a Chief Editor',
59 | content: 'Blah! blah! blah!',
60 | excerpt: 'Discussion about blah!',
61 | authorID: user.id,
62 | commentStatus: wp.PostCommentStatus.open,
63 | pingStatus: wp.PostPingStatus.closed,
64 | status: wp.PostPageStatus.publish,
65 | format: wp.PostFormat.standard,
66 | sticky: true,
67 | ),
68 | );
69 |
70 | post.then((p) {
71 | print('Post created successfully with ID: ${p.id}');
72 | }).catchError((err) {
73 | print('Failed to create post: $err');
74 | });
75 | }
76 |
77 | // yahya
78 |
79 | Future createUser({@required String email, @required String username, @required String password, @required List roles}) async {
80 | await widget.wordPress.createUser(
81 | user: wp.User(
82 | email: email,
83 | password: password,
84 | username: username,
85 | roles: roles
86 | )
87 | ).then((p) {
88 | print('User created successfully ${p}');
89 | }).catchError((err) {
90 | print('Failed to create user: $err');
91 | });
92 | }
93 |
94 | // =====================
95 | // UPDATE START
96 | // =====================
97 |
98 | Future updatePost({@required int id, @required int userId}) async {
99 | await widget.wordPress.updatePost(
100 | post: new wp.Post(
101 | title: 'First post as a Chief Editor',
102 | content: 'Blah! blah! blah!',
103 | excerpt: 'Discussion about blah!',
104 | authorID: userId,
105 | commentStatus: wp.PostCommentStatus.open,
106 | pingStatus: wp.PostPingStatus.closed,
107 | status: wp.PostPageStatus.publish,
108 | format: wp.PostFormat.standard,
109 | sticky: true,
110 | ),
111 | id: id, //
112 | ).then((p) {
113 | print('Post updated successfully with ID ${p}');
114 | }).catchError((err) {
115 | print('Failed to update post: $err');
116 | });
117 | }
118 |
119 | Future updateComment({@required int id, @required int postId, @required wp.User user}) async {
120 | await widget.wordPress.updateComment(
121 | comment: new wp.Comment(
122 | content: "Comment Updated2!",
123 | author: user.id,
124 | post: postId,
125 | ),
126 | id: id,
127 | ).then((c) {
128 | print('Comment updated successfully "$c"');
129 | }).catchError((err) {
130 | print('Failed to update Comment: $err');
131 | });
132 | }
133 |
134 | Future updateUser({@required int id, @required String username, @required String email}) async {
135 | await widget.wordPress.updateUser(
136 | user: new wp.User(
137 | description: "This is description for this user",
138 | username: username,
139 | id: id,
140 | email: email
141 | ),
142 | id: id,
143 | ).then((u) {
144 | print('User updated successfully $u');
145 | }).catchError((err) {
146 | print('Failed to update User: $err');
147 | });
148 | }
149 |
150 | // =====================
151 | // UPDATE END
152 | // =====================
153 |
154 | // =====================
155 | // DELETE START
156 | // =====================
157 |
158 | Future deletePost({@required int id}) async {
159 | await widget.wordPress.deletePost(id: id).then((p) {
160 | print('Post Deleted successfully: $p');
161 | }).catchError((err) {
162 | print('Failed to Delete post: $err');
163 | });
164 | }
165 |
166 | Future deleteComment({@required int id}) async {
167 | await widget.wordPress.deleteComment(id: id).then((c) {
168 | print('Comment Deleted successfully: $c');
169 | }).catchError((err) {
170 | print('Failed to Delete comment: $err');
171 | });
172 | }
173 |
174 | Future deleteUser({@required int id, @required int reassign}) async {
175 | await widget.wordPress.deleteUser(id: id, reassign: reassign).then((u) {
176 | print('User Deleted successfully: $u');
177 | }).catchError((err) {
178 | print('Failed to Delete user: $err');
179 | });
180 | }
181 |
182 | // =====================
183 | // DELETE END
184 | // =====================
185 |
186 | // end yahya
187 |
188 | void createComment({@required int userId, @required int postId}) {
189 | final comment = widget.wordPress.createComment(
190 | comment: new wp.Comment(
191 | author: userId,
192 | post: postId,
193 | content: "First!",
194 | parent: 0,
195 | ),
196 | );
197 |
198 | comment.then((c) {
199 | print('Comment successfully posted with ID: ${c.id}');
200 | }).catchError((err) {
201 | print('Failed to comment: $err');
202 | });
203 | }
204 |
205 | Future fetchPosts() {
206 | setState(() {
207 | posts = widget.wordPress.fetchPosts(
208 | postParams: wp.ParamsPostList(perPage: 1),
209 | fetchAuthor: true,
210 | fetchFeaturedMedia: true,
211 | );
212 | });
213 | return posts;
214 | }
215 |
216 | @override
217 | Widget build(BuildContext context) {
218 | return FutureBuilder>(
219 | future: posts,
220 | builder: (context, snapshot) {
221 | if (snapshot.hasData) {
222 | return RefreshIndicator(
223 | child: ListView.builder(
224 | itemBuilder: (context, i) {
225 | int id = snapshot.data[i].id;
226 | String title = snapshot.data[i].title.rendered;
227 | String author = snapshot.data[i].author.name;
228 | String content = snapshot.data[i].content.rendered;
229 | wp.Media featuredMedia = snapshot.data[i].featuredMedia;
230 |
231 | return Padding(
232 | padding: paddingCardsList,
233 | child: GestureDetector(
234 | onTap: () {
235 | openPostPage(snapshot.data[i]);
236 | },
237 | child: _buildPostCard(
238 | author: author,
239 | title: title,
240 | content: content,
241 | featuredMedia: featuredMedia,
242 | id : id,
243 | ),
244 | ),
245 | );
246 | },
247 | itemCount: snapshot.data.length,
248 | ),
249 | onRefresh: fetchPosts,
250 | );
251 | } else if (snapshot.hasError) {
252 | return Text(
253 | snapshot.error.toString(),
254 | style: TextStyle(color: Colors.red),
255 | );
256 | }
257 |
258 | return CircularProgressIndicator(
259 | valueColor: AlwaysStoppedAnimation(Colors.blue),
260 | );
261 | },
262 | );
263 | }
264 |
265 | Widget _buildPostCard({
266 | String author,
267 | String title,
268 | String content,
269 | wp.Media featuredMedia,
270 | int id,
271 | }) {
272 | return Card(
273 | color: Colors.white,
274 | child: Column(
275 | mainAxisAlignment: MainAxisAlignment.start,
276 | crossAxisAlignment: CrossAxisAlignment.start,
277 | children: [
278 | Padding(
279 | padding: EdgeInsets.symmetric(horizontal: 8.0, vertical: 4.0),
280 | child: Text(
281 | title,
282 | style: Theme.of(context).textTheme.headline6,
283 | ),
284 | ),
285 | _buildFeaturedMedia(featuredMedia),
286 | featuredMedia == null
287 | ? Divider()
288 | : SizedBox(
289 | width: 0,
290 | height: 0,
291 | ),
292 | Padding(
293 | padding: EdgeInsets.symmetric(vertical: 0.0, horizontal: 8.0),
294 | child: Column(
295 | crossAxisAlignment: CrossAxisAlignment.start,
296 | mainAxisAlignment: MainAxisAlignment.start,
297 | children: [
298 | Text(
299 | author,
300 | style: TextStyle(
301 | fontWeight: FontWeight.w200,
302 | ),
303 | ),
304 | ElevatedButton.icon(
305 | onPressed: () {
306 | createComment(postId: 1, userId: 1);
307 | },
308 | icon: Icon(Icons.settings),
309 | label: Text(
310 | "Create New Comment",
311 | ),
312 | ),
313 | ElevatedButton.icon(
314 | onPressed: () {
315 | updateComment(user: widget.user, id: 1, postId: 1);
316 | },
317 | icon: Icon(Icons.settings),
318 | label: Text(
319 | "Update Comment with ID #1",
320 | ),
321 | ),
322 | ElevatedButton.icon(
323 | onPressed: () {
324 | deleteComment(id: 1);
325 | },
326 | icon: Icon(Icons.settings),
327 | label: Text(
328 | "Delete Comment with ID #1",
329 | ),
330 | ),
331 | ElevatedButton.icon(
332 | onPressed: () {
333 | updatePost(userId: widget.user.id, id: 1);
334 | },
335 | icon: Icon(Icons.settings, color: Colors.white),
336 | label: Text(
337 | "Update Post with ID #1",
338 | style: TextStyle(color: Colors.white),
339 | ),
340 | ),
341 | ElevatedButton.icon(
342 | onPressed: () {
343 | deletePost(id: 1);
344 | },
345 | icon: Icon(Icons.delete, color: Colors.white),
346 | label: Text(
347 | "Delete Post with ID #1",
348 | style: TextStyle(color: Colors.white),
349 | ),
350 | ),
351 | ElevatedButton.icon(
352 | onPressed: () {
353 | createPost(user: widget.user);
354 | },
355 | icon: Icon(Icons.add_circle, color: Colors.white,),
356 | label: Text(
357 | "Create New Post",
358 | style: TextStyle(color: Colors.white),
359 | ),
360 | ),
361 | ElevatedButton.icon(
362 | onPressed: () {
363 | createUser(roles: ["subscriber"], username: "myUserName", password: "123", email: "myEmail@domain.com");
364 | },
365 | icon: Icon(Icons.add_circle, color: Colors.white,),
366 | label: Text(
367 | "Create New User",
368 | style: TextStyle(color: Colors.white),
369 | ),
370 | ),
371 | ElevatedButton.icon(
372 | onPressed: () {
373 | updateUser(id: 1, email: "newuser@gmaill.com", username: "newuser");
374 | },
375 | icon: Icon(Icons.settings, color: Colors.white,),
376 | label: Text(
377 | "Update User with ID #1",
378 | style: TextStyle(color: Colors.white),
379 | ),
380 | ),
381 | ElevatedButton.icon(
382 | onPressed: () {
383 | deleteUser(id: 1, reassign: 1);
384 | },
385 | icon: Icon(Icons.delete, color: Colors.white,),
386 | label: Text(
387 | "Delete User with ID #1",
388 | style: TextStyle(color: Colors.white),
389 | ),
390 | )
391 | ],
392 | ),
393 | ),
394 | ],
395 | ),
396 | );
397 | }
398 |
399 | Widget _buildFeaturedMedia(wp.Media featuredMedia) {
400 | if (featuredMedia == null) {
401 | return SizedBox(
402 | width: 0.0,
403 | height: 0.0,
404 | );
405 | }
406 | String imgSource = featuredMedia.mediaDetails.sizes.mediumLarge.sourceUrl;
407 | imgSource = imgSource.replaceAll('localhost', '192.168.6.165');
408 | return Center(
409 | child: Image.network(
410 | imgSource,
411 | fit: BoxFit.cover,
412 | ),
413 | );
414 | }
415 |
416 | void openPostPage(wp.Post post) {
417 | print('OnTapped');
418 | Navigator.push(
419 | context,
420 | MaterialPageRoute(builder: (context) {
421 | return SinglePostPage(
422 | wordPress: widget.wordPress,
423 | post: post,
424 | );
425 | }),
426 | );
427 | }
428 | }
429 |
--------------------------------------------------------------------------------
/example/lib/generated_plugin_registrant.dart:
--------------------------------------------------------------------------------
1 | //
2 | // Generated file. Do not edit.
3 | //
4 |
5 | // ignore_for_file: directives_ordering
6 | // ignore_for_file: lines_longer_than_80_chars
7 |
8 | import 'package:video_player_web/video_player_web.dart';
9 | import 'package:wakelock_web/wakelock_web.dart';
10 |
11 | import 'package:flutter_web_plugins/flutter_web_plugins.dart';
12 |
13 | // ignore: public_member_api_docs
14 | void registerPlugins(Registrar registrar) {
15 | VideoPlayerPlugin.registerWith(registrar);
16 | WakelockWeb.registerWith(registrar);
17 | registrar.registerMessageHandler();
18 | }
19 |
--------------------------------------------------------------------------------
/example/lib/login.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:flutter_wordpress/flutter_wordpress.dart' as wp;
3 |
4 | import 'display_posts.dart';
5 |
6 | const PADDING_16 = EdgeInsets.all(16.0);
7 | const PADDING_8 = EdgeInsets.all(8.0);
8 |
9 | class LoginPage extends StatefulWidget {
10 | @override
11 | LoginPageState createState() => LoginPageState();
12 | }
13 |
14 | class LoginPageState extends State {
15 | @override
16 | Widget build(BuildContext context) {
17 | return Scaffold(
18 | appBar: AppBar(
19 | title: Text(
20 | "Login",
21 | style: TextStyle(fontWeight: FontWeight.w300),
22 | ),
23 | centerTitle: true,
24 | ),
25 | body: LoginFields(),
26 | );
27 | }
28 | }
29 |
30 | class LoginFields extends StatefulWidget {
31 | @override
32 | LoginFieldsState createState() => LoginFieldsState();
33 | }
34 |
35 | class LoginFieldsState extends State {
36 | String _username;
37 | String _password;
38 | bool _isDetailValid = true;
39 | bool _isValidating = false;
40 |
41 | @override
42 | void initState() {
43 | super.initState();
44 | _username = 'YOUR_USERNAME';
45 | _password = 'YOUR_PASSWORD';
46 | }
47 |
48 | @override
49 | Widget build(BuildContext context) {
50 | return Center(
51 | child: SingleChildScrollView(
52 | child: Container(
53 | padding: PADDING_16,
54 | child: Column(
55 | mainAxisAlignment: MainAxisAlignment.center,
56 | crossAxisAlignment: CrossAxisAlignment.center,
57 | children: [
58 | Padding(
59 | padding: PADDING_8,
60 | child: _buildFormField(
61 | icon: Icon(Icons.person),
62 | labelText: "Username",
63 | hintText: "Username",
64 | initialText: _username,
65 | onChanged: _onUsernameChanged,
66 | ),
67 | ),
68 | Padding(
69 | padding: PADDING_8,
70 | child: _buildFormField(
71 | icon: Icon(Icons.lock),
72 | labelText: "Password",
73 | hintText: "Password",
74 | initialText: _password,
75 | obscureText: true,
76 | onChanged: _onPasswordChanged,
77 | ),
78 | ),
79 | _isDetailValid
80 | ? SizedBox(
81 | width: 0.0,
82 | height: 0.0,
83 | )
84 | : Padding(
85 | padding: PADDING_8,
86 | child: Text(
87 | "Invalid Username / Password",
88 | style: TextStyle(
89 | color: Colors.red,
90 | ),
91 | ),
92 | ),
93 | ElevatedButton(
94 | onPressed: _isValidating ? () {} : _validateUser,
95 | child: Padding(
96 | padding: PADDING_8,
97 | child: _isValidating
98 | ? CircularProgressIndicator(
99 | valueColor: AlwaysStoppedAnimation(Colors.white),
100 | )
101 | : Text('Login'),
102 | ),
103 | ),
104 | ],
105 | ),
106 | ),
107 | ));
108 | }
109 |
110 | Widget _buildFormField({
111 | Icon icon,
112 | String labelText,
113 | String hintText,
114 | String initialText,
115 | TextInputType inputType = TextInputType.text,
116 | bool obscureText = false,
117 | onChanged,
118 | }) {
119 | return TextField(
120 | decoration: InputDecoration(
121 | icon: icon,
122 | labelText: labelText,
123 | hintText: hintText,
124 | border: OutlineInputBorder(
125 | borderRadius: BorderRadius.circular(4.0),
126 | ),
127 | ),
128 | controller: TextEditingController(text: initialText),
129 | keyboardType: inputType,
130 | obscureText: obscureText,
131 | onChanged: onChanged,
132 | );
133 | }
134 |
135 | void _onUsernameChanged(String value) {
136 | _username = value;
137 | }
138 |
139 | void _onPasswordChanged(String value) {
140 | _password = value;
141 | }
142 |
143 | void _validateUser() {
144 | setState(() {
145 | _isValidating = true;
146 | });
147 |
148 | wp.WordPress wordPress = new wp.WordPress(
149 | baseUrl: 'YOUR WEBSITE URL',
150 | authenticator: wp.WordPressAuthenticator.JWT,
151 | adminName: '',
152 | adminKey: '',
153 | );
154 |
155 | final response =
156 | wordPress.authenticateUser(username: _username, password: _password);
157 |
158 | response.then((user) {
159 | setState(() {
160 | _isDetailValid = true;
161 | _isValidating = false;
162 |
163 | _onValidUser(wordPress, user);
164 | });
165 | }).catchError((err) {
166 | print(err.toString());
167 | setState(() {
168 | _isDetailValid = false;
169 | _isValidating = false;
170 | });
171 | });
172 | }
173 |
174 | void _onValidUser(wp.WordPress wordPress, wp.User user) {
175 | Navigator.pushReplacement(
176 | context,
177 | MaterialPageRoute(
178 | builder: (context) => PostListPage(
179 | wordPress: wordPress,
180 | user: user,
181 | ),
182 | ),
183 | );
184 | }
185 | }
186 |
--------------------------------------------------------------------------------
/example/lib/main.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'login.dart';
3 |
4 | void main() {
5 | runApp(WordPressApp());
6 | }
7 |
8 | class WordPressApp extends StatelessWidget {
9 | @override
10 | Widget build(BuildContext context) {
11 | return MaterialApp(
12 | debugShowCheckedModeBanner: false,
13 | title: 'WordPress Demo',
14 | theme: ThemeData.light(),
15 | home: LoginPage(),
16 | );
17 | }
18 | }
--------------------------------------------------------------------------------
/example/lib/post_page.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:flutter_html/flutter_html.dart';
3 | import 'package:flutter_wordpress/flutter_wordpress.dart' as wp;
4 |
5 | class SinglePostPage extends StatelessWidget {
6 | final wp.WordPress wordPress;
7 | final wp.Post post;
8 |
9 | SinglePostPage({Key key, @required this.wordPress, @required this.post});
10 |
11 | @override
12 | Widget build(BuildContext context) {
13 | return Scaffold(
14 | appBar: AppBar(
15 | title: Text(post.title.rendered),
16 | ),
17 | body: Padding(
18 | padding: EdgeInsets.all(8.0),
19 | child: PostWithComments(wordPress: wordPress, post: post),
20 | ),
21 | );
22 | }
23 | }
24 |
25 | class PostWithComments extends StatefulWidget {
26 | final wp.WordPress wordPress;
27 | final wp.Post post;
28 |
29 | PostWithComments({@required this.wordPress, @required this.post});
30 |
31 | @override
32 | PostWithCommentsState createState() => PostWithCommentsState();
33 | }
34 |
35 | class PostWithCommentsState extends State {
36 | String _content;
37 |
38 | Future> _comments;
39 |
40 | @override
41 | void initState() {
42 | super.initState();
43 |
44 | _content = widget.post.content.rendered;
45 | _content = _content.replaceAll('localhost', '192.168.6.165');
46 |
47 | fetchComments();
48 | }
49 |
50 | void fetchComments() {
51 | setState(() {
52 | _comments = widget.wordPress.fetchCommentsAsHierarchy(
53 | params: wp.ParamsCommentList(
54 | includePostIDs: [widget.post.id],
55 | ));
56 | });
57 | }
58 |
59 | @override
60 | Widget build(BuildContext context) {
61 | return CustomScrollView(
62 | slivers: [
63 | SliverList(
64 | delegate: SliverChildListDelegate(
65 | [
66 | Html(
67 | data: _content,
68 | // blockSpacing: 0.0,
69 | ),
70 | Divider(),
71 | Row(
72 | children: [
73 | Icon(Icons.comment),
74 | Text('Comments'),
75 | ],
76 | ),
77 | Divider(),
78 | ],
79 | ),
80 | ),
81 | FutureBuilder(
82 | future: _comments,
83 | builder: (context, snapshot) {
84 | return SliverList(
85 | delegate: _buildCommentsSection(snapshot),
86 | );
87 | },
88 | ),
89 | ],
90 | );
91 | }
92 |
93 | SliverChildDelegate _buildCommentsSection(
94 | AsyncSnapshot> snapshot) {
95 | if (snapshot.hasData) {
96 | return _buildComments(snapshot.data);
97 | } else if (snapshot.hasError) {
98 | return SliverChildListDelegate([
99 | Text(
100 | 'Error fetching comments: ${snapshot.error.toString()}',
101 | style: TextStyle(
102 | color: Colors.red,
103 | ),
104 | )
105 | ]);
106 | }
107 |
108 | return SliverChildListDelegate(
109 | [
110 | Center(
111 | child: CircularProgressIndicator(
112 | valueColor: AlwaysStoppedAnimation(Colors.blue),
113 | ),
114 | ),
115 | ],
116 | );
117 | }
118 |
119 | SliverChildBuilderDelegate _buildComments(
120 | List comments) {
121 | return SliverChildBuilderDelegate(
122 | (BuildContext context, int i) {
123 | if (comments == null || comments.length == 0) {
124 | return Center(
125 | child: Padding(
126 | padding: EdgeInsets.all(8.0),
127 | child: Text(
128 | 'No comments',
129 | style: Theme.of(context).textTheme.bodyText1,
130 | ),
131 | ),
132 | );
133 | }
134 |
135 | if (i % 2 != 0) {
136 | return Divider();
137 | }
138 | return _buildCommentTile(comments[(i / 2).ceil()]);
139 | },
140 | childCount:
141 | comments == null || comments.length == 0 ? 1 : comments.length * 2,
142 | );
143 | }
144 |
145 | Widget _buildCommentTile(wp.CommentHierarchy root) {
146 | if (root.children == null) {
147 | return Padding(
148 | padding: EdgeInsets.all(16.0),
149 | child: Column(
150 | crossAxisAlignment: CrossAxisAlignment.start,
151 | children: [
152 | Html(
153 | data: root.comment.content.rendered,
154 | // blockSpacing: 0.0,
155 | ),
156 | Text(
157 | root.comment.authorName,
158 | style: TextStyle(
159 | color: Colors.grey,
160 | fontWeight: FontWeight.w300,
161 | ),
162 | ),
163 | ],
164 | ),
165 | );
166 | } else {
167 | return ExpansionTile(
168 | title: Column(
169 | crossAxisAlignment: CrossAxisAlignment.start,
170 | children: [
171 | Html(
172 | data: root.comment.content.rendered,
173 | // blockSpacing: 0.0,
174 | ),
175 | Text(
176 | root.comment.authorName,
177 | style: TextStyle(
178 | color: Colors.grey,
179 | fontWeight: FontWeight.w300,
180 | ),
181 | ),
182 | ],
183 | ),
184 | children: root.children.map((c) {
185 | return Padding(
186 | padding: EdgeInsets.only(left: 16.0),
187 | child: _buildCommentTile(c),
188 | );
189 | }).toList(),
190 | );
191 | }
192 | }
193 | }
194 |
--------------------------------------------------------------------------------
/example/pubspec.yaml:
--------------------------------------------------------------------------------
1 | name: flutter_wordpress_example
2 | description: Wordpress API testing example.
3 |
4 | # The following defines the version and build number for your application.
5 | # A version number is three numbers separated by dots, like 1.2.43
6 | # followed by an optional build number separated by a +.
7 | # Both the version and the builder number may be overridden in flutter
8 | # build by specifying --build-name and --build-number, respectively.
9 | # Read more about versioning at semver.org.
10 | version: 1.0.0+1
11 | publish_to: none
12 |
13 | environment:
14 | sdk: ">=2.0.0-dev.68.0 <3.0.0"
15 |
16 | dependencies:
17 | flutter_wordpress:
18 | path: ../
19 | flutter:
20 | sdk: flutter
21 | flutter_html: ^2.2.1
22 |
23 | # The following adds the Cupertino Icons font to your application.
24 | # Use with the CupertinoIcons class for iOS style icons.
25 | cupertino_icons: ^1.0.4
26 |
27 | dev_dependencies:
28 | flutter_test:
29 | sdk: flutter
30 |
31 |
32 | # For information on the generic Dart part of this file, see the
33 | # following page: https://www.dartlang.org/tools/pub/pubspec
34 |
35 | # The following section is specific to Flutter.
36 | flutter:
37 |
38 | # The following line ensures that the Material Icons font is
39 | # included with your application, so that you can use the icons in
40 | # the material Icons class.
41 | uses-material-design: true
42 |
43 | # To add assets to your application, add an assets section, like this:
44 | # assets:
45 | # - images/a_dot_burr.jpeg
46 | # - images/a_dot_ham.jpeg
47 |
48 | # An image asset can refer to one or more resolution-specific "variants", see
49 | # https://flutter.io/assets-and-images/#resolution-aware.
50 |
51 | # For details regarding adding assets from package dependencies, see
52 | # https://flutter.io/assets-and-images/#from-packages
53 |
54 | # To add custom fonts to your application, add a fonts section here,
55 | # in this "flutter" section. Each entry in this list should have a
56 | # "family" key with the font family name, and a "fonts" key with a
57 | # list giving the asset and other descriptors for the font. For
58 | # example:
59 | # fonts:
60 | # - family: Schyler
61 | # fonts:
62 | # - asset: fonts/Schyler-Regular.ttf
63 | # - asset: fonts/Schyler-Italic.ttf
64 | # style: italic
65 | # - family: Trajan Pro
66 | # fonts:
67 | # - asset: fonts/TrajanPro.ttf
68 | # - asset: fonts/TrajanPro_Bold.ttf
69 | # weight: 700
70 | #
71 | # For details regarding fonts from package dependencies,
72 | # see https://flutter.io/custom-fonts/#from-packages
73 |
--------------------------------------------------------------------------------
/example/test/widget_test.dart:
--------------------------------------------------------------------------------
1 | // This is a basic Flutter widget test.
2 | //
3 | // To perform an interaction with a widget in your test, use the WidgetTester
4 | // utility that Flutter provides. For example, you can send tap and scroll
5 | // gestures. You can also use WidgetTester to find child widgets in the widget
6 | // tree, read text, and verify that the values of widget properties are correct.
7 |
8 | import 'package:flutter/material.dart';
9 | import 'package:flutter_test/flutter_test.dart';
10 |
11 | import 'package:flutter_wordpress_example/main.dart';
12 |
13 | void main() {
14 | testWidgets('Counter increments smoke test', (WidgetTester tester) async {
15 | // Build our app and trigger a frame.
16 | await tester.pumpWidget(WordPressApp());
17 |
18 | // Verify that our counter starts at 0.
19 | expect(find.text('0'), findsOneWidget);
20 | expect(find.text('1'), findsNothing);
21 |
22 | // Tap the '+' icon and trigger a frame.
23 | await tester.tap(find.byIcon(Icons.add));
24 | await tester.pump();
25 |
26 | // Verify that our counter has incremented.
27 | expect(find.text('0'), findsNothing);
28 | expect(find.text('1'), findsOneWidget);
29 | });
30 | }
31 |
--------------------------------------------------------------------------------
/flutter_wordpress.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/lib/constants.dart:
--------------------------------------------------------------------------------
1 | const URL_JWT_BASE = '/wp-json/jwt-auth/v1';
2 | const URL_WP_BASE = '/wp-json/wp/v2';
3 |
4 | const URL_JWT_TOKEN = '$URL_JWT_BASE/token';
5 | const URL_JWT_TOKEN_VALIDATE = '$URL_JWT_BASE/token/validate';
6 |
7 | const URL_CATEGORIES = '$URL_WP_BASE/categories';
8 | const URL_COMMENTS = '$URL_WP_BASE/comments';
9 | const URL_MEDIA = '$URL_WP_BASE/media';
10 | const URL_PAGES = '$URL_WP_BASE/pages';
11 | const URL_POSTS = '$URL_WP_BASE/posts';
12 | const URL_TAGS = '$URL_WP_BASE/tags';
13 | const URL_USERS = '$URL_WP_BASE/users';
14 | const URL_USER_ME = '$URL_WP_BASE/users/me';
15 |
16 | enum WordPressAuthenticator {
17 | JWT,
18 | ApplicationPasswords,
19 | }
20 | enum WordPressContext { view, embed, edit }
21 |
22 | enum Order {
23 | asc,
24 | desc,
25 | }
26 |
27 | enum PostOrderBy {
28 | author,
29 | date,
30 | id,
31 | include,
32 | modified,
33 | parent,
34 | relevance,
35 | slug,
36 | title,
37 | }
38 | enum PostPageStatus {
39 | publish,
40 | future,
41 | draft,
42 | pending,
43 | private,
44 | }
45 | enum PostCommentStatus {
46 | open,
47 | closed,
48 | }
49 | enum PostPingStatus {
50 | open,
51 | closed,
52 | }
53 | enum PostFormat {
54 | standard,
55 | aside,
56 | chat,
57 | gallery,
58 | link,
59 | image,
60 | quote,
61 | status,
62 | video,
63 | audio,
64 | }
65 |
66 | enum UserOrderBy {
67 | id,
68 | include,
69 | name,
70 | registered_date,
71 | slug,
72 | email,
73 | url,
74 | }
75 |
76 | enum CommentOrderBy {
77 | date,
78 | date_gmt,
79 | id,
80 | include,
81 | post,
82 | parent,
83 | type,
84 | }
85 | enum CommentStatus {
86 | all,
87 | approve,
88 | hold,
89 | spam,
90 | trash,
91 | }
92 | enum CommentType {
93 | comment,
94 | //TODO: Add all comment types
95 | }
96 |
97 | enum CategoryTagOrderBy {
98 | id,
99 | include,
100 | name,
101 | slug,
102 | term_group,
103 | description,
104 | count,
105 | }
106 |
107 | enum PageOrderBy {
108 | author,
109 | date,
110 | id,
111 | include,
112 | modified,
113 | parent,
114 | relevance,
115 | slug,
116 | title,
117 | menu_order,
118 | }
119 |
120 | enum MediaOrderBy {
121 | author,
122 | date,
123 | id,
124 | include,
125 | modified,
126 | parent,
127 | relevance,
128 | slug,
129 | title,
130 | }
131 | enum MediaStatus {
132 | inherit,
133 | publish,
134 | future,
135 | draft,
136 | pending,
137 | private,
138 | }
139 | enum MediaType {
140 | image,
141 | video,
142 | audio,
143 | application,
144 | }
145 |
146 | /// Converts an enum string to enum value name.
147 | String enumStringToName(String enumString) {
148 | return enumString.split('.')[1];
149 | }
150 |
151 | /// Formats a list of [items] to a comma(,) separated string to pass it as a
152 | /// URL parameter.
153 | String listToUrlString(List items) {
154 | if (items.length == 0) return '';
155 |
156 | return items.join(',');
157 | }
158 |
159 | /// Formats a [Map] of parameters to a string of URL friendly parameters.
160 | String constructUrlParams(Map params) {
161 | StringBuffer p = new StringBuffer('/?');
162 | params.forEach((key, value) {
163 | if (value != '') {
164 | p.write('$key=$value');
165 | p.write('&');
166 | }
167 | });
168 | return p.toString();
169 | }
170 |
--------------------------------------------------------------------------------
/lib/requests/params_category_list.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter_wordpress/constants.dart';
2 |
3 | /// This class holds all arguments which can be used to filter Categories when using
4 | /// [WordPress.fetchCategories] method.
5 | ///
6 | /// [List Categories' Arguments](https://developer.wordpress.org/rest-api/reference/categories/#list-categories)
7 | class ParamsCategoryList {
8 | final WordPressContext context;
9 | final int pageNum;
10 | final int perPage;
11 | final String searchQuery;
12 | final List excludeCategoryIDs;
13 | final List includeCategoryIDs;
14 | final Order order;
15 | final CategoryTagOrderBy orderBy;
16 | final bool hideEmpty;
17 | final int? parent;
18 | final int? post;
19 | final String slug;
20 |
21 | ParamsCategoryList({
22 | this.context = WordPressContext.view,
23 | this.pageNum = 1,
24 | this.perPage = 10,
25 | this.searchQuery = '',
26 | this.excludeCategoryIDs = const [],
27 | this.includeCategoryIDs = const [],
28 | this.order = Order.asc,
29 | this.orderBy = CategoryTagOrderBy.name,
30 | this.hideEmpty = false,
31 | this.parent,
32 | this.post,
33 | this.slug = '',
34 | });
35 |
36 | Map toMap() {
37 | return {
38 | 'context': '${enumStringToName(this.context.toString())}',
39 | 'page': '${this.pageNum}',
40 | 'per_page': '${this.perPage}',
41 | 'search': '${this.searchQuery}',
42 | 'exclude': '${listToUrlString(this.excludeCategoryIDs)}',
43 | 'include': '${listToUrlString(this.includeCategoryIDs)}',
44 | 'order': '${enumStringToName(this.order.toString())}',
45 | 'orderby': '${enumStringToName(this.orderBy.toString())}',
46 | 'hide_empty': '${this.hideEmpty}',
47 | 'parent': '${this.parent == null ? '' : this.parent}',
48 | 'post': '${this.post == null ? '' : this.post}',
49 | 'slug': '${this.slug}',
50 | };
51 | }
52 |
53 | ParamsCategoryList copyWith({
54 | int? pageNum,
55 | int? perPage
56 | }) {
57 | return ParamsCategoryList(
58 | context: context,
59 | order: order,
60 | orderBy: orderBy,
61 | pageNum: pageNum ?? this.pageNum,
62 | perPage: perPage ?? this.perPage,
63 | searchQuery: searchQuery,
64 | slug: slug,
65 | excludeCategoryIDs: excludeCategoryIDs,
66 | hideEmpty: hideEmpty,
67 | includeCategoryIDs: includeCategoryIDs,
68 | parent: parent,
69 | post: post
70 | );
71 | }
72 |
73 | @override
74 | String toString() {
75 | return constructUrlParams(toMap());
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/lib/requests/params_comment_list.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter_wordpress/constants.dart';
2 |
3 | /// This class holds all arguments which can be used to filter comments when using
4 | /// [WordPress.fetchComments] method.
5 | ///
6 | /// [List Comments' Arguments](https://developer.wordpress.org/rest-api/reference/comments/#list-comments)
7 | class ParamsCommentList {
8 | final WordPressContext context;
9 | final int pageNum;
10 | final int perPage;
11 | final String searchQuery;
12 | final String afterDate;
13 | final List includeAuthorIDs;
14 | final List excludeAuthorIDs;
15 | final String authorEmail;
16 | final String beforeDate;
17 | final List excludeCommentIDs;
18 | final List includeCommentIDs;
19 | final int? offset;
20 | final Order order;
21 | final CommentOrderBy orderBy;
22 | final List includeParentIDs;
23 | final List excludeParentIDs;
24 | final List includePostIDs;
25 | final CommentStatus commentStatus;
26 | final CommentType commentType;
27 | final String postPassword;
28 |
29 | ParamsCommentList({
30 | this.context = WordPressContext.view,
31 | this.pageNum = 1,
32 | this.perPage = 10,
33 | this.searchQuery = '',
34 | this.afterDate = '',
35 | this.includeAuthorIDs = const [],
36 | this.excludeAuthorIDs = const [],
37 | this.authorEmail = '',
38 | this.beforeDate = '',
39 | this.excludeCommentIDs = const [],
40 | this.includeCommentIDs = const [],
41 | this.offset,
42 | this.order = Order.desc,
43 | this.orderBy = CommentOrderBy.date_gmt,
44 | this.includeParentIDs = const [],
45 | this.excludeParentIDs = const [],
46 | this.includePostIDs = const [],
47 | this.commentStatus = CommentStatus.approve,
48 | this.commentType = CommentType.comment,
49 | this.postPassword = '',
50 | });
51 |
52 | Map toMap() {
53 | return {
54 | 'context': '${enumStringToName(this.context.toString())}',
55 | 'page': '${this.pageNum}',
56 | 'per_page': '${this.perPage}',
57 | 'search': '${this.searchQuery}',
58 | 'after': '${this.afterDate}',
59 | 'author': '${listToUrlString(this.includeAuthorIDs)}',
60 | 'author_exclude': '${listToUrlString(this.excludeAuthorIDs)}',
61 | 'author_email': '${this.authorEmail}',
62 | 'before': '${this.beforeDate}',
63 | 'exclude': '${listToUrlString(excludeCommentIDs)}',
64 | 'include': '${listToUrlString(includeCommentIDs)}',
65 | 'offset': '${this.offset == null ? '' : this.offset}',
66 | 'order': '${enumStringToName(this.order.toString())}',
67 | 'orderby': '${enumStringToName(this.orderBy.toString())}',
68 | 'parent': '${listToUrlString(this.includeParentIDs)}',
69 | 'parent_exclude': '${listToUrlString(this.excludeParentIDs)}',
70 | 'post': '${listToUrlString(this.includePostIDs)}',
71 | 'status': '${enumStringToName(this.commentStatus.toString())}',
72 | 'type': '${enumStringToName(this.commentType.toString())}',
73 | 'password': '${this.postPassword}',
74 | };
75 | }
76 |
77 | @override
78 | String toString() {
79 | return constructUrlParams(toMap());
80 | }
81 | }
82 |
--------------------------------------------------------------------------------
/lib/requests/params_media_list.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter_wordpress/constants.dart';
2 |
3 | /// This class holds all arguments which can be used to filter media when using
4 | /// [WordPress.fetchMediaList] method.
5 | ///
6 | /// [List Media Arguments](https://developer.wordpress.org/rest-api/reference/media/#list-media)
7 | class ParamsMediaList {
8 | final WordPressContext context;
9 | final int pageNum;
10 | final int perPage;
11 | final String searchQuery;
12 | final String afterDate;
13 | final List includeAuthorIDs;
14 | final List excludeAuthorIDs;
15 | final String beforeDate;
16 | final List excludeMediaIDs;
17 | final List includeMediaIDs;
18 | final int? offset;
19 | final Order order;
20 | final MediaOrderBy orderBy;
21 | final List includeParentIDs;
22 | final List excludeParentIDs;
23 | final String slug;
24 | final MediaStatus mediaStatus;
25 | final MediaType? mediaType;
26 | final String mimeType;
27 |
28 | ParamsMediaList({
29 | this.context = WordPressContext.view,
30 | this.pageNum = 1,
31 | this.perPage = 10,
32 | this.searchQuery = '',
33 | this.afterDate = '',
34 | this.includeAuthorIDs = const [],
35 | this.excludeAuthorIDs = const [],
36 | this.beforeDate = '',
37 | this.excludeMediaIDs = const [],
38 | this.includeMediaIDs = const [],
39 | this.offset,
40 | this.order = Order.desc,
41 | this.orderBy = MediaOrderBy.date,
42 | this.excludeParentIDs = const [],
43 | this.includeParentIDs = const [],
44 | this.slug = '',
45 | this.mediaStatus = MediaStatus.inherit,
46 | this.mediaType,
47 | this.mimeType = '',
48 | });
49 |
50 | Map toMap() {
51 | return {
52 | 'context': '${enumStringToName(this.context.toString())}',
53 | 'page': '${this.pageNum}',
54 | 'per_page': '${this.perPage}',
55 | 'search': '${this.searchQuery}',
56 | 'after': '${this.afterDate}',
57 | 'author': '${listToUrlString(this.includeAuthorIDs)}',
58 | 'author_exclude': '${listToUrlString(this.excludeAuthorIDs)}',
59 | 'before': '${this.beforeDate}',
60 | 'exclude': '${listToUrlString(excludeMediaIDs)}',
61 | 'include': '${listToUrlString(includeMediaIDs)}',
62 | 'offset': '${this.offset == null ? '' : this.offset}',
63 | 'order': '${enumStringToName(this.order.toString())}',
64 | 'orderby': '${enumStringToName(this.orderBy.toString())}',
65 | 'parent': '${listToUrlString(includeParentIDs)}',
66 | 'parent_exclude': '${listToUrlString(excludeParentIDs)}',
67 | 'slug': '${this.slug}',
68 | 'status': '${enumStringToName(this.mediaStatus.toString())}',
69 | 'media_type':
70 | '${this.mediaType == null ? '' : enumStringToName(this.mediaType.toString())}',
71 | 'mime_type': '${this.mimeType}',
72 | };
73 | }
74 |
75 | @override
76 | String toString() {
77 | return constructUrlParams(toMap());
78 | }
79 | }
80 |
--------------------------------------------------------------------------------
/lib/requests/params_page_list.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter_wordpress/constants.dart';
2 |
3 | /// This class holds all arguments which can be used to filter pages when using
4 | /// [WordPress.fetchPages] method.
5 | ///
6 | /// [List Pages' Arguments](https://developer.wordpress.org/rest-api/reference/pages/#list-pages)
7 | class ParamsPageList {
8 | final WordPressContext context;
9 | final int pageNum;
10 | final int perPage;
11 | final String searchQuery;
12 | final String afterDate;
13 | final List includeAuthorIDs;
14 | final List excludeAuthorIDs;
15 | final String beforeDate;
16 | final List excludePageIDs;
17 | final List includePageIDs;
18 | final int? menuOrder;
19 | final int? offset;
20 | final Order order;
21 | final PageOrderBy orderBy;
22 | final List includeParentIDs;
23 | final List excludeParentIDs;
24 | final String slug;
25 | final PostPageStatus pageStatus;
26 |
27 | ParamsPageList({
28 | this.context = WordPressContext.view,
29 | this.pageNum = 1,
30 | this.perPage = 10,
31 | this.searchQuery = '',
32 | this.afterDate = '',
33 | this.includeAuthorIDs = const [],
34 | this.excludeAuthorIDs = const [],
35 | this.beforeDate = '',
36 | this.excludePageIDs = const [],
37 | this.includePageIDs = const [],
38 | this.menuOrder,
39 | this.offset,
40 | this.order = Order.desc,
41 | this.orderBy = PageOrderBy.date,
42 | this.includeParentIDs = const [],
43 | this.excludeParentIDs = const [],
44 | this.slug = '',
45 | this.pageStatus = PostPageStatus.publish,
46 | });
47 |
48 | Map toMap() {
49 | return {
50 | 'context': '${enumStringToName(this.context.toString())}',
51 | 'page': '${this.pageNum}',
52 | 'per_page': '${this.perPage}',
53 | 'search': '${this.searchQuery}',
54 | 'after': '${this.afterDate}',
55 | 'author': '${listToUrlString(this.includeAuthorIDs)}',
56 | 'author_exclude': '${listToUrlString(this.excludeAuthorIDs)}',
57 | 'before': '${this.beforeDate}',
58 | 'exclude': '${listToUrlString(excludePageIDs)}',
59 | 'include': '${listToUrlString(includePageIDs)}',
60 | 'menu_order': '${this.menuOrder == null ? '' : this.menuOrder}',
61 | 'offset': '${this.offset == null ? '' : this.offset}',
62 | 'order': '${enumStringToName(this.order.toString())}',
63 | 'orderby': '${enumStringToName(this.orderBy.toString())}',
64 | 'parent': '${listToUrlString(includeParentIDs)}',
65 | 'parent_exclude': '${listToUrlString(excludeParentIDs)}',
66 | 'slug': '${this.slug}',
67 | 'status': '${enumStringToName(this.pageStatus.toString())}',
68 | };
69 | }
70 |
71 | @override
72 | String toString() {
73 | return constructUrlParams(toMap());
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/lib/requests/params_post_list.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter_wordpress/constants.dart';
2 |
3 | /// This class holds all arguments which can be used to filter posts when using
4 | /// [WordPress.fetchPosts] method.
5 | ///
6 | /// [List Posts' Arguments](https://developer.wordpress.org/rest-api/reference/posts/#list-posts)
7 | class ParamsPostList {
8 | final WordPressContext context;
9 | final int pageNum;
10 | final int perPage;
11 | final String searchQuery;
12 | final String afterDate;
13 | final String beforeDate;
14 | final List includeAuthorIDs;
15 | final List excludeAuthorIDs;
16 | final List includePostIDs;
17 | final List excludePostIDs;
18 | final int? offset;
19 | final Order order;
20 | final PostOrderBy orderBy;
21 | final String slug;
22 | final PostPageStatus postStatus;
23 | final List includeCategories;
24 | final List excludeCategories;
25 | final List includeTags;
26 | final List excludeTags;
27 | final bool? sticky;
28 |
29 | ParamsPostList({
30 | this.context = WordPressContext.view,
31 | this.pageNum = 1,
32 | this.perPage = 10,
33 | this.searchQuery = '',
34 | this.afterDate = '',
35 | this.beforeDate = '',
36 | this.includeAuthorIDs = const [],
37 | this.excludeAuthorIDs = const [],
38 | this.includePostIDs = const [],
39 | this.excludePostIDs = const [],
40 | this.offset,
41 | this.order = Order.desc,
42 | this.orderBy = PostOrderBy.date,
43 | this.slug = '',
44 | this.postStatus = PostPageStatus.publish,
45 | this.includeCategories = const [],
46 | this.excludeCategories = const [],
47 | this.includeTags = const [],
48 | this.excludeTags = const [],
49 | this.sticky,
50 | });
51 |
52 | Map toMap() {
53 | return {
54 | 'context': '${enumStringToName(this.context.toString())}',
55 | 'page': '${this.pageNum}',
56 | 'per_page': '${this.perPage}',
57 | 'search': '${this.searchQuery}',
58 | 'after': '${this.afterDate}',
59 | 'before': '${this.beforeDate}',
60 | 'author': '${listToUrlString(this.includeAuthorIDs)}',
61 | 'author_exclude': '${listToUrlString(this.excludeAuthorIDs)}',
62 | 'include': '${listToUrlString(includePostIDs)}',
63 | 'exclude': '${listToUrlString(excludePostIDs)}',
64 | 'offset': '${this.offset == null ? '' : this.offset}',
65 | 'order': '${enumStringToName(this.order.toString())}',
66 | 'orderby': '${enumStringToName(this.orderBy.toString())}',
67 | 'slug': '${this.slug}',
68 | 'status': '${enumStringToName(this.postStatus.toString())}',
69 | 'categories': '${listToUrlString(includeCategories)}',
70 | 'categories_exclude': '${listToUrlString(excludeCategories)}',
71 | 'tags': '${listToUrlString(includeTags)}',
72 | 'tags_exclude': '${listToUrlString(excludeTags)}',
73 | 'sticky': '${this.sticky == null ? '' : this.sticky}',
74 | };
75 | }
76 |
77 | ParamsPostList copyWith({
78 | int? pageNum,
79 | int? perPage,
80 | }) {
81 | return ParamsPostList(
82 | afterDate: afterDate,
83 | beforeDate: beforeDate,
84 | context: context,
85 | excludeAuthorIDs: excludeAuthorIDs,
86 | excludeCategories: excludeCategories,
87 | excludePostIDs: excludePostIDs,
88 | excludeTags: excludeTags,
89 | includeAuthorIDs: includeAuthorIDs,
90 | includeCategories: includeCategories,
91 | includePostIDs: includePostIDs,
92 | includeTags: includeTags,
93 | offset: offset,
94 | order: order,
95 | orderBy: orderBy,
96 | pageNum: pageNum ?? this.pageNum,
97 | perPage: perPage ?? this.perPage,
98 | postStatus: postStatus,
99 | searchQuery: searchQuery,
100 | slug: slug,
101 | sticky: sticky
102 | );
103 | }
104 |
105 | @override
106 | String toString() {
107 | return constructUrlParams(toMap());
108 | }
109 | }
110 |
--------------------------------------------------------------------------------
/lib/requests/params_tag_list.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter_wordpress/constants.dart';
2 |
3 | /// This class holds all arguments which can be used to filter Tags when using
4 | /// [WordPress.fetchTags] method.
5 | ///
6 | /// [List Tags' Arguments](https://developer.wordpress.org/rest-api/reference/tags/#list-tags)
7 | class ParamsTagList {
8 | final WordPressContext context;
9 | final int pageNum;
10 | final int perPage;
11 | final String searchQuery;
12 | final List excludeTagIDs;
13 | final List includeTagIDs;
14 | final Order order;
15 | final CategoryTagOrderBy orderBy;
16 | final bool? hideEmpty;
17 | final int? post;
18 | final String slug;
19 |
20 | ParamsTagList({
21 | this.context = WordPressContext.view,
22 | this.pageNum = 1,
23 | this.perPage = 10,
24 | this.searchQuery = '',
25 | this.excludeTagIDs = const [],
26 | this.includeTagIDs = const [],
27 | this.order = Order.asc,
28 | this.orderBy = CategoryTagOrderBy.name,
29 | this.hideEmpty,
30 | this.post,
31 | this.slug = '',
32 | });
33 |
34 | Map toMap() {
35 | return {
36 | 'context': '${enumStringToName(this.context.toString())}',
37 | 'page': '${this.pageNum}',
38 | 'per_page': '${this.perPage}',
39 | 'search': '${this.searchQuery}',
40 | 'exclude': '${listToUrlString(this.excludeTagIDs)}',
41 | 'include': '${listToUrlString(this.includeTagIDs)}',
42 | 'order': '${enumStringToName(this.order.toString())}',
43 | 'orderby': '${enumStringToName(this.orderBy.toString())}',
44 | 'hide_empty': '${this.hideEmpty == null ? '' : this.hideEmpty}',
45 | 'post': '${this.post == null ? '' : this.post}',
46 | 'slug': '${this.slug}',
47 | };
48 | }
49 |
50 | @override
51 | String toString() {
52 | return constructUrlParams(toMap());
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/lib/requests/params_user_list.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter_wordpress/constants.dart';
2 |
3 | /// This class holds all arguments which can be used to filter users when using
4 | /// [WordPress.fetchUsers] method.
5 | ///
6 | /// [List Users' Arguments](https://developer.wordpress.org/rest-api/reference/users/#list-users)
7 | class ParamsUserList {
8 | final WordPressContext context;
9 | final int pageNum;
10 | final int perPage;
11 | final String searchQuery;
12 | final List includeUserIDs;
13 | final List excludeUserIDs;
14 | final int? offset;
15 | final Order order;
16 | final UserOrderBy orderBy;
17 | final String slug;
18 | final List roles;
19 |
20 | ParamsUserList({
21 | this.context = WordPressContext.view,
22 | this.pageNum = 1,
23 | this.perPage = 10,
24 | this.searchQuery = '',
25 | this.includeUserIDs = const [],
26 | this.excludeUserIDs = const [],
27 | this.offset,
28 | this.order = Order.asc,
29 | this.orderBy = UserOrderBy.name,
30 | this.slug = '',
31 | this.roles = const [],
32 | });
33 |
34 | Map toMap() {
35 | return {
36 | 'context': '${enumStringToName(this.context.toString())}',
37 | 'page': '${this.pageNum}',
38 | 'per_page': '${this.perPage}',
39 | 'search': '${this.searchQuery}',
40 | 'include': '${listToUrlString(this.includeUserIDs)}',
41 | 'exclude': '${listToUrlString(this.excludeUserIDs)}',
42 | 'offset': '${this.offset == null ? '' : this.offset}',
43 | 'order': '${enumStringToName(this.order.toString())}',
44 | 'orderby': '${enumStringToName(this.orderBy.toString())}',
45 | 'slug': '${this.slug}',
46 | 'roles': '${listToUrlString(this.roles)}',
47 | };
48 | }
49 |
50 | @override
51 | String toString() {
52 | return constructUrlParams(toMap());
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/lib/schemas/avatar_urls.dart:
--------------------------------------------------------------------------------
1 | class AvatarUrls {
2 | String? s24;
3 | String? s48;
4 | String? s96;
5 |
6 | AvatarUrls({
7 | this.s24,
8 | this.s48,
9 | this.s96,
10 | });
11 |
12 | AvatarUrls.fromJson(Map json) {
13 | s24 = json['24'];
14 | s48 = json['48'];
15 | s96 = json['96'];
16 | }
17 |
18 | Map toJson() {
19 | final Map data = new Map();
20 |
21 | data['24'] = this.s24;
22 | data['48'] = this.s48;
23 | data['96'] = this.s96;
24 |
25 | return data;
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/lib/schemas/capabilities.dart:
--------------------------------------------------------------------------------
1 | class Capabilities {
2 | String? manageTerms;
3 | String? editTerms;
4 | String? deleteTerms;
5 | String? assignTerms;
6 | String? editPost;
7 | String? readPost;
8 | String? deletePost;
9 | String? editPosts;
10 | String? editOthersPosts;
11 | String? publishPosts;
12 | String? readPrivatePosts;
13 | String? read;
14 | String? deletePosts;
15 | String? deletePrivatePosts;
16 | String? deletePublishedPosts;
17 | String? deleteOthersPosts;
18 | String? editPrivatePosts;
19 | String? editPublishedPosts;
20 | String? createPosts;
21 |
22 | Capabilities({
23 | this.manageTerms,
24 | this.editTerms,
25 | this.deleteTerms,
26 | this.assignTerms,
27 | this.editPost,
28 | this.readPost,
29 | this.deletePost,
30 | this.editPosts,
31 | this.editOthersPosts,
32 | this.publishPosts,
33 | this.readPrivatePosts,
34 | this.read,
35 | this.deletePosts,
36 | this.deletePrivatePosts,
37 | this.deletePublishedPosts,
38 | this.deleteOthersPosts,
39 | this.editPrivatePosts,
40 | this.editPublishedPosts,
41 | this.createPosts,
42 | });
43 |
44 | Capabilities.fromJson(Map json) {
45 | manageTerms = json['manage_terms'];
46 | editTerms = json['edit_terms'];
47 | deleteTerms = json['delete_terms'];
48 | assignTerms = json['assign_terms'];
49 | editPost = json['edit_post'];
50 | readPost = json['read_post'];
51 | deletePost = json['delete_post'];
52 | editPosts = json['edit_posts'];
53 | editOthersPosts = json['edit_others_posts'];
54 | publishPosts = json['publish_posts'];
55 | readPrivatePosts = json['read_private_posts'];
56 | read = json['read'];
57 | deletePosts = json['delete_posts'];
58 | deletePrivatePosts = json['delete_private_posts'];
59 | deletePublishedPosts = json['delete_published_posts'];
60 | deleteOthersPosts = json['delete_others_posts'];
61 | editPrivatePosts = json['edit_private_posts'];
62 | editPublishedPosts = json['edit_published_posts'];
63 | createPosts = json['create_posts'];
64 | }
65 |
66 | Map toJson() {
67 | final Map data = new Map();
68 |
69 | data['manage_terms'] = this.manageTerms;
70 | data['edit_terms'] = this.editTerms;
71 | data['delete_terms'] = this.deleteTerms;
72 | data['assign_terms'] = this.assignTerms;
73 | data['edit_post'] = this.editPost;
74 | data['read_post'] = this.readPost;
75 | data['delete_post'] = this.deletePost;
76 | data['edit_posts'] = this.editPosts;
77 | data['edit_others_posts'] = this.editOthersPosts;
78 | data['publish_posts'] = this.publishPosts;
79 | data['read_private_posts'] = this.readPrivatePosts;
80 | data['read'] = this.read;
81 | data['delete_posts'] = this.deletePosts;
82 | data['delete_private_posts'] = this.deletePrivatePosts;
83 | data['delete_published_posts'] = this.deletePublishedPosts;
84 | data['delete_others_posts'] = this.deleteOthersPosts;
85 | data['edit_private_posts'] = this.editPrivatePosts;
86 | data['edit_published_posts'] = this.editPublishedPosts;
87 | data['create_posts'] = this.createPosts;
88 |
89 | return data;
90 | }
91 | }
92 |
--------------------------------------------------------------------------------
/lib/schemas/category.dart:
--------------------------------------------------------------------------------
1 | import 'links.dart';
2 |
3 | class Category {
4 | int? id;
5 | int? count;
6 | String? description;
7 | String? link;
8 | String? name;
9 | String? slug;
10 | String? taxonomy;
11 | int? parent;
12 | Links? lLinks;
13 |
14 | Category({
15 | this.id,
16 | this.count,
17 | this.description,
18 | this.link,
19 | this.name,
20 | this.slug,
21 | this.taxonomy,
22 | this.parent,
23 | this.lLinks,
24 | });
25 |
26 | Category.fromJson(Map json) {
27 | id = json['id'];
28 | count = json['count'];
29 | description = json['description'];
30 | link = json['link'];
31 | name = json['name'];
32 | slug = json['slug'];
33 | taxonomy = json['taxonomy'];
34 | parent = json['parent'];
35 | lLinks = json['_links'] != null ? new Links.fromJson(json['_links']) : null;
36 | }
37 |
38 | Map toJson() {
39 | final Map data = new Map();
40 |
41 | data['id'] = this.id;
42 | data['count'] = this.count;
43 | data['description'] = this.description;
44 | data['link'] = this.link;
45 | data['name'] = this.name;
46 | data['slug'] = this.slug;
47 | data['taxonomy'] = this.taxonomy;
48 | data['parent'] = this.parent;
49 | data['_links'] = this.lLinks?.toJson();
50 |
51 | return data;
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/lib/schemas/comment.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter_wordpress/constants.dart';
2 |
3 | import 'avatar_urls.dart';
4 | import 'content.dart';
5 | import 'links.dart';
6 |
7 | /// A [WordPress Comment](https://developer.wordpress.org/rest-api/reference/comments/)
8 | ///
9 | /// Refer the above link to see which arguments are set based on different
10 | /// context modes ([WordPressContext]).
11 | class Comment {
12 | /// ID of the comment.
13 | int? id;
14 |
15 | /// ID of the post on which to comment.
16 | int? post;
17 |
18 | /// ID of the parent comment in case of reply.
19 | /// This should be 0 in case of a new comment.
20 | int? parent;
21 |
22 | /// ID of the author who is going to comment.
23 | int? author;
24 | String? authorName;
25 | String? authorEmail;
26 | String? authorUrl;
27 | String? authorIp;
28 | String? authorUserAgent;
29 |
30 | /// The date the comment was written, in the site's timezone.
31 | String? date;
32 |
33 | /// The date the comment was written, in GMT.
34 | String? dateGmt;
35 |
36 | /// Content of the comment.
37 | Content? content;
38 | String? link;
39 |
40 | /// This can only be set by an editor/administrator.
41 | CommentStatus? status;
42 |
43 | /// This can only be set by an editor/administrator.
44 | CommentType? type;
45 | AvatarUrls? authorAvatarUrls;
46 | Links? lLinks;
47 |
48 | Comment({
49 | required this.author,
50 | required this.post,
51 | required String content,
52 | this.authorEmail,
53 | this.authorIp,
54 | this.authorName,
55 | this.authorUrl,
56 | this.authorUserAgent,
57 | this.date,
58 | this.dateGmt,
59 | this.parent = 0,
60 | this.status,
61 | }) : content = new Content(rendered: content);
62 |
63 | Comment.fromJson(Map json) {
64 | id = json['id'];
65 | post = json['post'];
66 | parent = json['parent'];
67 | author = json['author'];
68 | authorName = json['author_name'];
69 | authorEmail = json['author_email'];
70 | authorUrl = json['author_url'];
71 | authorIp = json['author_ip'];
72 | authorUserAgent = json['author_user_agent'];
73 | date = json['date'];
74 | dateGmt = json['date_gmt'];
75 | content = (json['content'] != null
76 | ? new Content.fromJson(json['content']!)
77 | : null)!;
78 | link = json['link'];
79 | if (json['status'] != null) {
80 | CommentStatus.values.forEach((val) {
81 | if (enumStringToName(val.toString()) == json['status']) {
82 | status = val;
83 | return;
84 | }
85 | });
86 | }
87 | if (json['type'] != null) {
88 | CommentType.values.forEach((val) {
89 | if (enumStringToName(val.toString()) == json['type']) {
90 | type = val;
91 | return;
92 | }
93 | });
94 | }
95 | authorAvatarUrls = json['author_avatar_urls'] != null
96 | ? new AvatarUrls.fromJson(json['author_avatar_urls'])
97 | : null;
98 | lLinks = json['_links'] != null ? new Links.fromJson(json['_links']) : null;
99 | }
100 |
101 | Map toJson() {
102 | final Map data = new Map();
103 |
104 | data['post'] = this.post;
105 | data['parent'] = this.parent;
106 | data['author'] = this.author;
107 | data['author_name'] = this.authorName;
108 | data['author_email'] = this.authorEmail;
109 | data['author_url'] = this.authorUrl;
110 | data['author_ip'] = this.authorIp;
111 | data['author_user_agent'] = this.authorUserAgent;
112 | data['date'] = this.date;
113 | data['date_gmt'] = this.dateGmt;
114 | data['content'] = this.content?.toJson();
115 | data['status'] = enumStringToName(this.status.toString());
116 |
117 | return data;
118 | }
119 |
120 | @override
121 | String toString() {
122 | return 'Comment: {id: $id, author: $authorName, post: $post, parent: $parent}';
123 | }
124 | }
125 |
--------------------------------------------------------------------------------
/lib/schemas/comment_hierarchy.dart:
--------------------------------------------------------------------------------
1 | import 'comment.dart';
2 |
3 | /// This class is used to store comments as a hierarchy.
4 | class CommentHierarchy {
5 | /// Parent comment.
6 | final Comment comment;
7 |
8 | /// Replies to the parent comment.
9 | final List? children;
10 |
11 | CommentHierarchy({
12 | required this.comment,
13 | this.children,
14 | });
15 |
16 | @override
17 | String toString() {
18 | return '$comment, children: [$children]';
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/lib/schemas/content.dart:
--------------------------------------------------------------------------------
1 | class Content {
2 | String? raw;
3 | String? rendered;
4 | bool? protected;
5 | int? blockVersion;
6 |
7 | Content({this.rendered});
8 |
9 | Content.fromJson(Map json) {
10 | raw = json['raw'];
11 | rendered = json['rendered'];
12 | protected = json['protected'];
13 | blockVersion = json['block_version'];
14 | }
15 |
16 | Map toJson() {
17 | final Map data = new Map();
18 |
19 | data['raw'] = this.raw;
20 | data['rendered'] = this.rendered;
21 | data['protected'] = this.protected;
22 | data['block_version'] = this.blockVersion;
23 |
24 | return data;
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/lib/schemas/excerpt.dart:
--------------------------------------------------------------------------------
1 | class Excerpt {
2 | String? raw;
3 | String? rendered;
4 | bool? protected;
5 |
6 | Excerpt({this.rendered});
7 |
8 | Excerpt.fromJson(Map json) {
9 | raw = json['raw'];
10 | rendered = json['rendered'];
11 | protected = json['protected'];
12 | }
13 |
14 | Map toJson() {
15 | final Map data = new Map();
16 |
17 | data['raw'] = this.raw;
18 | data['rendered'] = this.rendered;
19 | data['protected'] = this.protected;
20 |
21 | return data;
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/lib/schemas/fetch_user_result.dart:
--------------------------------------------------------------------------------
1 | import 'user.dart';
2 |
3 | class FetchUsersResult {
4 | List users = const [];
5 | int? totalUsers;
6 |
7 | FetchUsersResult(List users, int totalUsers) {
8 | this.users = users;
9 | this.totalUsers = totalUsers;
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/lib/schemas/guid.dart:
--------------------------------------------------------------------------------
1 | class Guid {
2 | String? rendered;
3 | String? raw;
4 |
5 | Guid.fromJson(Map json) {
6 | rendered = json['rendered'];
7 | raw = json['raw'];
8 | }
9 |
10 | Map toJson() {
11 | final Map data = new Map();
12 |
13 | data['rendered'] = this.rendered;
14 | data['raw'] = this.raw;
15 |
16 | return data;
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/lib/schemas/jwt_response.dart:
--------------------------------------------------------------------------------
1 | class JWTResponse {
2 | String? token;
3 | String? userEmail;
4 | String? userNicename;
5 | String? userDisplayName;
6 |
7 | JWTResponse({
8 | this.token,
9 | this.userEmail,
10 | this.userNicename,
11 | this.userDisplayName,
12 | });
13 |
14 | JWTResponse.fromJson(Map json) {
15 | token = json['token'];
16 | userEmail = json['user_email'];
17 | userNicename = json['user_nicename'];
18 | userDisplayName = json['user_display_name'];
19 | }
20 |
21 | Map toJson() {
22 | final Map data = new Map();
23 |
24 | data['token'] = this.token;
25 | data['user_email'] = this.userEmail;
26 | data['user_nicename'] = this.userNicename;
27 | data['user_display_name'] = this.userDisplayName;
28 |
29 | return data;
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/lib/schemas/labels.dart:
--------------------------------------------------------------------------------
1 | class Labels {
2 | String? name;
3 | String? singularName;
4 | String? searchItems;
5 | String? popularItems;
6 | String? allItems;
7 | String? parentItem;
8 | String? parentItemColon;
9 | String? addNew;
10 | String? addNewItem;
11 | String? editItem;
12 | String? newItem;
13 | String? viewItem;
14 | String? viewItems;
15 | String? notFound;
16 | String? notFoundInTrash;
17 | String? archives;
18 | String? attributes;
19 | String? insertIntoItem;
20 | String? uploadedToThisItem;
21 | String? featuredImage;
22 | String? setFeaturedImage;
23 | String? removeFeaturedImage;
24 | String? useFeaturedImage;
25 | String? filterItemsList;
26 | String? itemsListNavigation;
27 | String? itemsList;
28 | String? itemPublished;
29 | String? itemPublishedPrivately;
30 | String? itemRevertedToDraft;
31 | String? itemScheduled;
32 | String? itemUpdated;
33 | String? menuName;
34 | String? nameAdminBar;
35 | String? updateItem;
36 | String? newItemName;
37 | String? separateItemsWithCommas;
38 | String? addOrRemoveItems;
39 | String? chooseFromMostUsed;
40 | String? noTerms;
41 | String? mostUsed;
42 | String? backToItems;
43 |
44 | Labels({
45 | this.name,
46 | this.singularName,
47 | this.searchItems,
48 | this.popularItems,
49 | this.allItems,
50 | this.parentItem,
51 | this.parentItemColon,
52 | this.addNew,
53 | this.addNewItem,
54 | this.editItem,
55 | this.newItem,
56 | this.viewItem,
57 | this.viewItems,
58 | this.notFound,
59 | this.notFoundInTrash,
60 | this.archives,
61 | this.attributes,
62 | this.insertIntoItem,
63 | this.uploadedToThisItem,
64 | this.featuredImage,
65 | this.setFeaturedImage,
66 | this.removeFeaturedImage,
67 | this.useFeaturedImage,
68 | this.filterItemsList,
69 | this.itemsListNavigation,
70 | this.itemsList,
71 | this.itemPublished,
72 | this.itemPublishedPrivately,
73 | this.itemRevertedToDraft,
74 | this.itemScheduled,
75 | this.itemUpdated,
76 | this.menuName,
77 | this.nameAdminBar,
78 | this.updateItem,
79 | this.newItemName,
80 | this.separateItemsWithCommas,
81 | this.addOrRemoveItems,
82 | this.chooseFromMostUsed,
83 | this.noTerms,
84 | this.mostUsed,
85 | this.backToItems,
86 | });
87 |
88 | Labels.fromJson(Map json) {
89 | name = json['name'];
90 | singularName = json['singular_name'];
91 | searchItems = json['search_items'];
92 | popularItems = json['popular_items'];
93 | allItems = json['all_items'];
94 | parentItem = json['parent_item'];
95 | parentItemColon = json['parent_item_colon'];
96 | addNew = json['add_new'];
97 | addNewItem = json['add_new_item'];
98 | editItem = json['edit_item'];
99 | newItem = json['new_item'];
100 | viewItem = json['view_item'];
101 | viewItems = json['view_items'];
102 | notFound = json['not_found'];
103 | notFoundInTrash = json['not_found_in_trash'];
104 | archives = json['archives'];
105 | attributes = json['attributes'];
106 | insertIntoItem = json['insert_into_item'];
107 | uploadedToThisItem = json['uploaded_to_this_item'];
108 | featuredImage = json['featured_image'];
109 | setFeaturedImage = json['set_featured_image'];
110 | removeFeaturedImage = json['remove_featured_image'];
111 | useFeaturedImage = json['use_featured_image'];
112 | filterItemsList = json['filter_items_list'];
113 | itemsListNavigation = json['items_list_navigation'];
114 | itemsList = json['items_list'];
115 | itemPublished = json['item_published'];
116 | itemPublishedPrivately = json['item_published_privately'];
117 | itemRevertedToDraft = json['item_reverted_to_draft'];
118 | itemScheduled = json['item_scheduled'];
119 | itemUpdated = json['item_updated'];
120 | menuName = json['menu_name'];
121 | nameAdminBar = json['name_admin_bar'];
122 | updateItem = json['update_item'];
123 | newItemName = json['new_item_name'];
124 | separateItemsWithCommas = json['separate_items_with_commas'];
125 | addOrRemoveItems = json['add_or_remove_items'];
126 | chooseFromMostUsed = json['choose_from_most_used'];
127 | noTerms = json['no_terms'];
128 | mostUsed = json['most_used'];
129 | backToItems = json['back_to_items'];
130 | }
131 |
132 | Map toJson() {
133 | final Map data = new Map();
134 |
135 | data['name'] = this.name;
136 | data['singular_name'] = this.singularName;
137 | data['search_items'] = this.searchItems;
138 | data['popular_items'] = this.popularItems;
139 | data['all_items'] = this.allItems;
140 | data['parent_item'] = this.parentItem;
141 | data['parent_item_colon'] = this.parentItemColon;
142 | data['add_new'] = this.addNew;
143 | data['add_new_item'] = this.addNewItem;
144 | data['edit_item'] = this.editItem;
145 | data['new_item'] = this.newItem;
146 | data['view_item'] = this.viewItem;
147 | data['view_items'] = this.viewItems;
148 | data['not_found'] = this.notFound;
149 | data['not_found_in_trash'] = this.notFoundInTrash;
150 | data['archives'] = this.archives;
151 | data['attributes'] = this.attributes;
152 | data['insert_into_item'] = this.insertIntoItem;
153 | data['uploaded_to_this_item'] = this.uploadedToThisItem;
154 | data['featured_image'] = this.featuredImage;
155 | data['set_featured_image'] = this.setFeaturedImage;
156 | data['remove_featured_image'] = this.removeFeaturedImage;
157 | data['use_featured_image'] = this.useFeaturedImage;
158 | data['filter_items_list'] = this.filterItemsList;
159 | data['items_list_navigation'] = this.itemsListNavigation;
160 | data['items_list'] = this.itemsList;
161 | data['item_published'] = this.itemPublished;
162 | data['item_published_privately'] = this.itemPublishedPrivately;
163 | data['item_reverted_to_draft'] = this.itemRevertedToDraft;
164 | data['item_scheduled'] = this.itemScheduled;
165 | data['item_updated'] = this.itemUpdated;
166 | data['menu_name'] = this.menuName;
167 | data['name_admin_bar'] = this.nameAdminBar;
168 | data['update_item'] = this.updateItem;
169 | data['new_item_name'] = this.newItemName;
170 | data['separate_items_with_commas'] = this.separateItemsWithCommas;
171 | data['add_or_remove_items'] = this.addOrRemoveItems;
172 | data['choose_from_most_used'] = this.chooseFromMostUsed;
173 | data['no_terms'] = this.noTerms;
174 | data['most_used'] = this.mostUsed;
175 | data['back_to_items'] = this.backToItems;
176 |
177 | return data;
178 | }
179 | }
180 |
--------------------------------------------------------------------------------
/lib/schemas/page.dart:
--------------------------------------------------------------------------------
1 | import 'content.dart';
2 | import 'excerpt.dart';
3 | import 'guid.dart';
4 | import 'links.dart';
5 | import 'title.dart';
6 |
7 | class Page {
8 | int? id;
9 | String? date;
10 | String? dateGmt;
11 | Guid? guid;
12 | String? modified;
13 | String? modifiedGmt;
14 | String? password;
15 | String? slug;
16 | String? status;
17 | String? type;
18 | String? link;
19 | Title? title;
20 | Content? content;
21 | Excerpt? excerpt;
22 | int? author;
23 | int? featuredMedia;
24 | int? parent;
25 | int? menuOrder;
26 | String? commentStatus;
27 | String? pingStatus;
28 | String? template;
29 | String? permalinkTemplate;
30 | String? generatedSlug;
31 | Links? lLinks;
32 |
33 | Page({
34 | this.id,
35 | this.date,
36 | this.dateGmt,
37 | this.guid,
38 | this.modified,
39 | this.modifiedGmt,
40 | this.password,
41 | this.slug,
42 | this.status,
43 | this.type,
44 | this.link,
45 | this.title,
46 | this.content,
47 | this.excerpt,
48 | this.author,
49 | this.featuredMedia,
50 | this.parent,
51 | this.menuOrder,
52 | this.commentStatus,
53 | this.pingStatus,
54 | this.template,
55 | this.permalinkTemplate,
56 | this.generatedSlug,
57 | this.lLinks,
58 | });
59 |
60 | Page.fromJson(Map json) {
61 | id = json['id'];
62 | date = json['date'];
63 | dateGmt = json['date_gmt'];
64 | guid = json['guid'] != null ? new Guid.fromJson(json['guid']) : null;
65 | modified = json['modified'];
66 | modifiedGmt = json['modified_gmt'];
67 | password = json['password'];
68 | slug = json['slug'];
69 | status = json['status'];
70 | type = json['type'];
71 | link = json['link'];
72 | title = json['title'] != null ? new Title.fromJson(json['title']) : null;
73 | content =
74 | json['content'] != null ? new Content.fromJson(json['content']) : null;
75 | excerpt =
76 | json['excerpt'] != null ? new Excerpt.fromJson(json['excerpt']) : null;
77 | author = json['author'];
78 | featuredMedia = json['featured_media'];
79 | parent = json['parent'];
80 | menuOrder = json['menu_order'];
81 | commentStatus = json['comment_status'];
82 | pingStatus = json['ping_status'];
83 | template = json['template'];
84 | permalinkTemplate = json['permalink_template'];
85 | generatedSlug = json['generated_slug'];
86 | lLinks = json['_links'] != null ? new Links.fromJson(json['_links']) : null;
87 | }
88 |
89 | Map toJson() {
90 | final Map data = new Map();
91 |
92 | data['id'] = this.id;
93 | data['date'] = this.date;
94 | data['date_gmt'] = this.dateGmt;
95 | data['guid'] = this.guid?.toJson();
96 | data['modified'] = this.modified;
97 | data['modified_gmt'] = this.modifiedGmt;
98 | data['password'] = this.password;
99 | data['slug'] = this.slug;
100 | data['status'] = this.status;
101 | data['type'] = this.type;
102 | data['link'] = this.link;
103 | data['title'] = this.title?.toJson();
104 | data['content'] = this.content?.toJson();
105 | data['excerpt'] = this.excerpt?.toJson();
106 | data['author'] = this.author;
107 | data['featured_media'] = this.featuredMedia;
108 | data['parent'] = this.parent;
109 | data['menu_order'] = this.menuOrder;
110 | data['comment_status'] = this.commentStatus;
111 | data['ping_status'] = this.pingStatus;
112 | data['template'] = this.template;
113 | data['permalink_template'] = this.permalinkTemplate;
114 | data['generated_slug'] = this.generatedSlug;
115 | data['_links'] = this.lLinks?.toJson();
116 |
117 | return data;
118 | }
119 | }
120 |
--------------------------------------------------------------------------------
/lib/schemas/post.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter_wordpress/constants.dart';
2 |
3 | import 'category.dart';
4 | import 'comment.dart';
5 | import 'comment_hierarchy.dart';
6 | import 'content.dart';
7 | import 'excerpt.dart';
8 | import 'guid.dart';
9 | import 'links.dart';
10 | import 'media.dart';
11 | import 'tag.dart';
12 | import 'title.dart';
13 | import 'user.dart';
14 |
15 | /// A [WordPress Post](https://developer.wordpress.org/rest-api/reference/posts/)
16 | ///
17 | /// Refer the above link to see which arguments are set based on different context modes.
18 | /// ([WordPressContext]).
19 | class Post {
20 | /// ID of the post
21 | int? id;
22 |
23 | /// The date the post was published, in the site's Timezone.
24 | String? date;
25 |
26 | /// The date the post was published, in GMT.
27 | String? dateGmt;
28 | Guid? guid;
29 | String? modified;
30 | String? modifiedGmt;
31 |
32 | /// Password for the post in case it needs to be password protected.
33 | String? password;
34 |
35 | /// An alphanumeric identifier unique to each post.
36 | String? slug;
37 |
38 | /// The state in which the post should be created (draft, publish etc.)
39 | PostPageStatus? status;
40 | String? type;
41 | String? link;
42 |
43 | /// Post title
44 | Title? title;
45 |
46 | /// Post content
47 | Content? content;
48 |
49 | /// Post excerpt
50 | Excerpt? excerpt;
51 |
52 | /// ID of the post author. Refer [User].
53 | int? authorID;
54 |
55 | int? featuredMediaID;
56 |
57 | /// Whether the post allows commenting.
58 | PostCommentStatus? commentStatus;
59 |
60 | /// Whether the post can be pinged.
61 | PostPingStatus? pingStatus;
62 |
63 | /// Whether the post needs to sticky i.e. a Featured post.
64 | bool? sticky;
65 | String? template;
66 |
67 | /// The format of the post.
68 | PostFormat? format;
69 |
70 | /// List of IDs of categories this post belongs to.
71 | List? categoryIDs;
72 |
73 | /// List of IDs of tags this post should have.
74 | List? tagIDs;
75 | String? permalinkTemplate;
76 | String? generatedSlug;
77 | Links? lLinks;
78 |
79 | /// The [User] object denoting the author of the post.
80 | User? author;
81 |
82 | /// A list of comments for the post.
83 | List? comments;
84 |
85 | /// A list of comments for the post, where each
86 | /// [CommentHierarchy] object is a direct comment to the post, with
87 | /// [CommentHierarchy.children] containing replies to that comment.
88 | List? commentsHierarchy;
89 |
90 | /// A list of categories assigned to the post.
91 | List? categories;
92 |
93 | /// A list of tags assigned to the post.
94 | List? tags;
95 |
96 | /// A list of attachments contained in the post.
97 | List? attachments;
98 |
99 | /// The featured Media of the post.
100 | Media? featuredMedia;
101 |
102 | Post({
103 | this.date,
104 | this.dateGmt,
105 | this.password,
106 | this.slug,
107 | this.status = PostPageStatus.publish,
108 | required String title,
109 | required String content,
110 | required String excerpt,
111 | required this.authorID,
112 | String? featuredMedia,
113 | this.featuredMediaID,
114 | this.commentStatus = PostCommentStatus.open,
115 | this.pingStatus = PostPingStatus.open,
116 | this.sticky,
117 | this.template,
118 | this.format = PostFormat.standard,
119 | this.categoryIDs,
120 | this.tagIDs,
121 | }) : this.title = new Title(rendered: title),
122 | this.featuredMedia = new Media(sourceUrl: featuredMedia),
123 | this.content = new Content(rendered: content),
124 | this.excerpt = new Excerpt(rendered: excerpt);
125 |
126 | Post.fromJson(Map json) {
127 | id = json['id'];
128 | date = json['date'];
129 | dateGmt = json['date_gmt'];
130 | guid = json['guid'] != null ? new Guid.fromJson(json['guid']) : null;
131 | modified = json['modified'];
132 | modifiedGmt = json['modified_gmt'];
133 | password = json['password'];
134 | slug = json['slug'];
135 | if (json['status'] != null) {
136 | PostPageStatus.values.forEach((val) {
137 | if (enumStringToName(val.toString()) == json['status']) {
138 | status = val;
139 | return;
140 | }
141 | });
142 | }
143 | type = json['type'];
144 | link = json['link'];
145 | title = json['title'] != null ? new Title.fromJson(json['title']) : null;
146 | content =
147 | json['content'] != null ? new Content.fromJson(json['content']) : null;
148 | excerpt =
149 | json['excerpt'] != null ? new Excerpt.fromJson(json['excerpt']) : null;
150 | authorID = json['author'];
151 | featuredMediaID = json['featured_media'];
152 | if (json['comment_status'] != null) {
153 | PostCommentStatus.values.forEach((val) {
154 | if (enumStringToName(val.toString()) == json['comment_status']) {
155 | commentStatus = val;
156 | return;
157 | }
158 | });
159 | }
160 | if (json['ping_status'] != null) {
161 | PostPingStatus.values.forEach((val) {
162 | if (enumStringToName(val.toString()) == json['ping_status']) {
163 | pingStatus = val;
164 | return;
165 | }
166 | });
167 | }
168 | sticky = json['sticky'];
169 | template = json['template'];
170 | if (json['format'] != null) {
171 | PostFormat.values.forEach((val) {
172 | if (enumStringToName(val.toString()) == json['format']) {
173 | format = val;
174 | return;
175 | }
176 | });
177 | }
178 | categoryIDs =
179 | json['categories'] != null ? json['categories'].cast() : null;
180 | tagIDs = json['tags'] != null ? json['tags'].cast() : null;
181 | permalinkTemplate = json['permalink_template'];
182 | generatedSlug = json['generated_slug'];
183 | lLinks = json['_links'] != null ? new Links.fromJson(json['_links']) : null;
184 | }
185 |
186 | Map toJson() {
187 | final Map data = new Map();
188 |
189 | data['date'] = this.date;
190 | data['date_gmt'] = this.dateGmt;
191 | data['password'] = this.password;
192 | data['slug'] = this.slug;
193 | data['status'] = enumStringToName(this.status.toString());
194 | data['title'] = this.title?.toJson();
195 | data['content'] = this.content?.toJson();
196 | data['excerpt'] = this.excerpt?.toJson();
197 | data['author'] = this.authorID;
198 | data['featured_media'] = this.featuredMediaID;
199 | data['comment_status'] = enumStringToName(this.commentStatus.toString());
200 | data['ping_status'] = enumStringToName(this.pingStatus.toString());
201 | data['sticky'] = this.sticky;
202 | data['template'] = this.template;
203 | data['format'] = enumStringToName(this.format.toString());
204 | data['categories'] = listToUrlString(this.categoryIDs ?? []);
205 | data['tags'] = listToUrlString(this.tagIDs ?? []);
206 |
207 | return data;
208 | }
209 |
210 | @override
211 | String toString() {
212 | return 'Post: { id: $id, title: ${title?.rendered}, '
213 | 'author: {id: $authorID, name: ${author?.name}}}';
214 | }
215 | }
216 |
--------------------------------------------------------------------------------
/lib/schemas/post_statuses.dart:
--------------------------------------------------------------------------------
1 | import 'links.dart';
2 |
3 | class PostStatuses {
4 | Publish? publish;
5 | Future? future;
6 | Draft? draft;
7 | Pending? pending;
8 | Private? private;
9 | Trash? trash;
10 |
11 | PostStatuses({
12 | this.publish,
13 | this.future,
14 | this.draft,
15 | this.pending,
16 | this.private,
17 | this.trash,
18 | });
19 |
20 | PostStatuses.fromJson(Map json) {
21 | publish =
22 | json['publish'] != null ? new Publish.fromJson(json['publish']) : null;
23 | future =
24 | json['future'] != null ? new Future.fromJson(json['future']) : null;
25 | draft = json['draft'] != null ? new Draft.fromJson(json['draft']) : null;
26 | pending =
27 | json['pending'] != null ? new Pending.fromJson(json['pending']) : null;
28 | private =
29 | json['private'] != null ? new Private.fromJson(json['private']) : null;
30 | trash = json['trash'] != null ? new Trash.fromJson(json['trash']) : null;
31 | }
32 |
33 | Map toJson() {
34 | final Map data = new Map();
35 |
36 | data['publish'] = this.publish?.toJson();
37 | data['future'] = this.future?.toJson();
38 | data['draft'] = this.draft?.toJson();
39 | data['pending'] = this.pending?.toJson();
40 | data['private'] = this.private?.toJson();
41 | data['trash'] = this.trash?.toJson();
42 |
43 | return data;
44 | }
45 | }
46 |
47 | class Publish {
48 | String? name;
49 | bool? private;
50 | bool? protected;
51 | bool? public;
52 | bool? queryable;
53 | bool? showInList;
54 | String? slug;
55 | Links? lLinks;
56 |
57 | Publish({
58 | this.name,
59 | this.private,
60 | this.protected,
61 | this.public,
62 | this.queryable,
63 | this.showInList,
64 | this.slug,
65 | this.lLinks,
66 | });
67 |
68 | Publish.fromJson(Map json) {
69 | name = json['name'];
70 | private = json['private'];
71 | protected = json['protected'];
72 | public = json['public'];
73 | queryable = json['queryable'];
74 | showInList = json['show_in_list'];
75 | slug = json['slug'];
76 | lLinks = json['_links'] != null ? new Links.fromJson(json['_links']) : null;
77 | }
78 |
79 | Map toJson() {
80 | final Map data = new Map();
81 |
82 | data['name'] = this.name;
83 | data['private'] = this.private;
84 | data['protected'] = this.protected;
85 | data['public'] = this.public;
86 | data['queryable'] = this.queryable;
87 | data['show_in_list'] = this.showInList;
88 | data['slug'] = this.slug;
89 | data['_links'] = this.lLinks?.toJson();
90 |
91 | return data;
92 | }
93 | }
94 |
95 | class Future {
96 | String? name;
97 | bool? private;
98 | bool? protected;
99 | bool? public;
100 | bool? queryable;
101 | bool? showInList;
102 | String? slug;
103 | Links? lLinks;
104 |
105 | Future({
106 | this.name,
107 | this.private,
108 | this.protected,
109 | this.public,
110 | this.queryable,
111 | this.showInList,
112 | this.slug,
113 | this.lLinks,
114 | });
115 |
116 | Future.fromJson(Map json) {
117 | name = json['name'];
118 | private = json['private'];
119 | protected = json['protected'];
120 | public = json['public'];
121 | queryable = json['queryable'];
122 | showInList = json['show_in_list'];
123 | slug = json['slug'];
124 | lLinks = json['_links'] != null ? new Links.fromJson(json['_links']) : null;
125 | }
126 |
127 | Map toJson() {
128 | final Map data = new Map();
129 |
130 | data['name'] = this.name;
131 | data['private'] = this.private;
132 | data['protected'] = this.protected;
133 | data['public'] = this.public;
134 | data['queryable'] = this.queryable;
135 | data['show_in_list'] = this.showInList;
136 | data['slug'] = this.slug;
137 | data['_links'] = this.lLinks?.toJson();
138 |
139 | return data;
140 | }
141 | }
142 |
143 | class Draft {
144 | String? name;
145 | bool? private;
146 | bool? protected;
147 | bool? public;
148 | bool? queryable;
149 | bool? showInList;
150 | String? slug;
151 | Links? lLinks;
152 |
153 | Draft({
154 | this.name,
155 | this.private,
156 | this.protected,
157 | this.public,
158 | this.queryable,
159 | this.showInList,
160 | this.slug,
161 | this.lLinks,
162 | });
163 |
164 | Draft.fromJson(Map json) {
165 | name = json['name'];
166 | private = json['private'];
167 | protected = json['protected'];
168 | public = json['public'];
169 | queryable = json['queryable'];
170 | showInList = json['show_in_list'];
171 | slug = json['slug'];
172 | lLinks = json['_links'] != null ? new Links.fromJson(json['_links']) : null;
173 | }
174 |
175 | Map toJson() {
176 | final Map data = new Map();
177 |
178 | data['name'] = this.name;
179 | data['private'] = this.private;
180 | data['protected'] = this.protected;
181 | data['public'] = this.public;
182 | data['queryable'] = this.queryable;
183 | data['show_in_list'] = this.showInList;
184 | data['slug'] = this.slug;
185 | data['_links'] = this.lLinks?.toJson();
186 |
187 | return data;
188 | }
189 | }
190 |
191 | class Pending {
192 | String? name;
193 | bool? private;
194 | bool? protected;
195 | bool? public;
196 | bool? queryable;
197 | bool? showInList;
198 | String? slug;
199 | Links? lLinks;
200 |
201 | Pending({
202 | this.name,
203 | this.private,
204 | this.protected,
205 | this.public,
206 | this.queryable,
207 | this.showInList,
208 | this.slug,
209 | this.lLinks,
210 | });
211 |
212 | Pending.fromJson(Map json) {
213 | name = json['name'];
214 | private = json['private'];
215 | protected = json['protected'];
216 | public = json['public'];
217 | queryable = json['queryable'];
218 | showInList = json['show_in_list'];
219 | slug = json['slug'];
220 | lLinks = json['_links'] != null ? new Links.fromJson(json['_links']) : null;
221 | }
222 |
223 | Map toJson() {
224 | final Map data = new Map();
225 |
226 | data['name'] = this.name;
227 | data['private'] = this.private;
228 | data['protected'] = this.protected;
229 | data['public'] = this.public;
230 | data['queryable'] = this.queryable;
231 | data['show_in_list'] = this.showInList;
232 | data['slug'] = this.slug;
233 | data['_links'] = this.lLinks?.toJson();
234 |
235 | return data;
236 | }
237 | }
238 |
239 | class Private {
240 | String? name;
241 | bool? private;
242 | bool? protected;
243 | bool? public;
244 | bool? queryable;
245 | bool? showInList;
246 | String? slug;
247 | Links? lLinks;
248 |
249 | Private({
250 | this.name,
251 | this.private,
252 | this.protected,
253 | this.public,
254 | this.queryable,
255 | this.showInList,
256 | this.slug,
257 | this.lLinks,
258 | });
259 |
260 | Private.fromJson(Map json) {
261 | name = json['name'];
262 | private = json['private'];
263 | protected = json['protected'];
264 | public = json['public'];
265 | queryable = json['queryable'];
266 | showInList = json['show_in_list'];
267 | slug = json['slug'];
268 | lLinks = json['_links'] != null ? new Links.fromJson(json['_links']) : null;
269 | }
270 |
271 | Map toJson() {
272 | final Map data = new Map();
273 |
274 | data['name'] = this.name;
275 | data['private'] = this.private;
276 | data['protected'] = this.protected;
277 | data['public'] = this.public;
278 | data['queryable'] = this.queryable;
279 | data['show_in_list'] = this.showInList;
280 | data['slug'] = this.slug;
281 | data['_links'] = this.lLinks?.toJson();
282 |
283 | return data;
284 | }
285 | }
286 |
287 | class Trash {
288 | String? name;
289 | bool? private;
290 | bool? protected;
291 | bool? public;
292 | bool? queryable;
293 | bool? showInList;
294 | String? slug;
295 | Links? lLinks;
296 |
297 | Trash({
298 | this.name,
299 | this.private,
300 | this.protected,
301 | this.public,
302 | this.queryable,
303 | this.showInList,
304 | this.slug,
305 | this.lLinks,
306 | });
307 |
308 | Trash.fromJson(Map json) {
309 | name = json['name'];
310 | private = json['private'];
311 | protected = json['protected'];
312 | public = json['public'];
313 | queryable = json['queryable'];
314 | showInList = json['show_in_list'];
315 | slug = json['slug'];
316 | lLinks = json['_links'] != null ? new Links.fromJson(json['_links']) : null;
317 | }
318 |
319 | Map toJson() {
320 | final Map data = new Map();
321 |
322 | data['name'] = this.name;
323 | data['private'] = this.private;
324 | data['protected'] = this.protected;
325 | data['public'] = this.public;
326 | data['queryable'] = this.queryable;
327 | data['show_in_list'] = this.showInList;
328 | data['slug'] = this.slug;
329 | data['_links'] = this.lLinks?.toJson();
330 |
331 | return data;
332 | }
333 | }
334 |
--------------------------------------------------------------------------------
/lib/schemas/post_types.dart:
--------------------------------------------------------------------------------
1 | import 'capabilities.dart';
2 | import 'labels.dart';
3 | import 'links.dart';
4 |
5 | class PostTypes {
6 | PostTypePost? post;
7 | PostTypePage? page;
8 | Attachment? attachment;
9 | WpBlock? wpBlock;
10 |
11 | PostTypes({
12 | this.post,
13 | this.page,
14 | this.attachment,
15 | this.wpBlock,
16 | });
17 |
18 | PostTypes.fromJson(Map json) {
19 | post =
20 | json['post'] != null ? new PostTypePost.fromJson(json['post']) : null;
21 | page =
22 | json['page'] != null ? new PostTypePage.fromJson(json['page']) : null;
23 | attachment = json['attachment'] != null
24 | ? new Attachment.fromJson(json['attachment'])
25 | : null;
26 | wpBlock = json['wp_block'] != null
27 | ? new WpBlock.fromJson(json['wp_block'])
28 | : null;
29 | }
30 |
31 | Map toJson() {
32 | final Map data = new Map();
33 |
34 | data['post'] = this.post?.toJson();
35 | data['page'] = this.page?.toJson();
36 | data['attachment'] = this.attachment?.toJson();
37 | data['wp_block'] = this.wpBlock?.toJson();
38 |
39 | return data;
40 | }
41 | }
42 |
43 | class PostTypePost {
44 | Capabilities? capabilities;
45 | String? description;
46 | bool? hierarchical;
47 | bool? viewable;
48 | Labels? labels;
49 | String? name;
50 | String? slug;
51 | Supports? supports;
52 | List? taxonomies;
53 | String? restBase;
54 | Links? lLinks;
55 |
56 | PostTypePost({
57 | this.capabilities,
58 | this.description,
59 | this.hierarchical,
60 | this.viewable,
61 | this.labels,
62 | this.name,
63 | this.slug,
64 | this.supports,
65 | this.taxonomies,
66 | this.restBase,
67 | this.lLinks,
68 | });
69 |
70 | PostTypePost.fromJson(Map json) {
71 | capabilities = json['capabilities'] != null
72 | ? new Capabilities.fromJson(json['capabilities'])
73 | : null;
74 | description = json['description'];
75 | hierarchical = json['hierarchical'];
76 | viewable = json['viewable'];
77 | labels =
78 | json['labels'] != null ? new Labels.fromJson(json['labels']) : null;
79 | name = json['name'];
80 | slug = json['slug'];
81 | supports = json['supports'] != null
82 | ? new Supports.fromJson(json['supports'])
83 | : null;
84 | taxonomies = json['taxonomies'].cast();
85 | restBase = json['rest_base'];
86 | lLinks = json['_links'] != null ? new Links.fromJson(json['_links']) : null;
87 | }
88 |
89 | Map toJson() {
90 | final Map data = new Map();
91 |
92 | data['capabilities'] = this.capabilities?.toJson();
93 | data['description'] = this.description;
94 | data['hierarchical'] = this.hierarchical;
95 | data['viewable'] = this.viewable;
96 | data['labels'] = this.labels?.toJson();
97 | data['name'] = this.name;
98 | data['slug'] = this.slug;
99 | data['supports'] = this.supports?.toJson();
100 | data['taxonomies'] = this.taxonomies;
101 | data['rest_base'] = this.restBase;
102 | data['_links'] = this.lLinks?.toJson();
103 |
104 | return data;
105 | }
106 | }
107 |
108 | class Supports {
109 | bool? title;
110 | bool? editor;
111 | bool? author;
112 | bool? thumbnail;
113 | bool? excerpt;
114 | bool? trackbacks;
115 | bool? customFields;
116 | bool? comments;
117 | bool? revisions;
118 | bool? postFormats;
119 |
120 | Supports({
121 | this.title,
122 | this.editor,
123 | this.author,
124 | this.thumbnail,
125 | this.excerpt,
126 | this.trackbacks,
127 | this.customFields,
128 | this.comments,
129 | this.revisions,
130 | this.postFormats,
131 | });
132 |
133 | Supports.fromJson(Map json) {
134 | title = json['title'];
135 | editor = json['editor'];
136 | author = json['author'];
137 | thumbnail = json['thumbnail'];
138 | excerpt = json['excerpt'];
139 | trackbacks = json['trackbacks'];
140 | customFields = json['custom-fields'];
141 | comments = json['comments'];
142 | revisions = json['revisions'];
143 | postFormats = json['post-formats'];
144 | }
145 |
146 | Map toJson() {
147 | final Map data = new Map();
148 |
149 | data['title'] = this.title;
150 | data['editor'] = this.editor;
151 | data['author'] = this.author;
152 | data['thumbnail'] = this.thumbnail;
153 | data['excerpt'] = this.excerpt;
154 | data['trackbacks'] = this.trackbacks;
155 | data['custom-fields'] = this.customFields;
156 | data['comments'] = this.comments;
157 | data['revisions'] = this.revisions;
158 | data['post-formats'] = this.postFormats;
159 |
160 | return data;
161 | }
162 | }
163 |
164 | class PostTypePage {
165 | Capabilities? capabilities;
166 | String? description;
167 | bool? hierarchical;
168 | bool? viewable;
169 | Labels? labels;
170 | String? name;
171 | String? slug;
172 | Supports? supports;
173 | List? taxonomies;
174 | String? restBase;
175 | Links? lLinks;
176 |
177 | PostTypePage({
178 | this.capabilities,
179 | this.description,
180 | this.hierarchical,
181 | this.viewable,
182 | this.labels,
183 | this.name,
184 | this.slug,
185 | this.supports,
186 | this.taxonomies,
187 | this.restBase,
188 | this.lLinks,
189 | });
190 |
191 | PostTypePage.fromJson(Map json) {
192 | capabilities = json['capabilities'] != null
193 | ? new Capabilities.fromJson(json['capabilities'])
194 | : null;
195 | description = json['description'];
196 | hierarchical = json['hierarchical'];
197 | viewable = json['viewable'];
198 | labels =
199 | json['labels'] != null ? new Labels.fromJson(json['labels']) : null;
200 | name = json['name'];
201 | slug = json['slug'];
202 | supports = json['supports'] != null
203 | ? new Supports.fromJson(json['supports'])
204 | : null;
205 | taxonomies = json['taxonomies'].cast();
206 | restBase = json['rest_base'];
207 | lLinks = json['_links'] != null ? new Links.fromJson(json['_links']) : null;
208 | }
209 |
210 | Map toJson() {
211 | final Map data = new Map();
212 |
213 | data['capabilities'] = this.capabilities?.toJson();
214 | data['description'] = this.description;
215 | data['hierarchical'] = this.hierarchical;
216 | data['viewable'] = this.viewable;
217 | data['labels'] = this.labels?.toJson();
218 | data['name'] = this.name;
219 | data['slug'] = this.slug;
220 | data['supports'] = this.supports?.toJson();
221 | data['taxonomies'] = this.taxonomies;
222 | data['rest_base'] = this.restBase;
223 | data['_links'] = this.lLinks?.toJson();
224 |
225 | return data;
226 | }
227 | }
228 |
229 | class Attachment {
230 | Capabilities? capabilities;
231 | String? description;
232 | bool? hierarchical;
233 | bool? viewable;
234 | Labels? labels;
235 | String? name;
236 | String? slug;
237 | Supports? supports;
238 | List? taxonomies;
239 | String? restBase;
240 | Links? lLinks;
241 |
242 | Attachment({
243 | this.capabilities,
244 | this.description,
245 | this.hierarchical,
246 | this.viewable,
247 | this.labels,
248 | this.name,
249 | this.slug,
250 | this.supports,
251 | this.taxonomies,
252 | this.restBase,
253 | this.lLinks,
254 | });
255 |
256 | Attachment.fromJson(Map json) {
257 | capabilities = json['capabilities'] != null
258 | ? new Capabilities.fromJson(json['capabilities'])
259 | : null;
260 | description = json['description'];
261 | hierarchical = json['hierarchical'];
262 | viewable = json['viewable'];
263 | labels =
264 | json['labels'] != null ? new Labels.fromJson(json['labels']) : null;
265 | name = json['name'];
266 | slug = json['slug'];
267 | supports = json['supports'] != null
268 | ? new Supports.fromJson(json['supports'])
269 | : null;
270 | taxonomies = json['taxonomies'].cast();
271 | restBase = json['rest_base'];
272 | lLinks = json['_links'] != null ? new Links.fromJson(json['_links']) : null;
273 | }
274 |
275 | Map toJson() {
276 | final Map data = new Map();
277 |
278 | data['capabilities'] = this.capabilities?.toJson();
279 | data['description'] = this.description;
280 | data['hierarchical'] = this.hierarchical;
281 | data['viewable'] = this.viewable;
282 | data['labels'] = this.labels?.toJson();
283 | data['name'] = this.name;
284 | data['slug'] = this.slug;
285 | data['supports'] = this.supports?.toJson();
286 | data['taxonomies'] = this.taxonomies;
287 | data['rest_base'] = this.restBase;
288 | data['_links'] = this.lLinks?.toJson();
289 |
290 | return data;
291 | }
292 | }
293 |
294 | class WpBlock {
295 | Capabilities? capabilities;
296 | String? description;
297 | bool? hierarchical;
298 | bool? viewable;
299 | Labels? labels;
300 | String? name;
301 | String? slug;
302 | Supports? supports;
303 | List? taxonomies;
304 | String? restBase;
305 | Links? lLinks;
306 |
307 | WpBlock({
308 | this.capabilities,
309 | this.description,
310 | this.hierarchical,
311 | this.viewable,
312 | this.labels,
313 | this.name,
314 | this.slug,
315 | this.supports,
316 | this.taxonomies,
317 | this.restBase,
318 | this.lLinks,
319 | });
320 |
321 | WpBlock.fromJson(Map json) {
322 | capabilities = json['capabilities'] != null
323 | ? new Capabilities.fromJson(json['capabilities'])
324 | : null;
325 | description = json['description'];
326 | hierarchical = json['hierarchical'];
327 | viewable = json['viewable'];
328 | labels =
329 | json['labels'] != null ? new Labels.fromJson(json['labels']) : null;
330 | name = json['name'];
331 | slug = json['slug'];
332 | supports = json['supports'] != null
333 | ? new Supports.fromJson(json['supports'])
334 | : null;
335 | taxonomies = json['taxonomies'].cast();
336 | restBase = json['rest_base'];
337 | lLinks = json['_links'] != null ? new Links.fromJson(json['_links']) : null;
338 | }
339 |
340 | Map toJson() {
341 | final Map data = new Map();
342 |
343 | data['capabilities'] = this.capabilities?.toJson();
344 | data['description'] = this.description;
345 | data['hierarchical'] = this.hierarchical;
346 | data['viewable'] = this.viewable;
347 | data['labels'] = this.labels?.toJson();
348 | data['name'] = this.name;
349 | data['slug'] = this.slug;
350 | data['supports'] = this.supports?.toJson();
351 | data['taxonomies'] = this.taxonomies;
352 | data['rest_base'] = this.restBase;
353 | data['_links'] = this.lLinks?.toJson();
354 |
355 | return data;
356 | }
357 | }
358 |
--------------------------------------------------------------------------------
/lib/schemas/settings.dart:
--------------------------------------------------------------------------------
1 | class Settings {
2 | String? title;
3 | String? description;
4 | String? url;
5 | String? email;
6 | String? timezone;
7 | String? dateFormat;
8 | String? timeFormat;
9 | int? startOfWeek;
10 | String? language;
11 | bool? useSmilies;
12 | int? defaultCategory;
13 | String? defaultPostFormat;
14 | int? postsPerPage;
15 | String? defaultPingStatus;
16 | String? defaultCommentStatus;
17 |
18 | Settings({
19 | this.title,
20 | this.description,
21 | this.url,
22 | this.email,
23 | this.timezone,
24 | this.dateFormat,
25 | this.timeFormat,
26 | this.startOfWeek,
27 | this.language,
28 | this.useSmilies,
29 | this.defaultCategory,
30 | this.defaultPostFormat,
31 | this.postsPerPage,
32 | this.defaultPingStatus,
33 | this.defaultCommentStatus,
34 | });
35 |
36 | Settings.fromJson(Map json) {
37 | title = json['title'];
38 | description = json['description'];
39 | url = json['url'];
40 | email = json['email'];
41 | timezone = json['timezone'];
42 | dateFormat = json['date_format'];
43 | timeFormat = json['time_format'];
44 | startOfWeek = json['start_of_week'];
45 | language = json['language'];
46 | useSmilies = json['use_smilies'];
47 | defaultCategory = json['default_category'];
48 | defaultPostFormat = json['default_post_format'];
49 | postsPerPage = json['posts_per_page'];
50 | defaultPingStatus = json['default_ping_status'];
51 | defaultCommentStatus = json['default_comment_status'];
52 | }
53 |
54 | Map toJson() {
55 | final Map data = new Map();
56 |
57 | data['title'] = this.title;
58 | data['description'] = this.description;
59 | data['url'] = this.url;
60 | data['email'] = this.email;
61 | data['timezone'] = this.timezone;
62 | data['date_format'] = this.dateFormat;
63 | data['time_format'] = this.timeFormat;
64 | data['start_of_week'] = this.startOfWeek;
65 | data['language'] = this.language;
66 | data['use_smilies'] = this.useSmilies;
67 | data['default_category'] = this.defaultCategory;
68 | data['default_post_format'] = this.defaultPostFormat;
69 | data['posts_per_page'] = this.postsPerPage;
70 | data['default_ping_status'] = this.defaultPingStatus;
71 | data['default_comment_status'] = this.defaultCommentStatus;
72 |
73 | return data;
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/lib/schemas/tag.dart:
--------------------------------------------------------------------------------
1 | import 'links.dart';
2 |
3 | class Tag {
4 | int? id;
5 | int? count;
6 | String? description;
7 | String? link;
8 | String? name;
9 | String? slug;
10 | String? taxonomy;
11 | Links? lLinks;
12 |
13 | Tag({
14 | this.id,
15 | this.count,
16 | this.description,
17 | this.link,
18 | this.name,
19 | this.slug,
20 | this.taxonomy,
21 | this.lLinks,
22 | });
23 |
24 | Tag.fromJson(Map json) {
25 | id = json['id'];
26 | count = json['count'];
27 | description = json['description'];
28 | link = json['link'];
29 | name = json['name'];
30 | slug = json['slug'];
31 | taxonomy = json['taxonomy'];
32 | lLinks = json['_links'] != null ? new Links.fromJson(json['_links']) : null;
33 | }
34 |
35 | Map toJson() {
36 | final Map data = new Map();
37 |
38 | data['id'] = this.id;
39 | data['count'] = this.count;
40 | data['description'] = this.description;
41 | data['link'] = this.link;
42 | data['name'] = this.name;
43 | data['slug'] = this.slug;
44 | data['taxonomy'] = this.taxonomy;
45 | data['_links'] = this.lLinks?.toJson();
46 |
47 | return data;
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/lib/schemas/taxonomies.dart:
--------------------------------------------------------------------------------
1 | import 'capabilities.dart';
2 | import 'labels.dart';
3 | import 'links.dart';
4 |
5 | class Taxonomies {
6 | TaxonomyCategory? category;
7 | TaxonomyPostTag? postTag;
8 |
9 | Taxonomies({
10 | this.category,
11 | this.postTag,
12 | });
13 |
14 | Taxonomies.fromJson(Map json) {
15 | category = json['category'] != null
16 | ? new TaxonomyCategory.fromJson(json['category'])
17 | : null;
18 | postTag = json['post_tag'] != null
19 | ? new TaxonomyPostTag.fromJson(json['post_tag'])
20 | : null;
21 | }
22 |
23 | Map toJson() {
24 | final Map data = new Map();
25 |
26 | data['category'] = this.category?.toJson();
27 | data['post_tag'] = this.postTag?.toJson();
28 |
29 | return data;
30 | }
31 | }
32 |
33 | class TaxonomyCategory {
34 | String? name;
35 | String? slug;
36 | Capabilities? capabilities;
37 | String? description;
38 | Labels? labels;
39 | List? types;
40 | bool? showCloud;
41 | bool? hierarchical;
42 | String? restBase;
43 | Visibility? visibility;
44 | Links? lLinks;
45 |
46 | TaxonomyCategory({
47 | this.name,
48 | this.slug,
49 | this.capabilities,
50 | this.description,
51 | this.labels,
52 | this.types,
53 | this.showCloud,
54 | this.hierarchical,
55 | this.restBase,
56 | this.visibility,
57 | this.lLinks,
58 | });
59 |
60 | TaxonomyCategory.fromJson(Map json) {
61 | name = json['name'];
62 | slug = json['slug'];
63 | capabilities = json['capabilities'] != null
64 | ? new Capabilities.fromJson(json['capabilities'])
65 | : null;
66 | description = json['description'];
67 | labels =
68 | json['labels'] != null ? new Labels.fromJson(json['labels']) : null;
69 | types = json['types'].cast();
70 | showCloud = json['show_cloud'];
71 | hierarchical = json['hierarchical'];
72 | restBase = json['rest_base'];
73 | visibility = json['visibility'] != null
74 | ? new Visibility.fromJson(json['visibility'])
75 | : null;
76 | lLinks = json['_links'] != null ? new Links.fromJson(json['_links']) : null;
77 | }
78 |
79 | Map toJson() {
80 | final Map data = new Map();
81 |
82 | data['name'] = this.name;
83 | data['slug'] = this.slug;
84 | data['capabilities'] = this.capabilities?.toJson();
85 | data['description'] = this.description;
86 | data['labels'] = this.labels?.toJson();
87 | data['types'] = this.types;
88 | data['show_cloud'] = this.showCloud;
89 | data['hierarchical'] = this.hierarchical;
90 | data['rest_base'] = this.restBase;
91 | data['visibility'] = this.visibility?.toJson();
92 | data['_links'] = this.lLinks?.toJson();
93 |
94 | return data;
95 | }
96 | }
97 |
98 | class Visibility {
99 | bool? public;
100 | bool? publiclyQueryable;
101 | bool? showAdminColumn;
102 | bool? showInNavMenus;
103 | bool? showInQuickEdit;
104 | bool? showUi;
105 |
106 | Visibility({
107 | this.public,
108 | this.publiclyQueryable,
109 | this.showAdminColumn,
110 | this.showInNavMenus,
111 | this.showInQuickEdit,
112 | this.showUi,
113 | });
114 |
115 | Visibility.fromJson(Map json) {
116 | public = json['public'];
117 | publiclyQueryable = json['publicly_queryable'];
118 | showAdminColumn = json['show_admin_column'];
119 | showInNavMenus = json['show_in_nav_menus'];
120 | showInQuickEdit = json['show_in_quick_edit'];
121 | showUi = json['show_ui'];
122 | }
123 |
124 | Map toJson() {
125 | final Map data = new Map();
126 |
127 | data['public'] = this.public;
128 | data['publicly_queryable'] = this.publiclyQueryable;
129 | data['show_admin_column'] = this.showAdminColumn;
130 | data['show_in_nav_menus'] = this.showInNavMenus;
131 | data['show_in_quick_edit'] = this.showInQuickEdit;
132 | data['show_ui'] = this.showUi;
133 |
134 | return data;
135 | }
136 | }
137 |
138 | class TaxonomyPostTag {
139 | String? name;
140 | String? slug;
141 | Capabilities? capabilities;
142 | String? description;
143 | Labels? labels;
144 | List? types;
145 | bool? showCloud;
146 | bool? hierarchical;
147 | String? restBase;
148 | Visibility? visibility;
149 | Links? lLinks;
150 |
151 | TaxonomyPostTag({
152 | this.name,
153 | this.slug,
154 | this.capabilities,
155 | this.description,
156 | this.labels,
157 | this.types,
158 | this.showCloud,
159 | this.hierarchical,
160 | this.restBase,
161 | this.visibility,
162 | this.lLinks,
163 | });
164 |
165 | TaxonomyPostTag.fromJson(Map json) {
166 | name = json['name'];
167 | slug = json['slug'];
168 | capabilities = json['capabilities'] != null
169 | ? new Capabilities.fromJson(json['capabilities'])
170 | : null;
171 | description = json['description'];
172 | labels =
173 | json['labels'] != null ? new Labels.fromJson(json['labels']) : null;
174 | types = json['types'].cast();
175 | showCloud = json['show_cloud'];
176 | hierarchical = json['hierarchical'];
177 | restBase = json['rest_base'];
178 | visibility = json['visibility'] != null
179 | ? new Visibility.fromJson(json['visibility'])
180 | : null;
181 | lLinks = json['_links'] != null ? new Links.fromJson(json['_links']) : null;
182 | }
183 |
184 | Map toJson() {
185 | final Map data = new Map();
186 |
187 | data['name'] = this.name;
188 | data['slug'] = this.slug;
189 | data['capabilities'] = this.capabilities?.toJson();
190 | data['labels'] = this.labels?.toJson();
191 | data['description'] = this.description;
192 | data['types'] = this.types;
193 | data['show_cloud'] = this.showCloud;
194 | data['hierarchical'] = this.hierarchical;
195 | data['rest_base'] = this.restBase;
196 | data['visibility'] = this.visibility?.toJson();
197 | data['_links'] = this.lLinks?.toJson();
198 |
199 | return data;
200 | }
201 | }
202 |
--------------------------------------------------------------------------------
/lib/schemas/title.dart:
--------------------------------------------------------------------------------
1 | class Title {
2 | String? raw;
3 | String? rendered;
4 |
5 | Title({this.rendered});
6 |
7 | Title.fromJson(Map json) {
8 | raw = json['raw'];
9 | rendered = json['rendered'];
10 | }
11 |
12 | Map toJson() {
13 | final Map data = new Map();
14 |
15 | data['raw'] = this.raw;
16 | data['rendered'] = this.rendered;
17 |
18 | return data;
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/lib/schemas/user.dart:
--------------------------------------------------------------------------------
1 | import 'avatar_urls.dart';
2 | import 'links.dart';
3 |
4 | class User {
5 | int? id;
6 | String? username;
7 | String? name;
8 | String? firstName;
9 | String? lastName;
10 | String? email;
11 | String? url;
12 | String? description;
13 | String? link;
14 | String? locale;
15 | String? nickname;
16 | String? slug;
17 | List? roles;
18 | String? registeredDate;
19 | UserCapabilities? capabilities;
20 | UserExtraCapabilities? extraCapabilities;
21 | AvatarUrls? avatarUrls;
22 | Map? meta;
23 | Links? lLinks;
24 | // yahya - @mymakarim
25 | String? password;
26 | // end yahya - @mymakarim
27 |
28 | User({
29 | this.id,
30 | this.username,
31 | this.name,
32 | this.firstName,
33 | this.lastName,
34 | this.email,
35 | this.url,
36 | this.description,
37 | this.link,
38 | this.locale,
39 | this.nickname,
40 | this.slug,
41 | this.roles,
42 | this.registeredDate,
43 | this.capabilities,
44 | this.extraCapabilities,
45 | this.avatarUrls,
46 | this.meta,
47 | this.lLinks,
48 | this.password,
49 | });
50 |
51 | User.fromJson(Map json) {
52 | id = json['id'];
53 | username = json['username'];
54 | name = json['name'];
55 | firstName = json['first_name'];
56 | lastName = json['last_name'];
57 | email = json['email'];
58 | url = json['url'];
59 | description = json['description'];
60 | link = json['link'];
61 | locale = json['locale'];
62 | nickname = json['nickname'];
63 | slug = json['slug'];
64 | if (json['roles'] != null) roles = json['roles'].cast();
65 | registeredDate = json['registered_date'];
66 | capabilities = json['capabilities'] != null
67 | ? new UserCapabilities.fromJson(json['capabilities'])
68 | : null;
69 | extraCapabilities = json['extra_capabilities'] != null
70 | ? new UserExtraCapabilities.fromJson(json['extra_capabilities'])
71 | : null;
72 | avatarUrls = json['avatar_urls'] != null
73 | ? new AvatarUrls.fromJson(json['avatar_urls'])
74 | : null;
75 |
76 | if (json['meta'] != null && json['meta'].length > 0) {
77 | meta = new Map();
78 | json['meta'].forEach((k, v) {
79 | meta![k] = v;
80 | });
81 | }
82 | lLinks = json['_links'] != null ? new Links.fromJson(json['_links']) : null;
83 | }
84 |
85 | Map toJson() {
86 | final Map data = new Map();
87 |
88 | data['id'] = this.id;
89 | data['username'] = this.username;
90 | data['name'] = this.name;
91 | data['first_name'] = this.firstName;
92 | data['last_name'] = this.lastName;
93 | data['email'] = this.email;
94 | data['url'] = this.url;
95 | data['description'] = this.description;
96 | data['link'] = this.link;
97 | data['locale'] = this.locale;
98 | data['nickname'] = this.nickname;
99 | data['slug'] = this.slug;
100 | data['roles'] = this.roles;
101 | data['registered_date'] = this.registeredDate;
102 | data['capabilities'] = this.capabilities?.toJson();
103 | data['extra_capabilities'] = this.extraCapabilities?.toJson();
104 | data['avatar_urls'] = this.avatarUrls?.toJson();
105 | data['meta'] = this.meta;
106 | data['_links'] = this.lLinks?.toJson();
107 | data['password'] = this.password;
108 |
109 | return data;
110 | }
111 |
112 | @override
113 | String toString() {
114 | return 'id: $id, name: $name';
115 | }
116 | }
117 |
118 | class UserCapabilities {
119 | bool? switchThemes;
120 | bool? editThemes;
121 | bool? activatePlugins;
122 | bool? editPlugins;
123 | bool? editUsers;
124 | bool? editFiles;
125 | bool? manageOptions;
126 | bool? moderateComments;
127 | bool? manageCategories;
128 | bool? manageLinks;
129 | bool? uploadFiles;
130 | bool? import;
131 | bool? unfilteredHtml;
132 | bool? editPosts;
133 | bool? editOthersPosts;
134 | bool? editPublishedPosts;
135 | bool? publishPosts;
136 | bool? editPages;
137 | bool? read;
138 | bool? level10;
139 | bool? level9;
140 | bool? level8;
141 | bool? level7;
142 | bool? level6;
143 | bool? level5;
144 | bool? level4;
145 | bool? level3;
146 | bool? level2;
147 | bool? level1;
148 | bool? level0;
149 | bool? editOthersPages;
150 | bool? editPublishedPages;
151 | bool? publishPages;
152 | bool? deletePages;
153 | bool? deleteOthersPages;
154 | bool? deletePublishedPages;
155 | bool? deletePosts;
156 | bool? deleteOthersPosts;
157 | bool? deletePublishedPosts;
158 | bool? deletePrivatePosts;
159 | bool? editPrivatePosts;
160 | bool? readPrivatePosts;
161 | bool? deletePrivatePages;
162 | bool? editPrivatePages;
163 | bool? readPrivatePages;
164 | bool? deleteUsers;
165 | bool? createUsers;
166 | bool? unfilteredUpload;
167 | bool? editDashboard;
168 | bool? updatePlugins;
169 | bool? deletePlugins;
170 | bool? installPlugins;
171 | bool? updateThemes;
172 | bool? installThemes;
173 | bool? updateCore;
174 | bool? listUsers;
175 | bool? removeUsers;
176 | bool? promoteUsers;
177 | bool? editThemeOptions;
178 | bool? deleteThemes;
179 | bool? export;
180 | bool? administrator;
181 |
182 | UserCapabilities({
183 | this.switchThemes,
184 | this.editThemes,
185 | this.activatePlugins,
186 | this.editPlugins,
187 | this.editUsers,
188 | this.editFiles,
189 | this.manageOptions,
190 | this.moderateComments,
191 | this.manageCategories,
192 | this.manageLinks,
193 | this.uploadFiles,
194 | this.import,
195 | this.unfilteredHtml,
196 | this.editPosts,
197 | this.editOthersPosts,
198 | this.editPublishedPosts,
199 | this.publishPosts,
200 | this.editPages,
201 | this.read,
202 | this.level10,
203 | this.level9,
204 | this.level8,
205 | this.level7,
206 | this.level6,
207 | this.level5,
208 | this.level4,
209 | this.level3,
210 | this.level2,
211 | this.level1,
212 | this.level0,
213 | this.editOthersPages,
214 | this.editPublishedPages,
215 | this.publishPages,
216 | this.deletePages,
217 | this.deleteOthersPages,
218 | this.deletePublishedPages,
219 | this.deletePosts,
220 | this.deleteOthersPosts,
221 | this.deletePublishedPosts,
222 | this.deletePrivatePosts,
223 | this.editPrivatePosts,
224 | this.readPrivatePosts,
225 | this.deletePrivatePages,
226 | this.editPrivatePages,
227 | this.readPrivatePages,
228 | this.deleteUsers,
229 | this.createUsers,
230 | this.unfilteredUpload,
231 | this.editDashboard,
232 | this.updatePlugins,
233 | this.deletePlugins,
234 | this.installPlugins,
235 | this.updateThemes,
236 | this.installThemes,
237 | this.updateCore,
238 | this.listUsers,
239 | this.removeUsers,
240 | this.promoteUsers,
241 | this.editThemeOptions,
242 | this.deleteThemes,
243 | this.export,
244 | this.administrator,
245 | });
246 |
247 | UserCapabilities.fromJson(Map json) {
248 | switchThemes = json['switch_themes'];
249 | editThemes = json['edit_themes'];
250 | activatePlugins = json['activate_plugins'];
251 | editPlugins = json['edit_plugins'];
252 | editUsers = json['edit_users'];
253 | editFiles = json['edit_files'];
254 | manageOptions = json['manage_options'];
255 | moderateComments = json['moderate_comments'];
256 | manageCategories = json['manage_categories'];
257 | manageLinks = json['manage_links'];
258 | uploadFiles = json['upload_files'];
259 | import = json['import'];
260 | unfilteredHtml = json['unfiltered_html'];
261 | editPosts = json['edit_posts'];
262 | editOthersPosts = json['edit_others_posts'];
263 | editPublishedPosts = json['edit_published_posts'];
264 | publishPosts = json['publish_posts'];
265 | editPages = json['edit_pages'];
266 | read = json['read'];
267 | level10 = json['level_10'];
268 | level9 = json['level_9'];
269 | level8 = json['level_8'];
270 | level7 = json['level_7'];
271 | level6 = json['level_6'];
272 | level5 = json['level_5'];
273 | level4 = json['level_4'];
274 | level3 = json['level_3'];
275 | level2 = json['level_2'];
276 | level1 = json['level_1'];
277 | level0 = json['level_0'];
278 | editOthersPages = json['edit_others_pages'];
279 | editPublishedPages = json['edit_published_pages'];
280 | publishPages = json['publish_pages'];
281 | deletePages = json['delete_pages'];
282 | deleteOthersPages = json['delete_others_pages'];
283 | deletePublishedPages = json['delete_published_pages'];
284 | deletePosts = json['delete_posts'];
285 | deleteOthersPosts = json['delete_others_posts'];
286 | deletePublishedPosts = json['delete_published_posts'];
287 | deletePrivatePosts = json['delete_private_posts'];
288 | editPrivatePosts = json['edit_private_posts'];
289 | readPrivatePosts = json['read_private_posts'];
290 | deletePrivatePages = json['delete_private_pages'];
291 | editPrivatePages = json['edit_private_pages'];
292 | readPrivatePages = json['read_private_pages'];
293 | deleteUsers = json['delete_users'];
294 | createUsers = json['create_users'];
295 | unfilteredUpload = json['unfiltered_upload'];
296 | editDashboard = json['edit_dashboard'];
297 | updatePlugins = json['update_plugins'];
298 | deletePlugins = json['delete_plugins'];
299 | installPlugins = json['install_plugins'];
300 | updateThemes = json['update_themes'];
301 | installThemes = json['install_themes'];
302 | updateCore = json['update_core'];
303 | listUsers = json['list_users'];
304 | removeUsers = json['remove_users'];
305 | promoteUsers = json['promote_users'];
306 | editThemeOptions = json['edit_theme_options'];
307 | deleteThemes = json['delete_themes'];
308 | export = json['export'];
309 | administrator = json['administrator'];
310 | }
311 |
312 | Map toJson() {
313 | final Map data = new Map();
314 |
315 | data['switch_themes'] = this.switchThemes;
316 | data['edit_themes'] = this.editThemes;
317 | data['activate_plugins'] = this.activatePlugins;
318 | data['edit_plugins'] = this.editPlugins;
319 | data['edit_users'] = this.editUsers;
320 | data['edit_files'] = this.editFiles;
321 | data['manage_options'] = this.manageOptions;
322 | data['moderate_comments'] = this.moderateComments;
323 | data['manage_categories'] = this.manageCategories;
324 | data['manage_links'] = this.manageLinks;
325 | data['upload_files'] = this.uploadFiles;
326 | data['import'] = this.import;
327 | data['unfiltered_html'] = this.unfilteredHtml;
328 | data['edit_posts'] = this.editPosts;
329 | data['edit_others_posts'] = this.editOthersPosts;
330 | data['edit_published_posts'] = this.editPublishedPosts;
331 | data['publish_posts'] = this.publishPosts;
332 | data['edit_pages'] = this.editPages;
333 | data['read'] = this.read;
334 | data['level_10'] = this.level10;
335 | data['level_9'] = this.level9;
336 | data['level_8'] = this.level8;
337 | data['level_7'] = this.level7;
338 | data['level_6'] = this.level6;
339 | data['level_5'] = this.level5;
340 | data['level_4'] = this.level4;
341 | data['level_3'] = this.level3;
342 | data['level_2'] = this.level2;
343 | data['level_1'] = this.level1;
344 | data['level_0'] = this.level0;
345 | data['edit_others_pages'] = this.editOthersPages;
346 | data['edit_published_pages'] = this.editPublishedPages;
347 | data['publish_pages'] = this.publishPages;
348 | data['delete_pages'] = this.deletePages;
349 | data['delete_others_pages'] = this.deleteOthersPages;
350 | data['delete_published_pages'] = this.deletePublishedPages;
351 | data['delete_posts'] = this.deletePosts;
352 | data['delete_others_posts'] = this.deleteOthersPosts;
353 | data['delete_published_posts'] = this.deletePublishedPosts;
354 | data['delete_private_posts'] = this.deletePrivatePosts;
355 | data['edit_private_posts'] = this.editPrivatePosts;
356 | data['read_private_posts'] = this.readPrivatePosts;
357 | data['delete_private_pages'] = this.deletePrivatePages;
358 | data['edit_private_pages'] = this.editPrivatePages;
359 | data['read_private_pages'] = this.readPrivatePages;
360 | data['delete_users'] = this.deleteUsers;
361 | data['create_users'] = this.createUsers;
362 | data['unfiltered_upload'] = this.unfilteredUpload;
363 | data['edit_dashboard'] = this.editDashboard;
364 | data['update_plugins'] = this.updatePlugins;
365 | data['delete_plugins'] = this.deletePlugins;
366 | data['install_plugins'] = this.installPlugins;
367 | data['update_themes'] = this.updateThemes;
368 | data['install_themes'] = this.installThemes;
369 | data['update_core'] = this.updateCore;
370 | data['list_users'] = this.listUsers;
371 | data['remove_users'] = this.removeUsers;
372 | data['promote_users'] = this.promoteUsers;
373 | data['edit_theme_options'] = this.editThemeOptions;
374 | data['delete_themes'] = this.deleteThemes;
375 | data['export'] = this.export;
376 | data['administrator'] = this.administrator;
377 |
378 | return data;
379 | }
380 | }
381 |
382 | class UserExtraCapabilities {
383 | bool? administrator;
384 |
385 | UserExtraCapabilities({this.administrator});
386 |
387 | UserExtraCapabilities.fromJson(Map json) {
388 | administrator = json['administrator'];
389 | }
390 |
391 | Map toJson() {
392 | final Map data = new Map();
393 |
394 | data['administrator'] = this.administrator;
395 |
396 | return data;
397 | }
398 | }
399 |
--------------------------------------------------------------------------------
/lib/schemas/wordpress_error.dart:
--------------------------------------------------------------------------------
1 | /// All API related errors are thrown as an object of this class.
2 | class WordPressError {
3 | String? code;
4 | String? message;
5 | Data? data;
6 |
7 | WordPressError({
8 | this.code,
9 | this.message,
10 | this.data,
11 | });
12 |
13 | WordPressError.fromJson(Map json) {
14 | code = json['code'];
15 | message = json['message'];
16 | data = json['data'] != null ? new Data.fromJson(json['data']) : null;
17 | }
18 |
19 | Map toJson() {
20 | final Map data = new Map();
21 |
22 | data['code'] = this.code;
23 | data['message'] = this.message;
24 | data['data'] = this.data?.toJson();
25 |
26 | return data;
27 | }
28 |
29 | @override
30 | String toString() {
31 | return 'WordPress Error! code: $code, message: $message, status: ${data == null ? null : data?.status}';
32 | }
33 | }
34 |
35 | class Data {
36 | int? status;
37 |
38 | Data({this.status});
39 |
40 | Data.fromJson(Map json) {
41 | status = json['status'];
42 | }
43 |
44 | Map toJson() {
45 | final Map data = new Map