From de0b158aa97330b44e5171f9f952233cf8ab4a58 Mon Sep 17 00:00:00 2001 From: FantaMagier Date: Tue, 19 Oct 2021 19:46:50 +0200 Subject: [PATCH 1/2] HTTP Version updated --- example/lib/display_posts.dart | 92 +++++++++++++++++++++++----------- example/lib/post_page.dart | 2 +- pubspec.lock | 18 +++---- pubspec.yaml | 8 +-- 4 files changed, 73 insertions(+), 47 deletions(-) diff --git a/example/lib/display_posts.dart b/example/lib/display_posts.dart index fd30d81..831e52e 100644 --- a/example/lib/display_posts.dart +++ b/example/lib/display_posts.dart @@ -76,15 +76,19 @@ class PostsBuilderState extends State { // yahya - Future createUser({@required String email, @required String username, @required String password, @required List roles}) async { - await widget.wordPress.createUser( - user: wp.User( - email: email, - password: password, - username: username, - roles: roles - ) - ).then((p) { + Future createUser( + {@required String email, + @required String username, + @required String password, + @required List roles}) async { + await widget.wordPress + .createUser( + user: wp.User( + email: email, + password: password, + username: username, + roles: roles)) + .then((p) { print('User created successfully ${p}'); }).catchError((err) { print('Failed to create user: $err'); @@ -96,7 +100,8 @@ class PostsBuilderState extends State { // ===================== Future updatePost({@required int id, @required int userId}) async { - await widget.wordPress.updatePost( + await widget.wordPress + .updatePost( post: new wp.Post( title: 'First post as a Chief Editor', content: 'Blah! blah! blah!', @@ -109,38 +114,46 @@ class PostsBuilderState extends State { sticky: true, ), id: id, // - ).then((p) { + ) + .then((p) { print('Post updated successfully with ID ${p}'); }).catchError((err) { print('Failed to update post: $err'); }); } - Future updateComment({@required int id, @required int postId, @required wp.User user}) async { - await widget.wordPress.updateComment( + Future updateComment( + {@required int id, @required int postId, @required wp.User user}) async { + await widget.wordPress + .updateComment( comment: new wp.Comment( content: "Comment Updated2!", author: user.id, post: postId, ), id: id, - ).then((c) { + ) + .then((c) { print('Comment updated successfully "$c"'); }).catchError((err) { print('Failed to update Comment: $err'); }); } - Future updateUser({@required int id, @required String username, @required String email}) async { - await widget.wordPress.updateUser( + Future updateUser( + {@required int id, + @required String username, + @required String email}) async { + await widget.wordPress + .updateUser( user: new wp.User( - description: "This is description for this user", - username: username, - id: id, - email: email - ), + description: "This is description for this user", + username: username, + id: id, + email: email), id: id, - ).then((u) { + ) + .then((u) { print('User updated successfully $u'); }).catchError((err) { print('Failed to update User: $err'); @@ -239,7 +252,7 @@ class PostsBuilderState extends State { title: title, content: content, featuredMedia: featuredMedia, - id : id, + id: id, ), ), ); @@ -279,7 +292,7 @@ class PostsBuilderState extends State { padding: EdgeInsets.symmetric(horizontal: 8.0, vertical: 4.0), child: Text( title, - style: Theme.of(context).textTheme.title, + style: Theme.of(context).textTheme.headline1, ), ), _buildFeaturedMedia(featuredMedia), @@ -352,7 +365,10 @@ class PostsBuilderState extends State { onPressed: () { createPost(user: widget.user); }, - icon: Icon(Icons.add_circle, color: Colors.white,), + icon: Icon( + Icons.add_circle, + color: Colors.white, + ), label: Text( "Create New Post", style: TextStyle(color: Colors.white), @@ -360,9 +376,16 @@ class PostsBuilderState extends State { ), ElevatedButton.icon( onPressed: () { - createUser(roles: ["subscriber"], username: "myUserName", password: "123", email: "myEmail@domain.com"); + createUser( + roles: ["subscriber"], + username: "myUserName", + password: "123", + email: "myEmail@domain.com"); }, - icon: Icon(Icons.add_circle, color: Colors.white,), + icon: Icon( + Icons.add_circle, + color: Colors.white, + ), label: Text( "Create New User", style: TextStyle(color: Colors.white), @@ -370,9 +393,15 @@ class PostsBuilderState extends State { ), ElevatedButton.icon( onPressed: () { - updateUser(id: 1, email: "newuser@gmaill.com", username: "newuser"); + updateUser( + id: 1, + email: "newuser@gmaill.com", + username: "newuser"); }, - icon: Icon(Icons.settings, color: Colors.white,), + icon: Icon( + Icons.settings, + color: Colors.white, + ), label: Text( "Update User with ID #1", style: TextStyle(color: Colors.white), @@ -382,7 +411,10 @@ class PostsBuilderState extends State { onPressed: () { deleteUser(id: 1, reassign: 1); }, - icon: Icon(Icons.delete, color: Colors.white,), + icon: Icon( + Icons.delete, + color: Colors.white, + ), label: Text( "Delete User with ID #1", style: TextStyle(color: Colors.white), diff --git a/example/lib/post_page.dart b/example/lib/post_page.dart index 895d582..52b7a04 100644 --- a/example/lib/post_page.dart +++ b/example/lib/post_page.dart @@ -126,7 +126,7 @@ class PostWithCommentsState extends State { padding: EdgeInsets.all(8.0), child: Text( 'No comments', - style: Theme.of(context).textTheme.display1, + style: Theme.of(context).textTheme.bodyText1, ), ), ); diff --git a/pubspec.lock b/pubspec.lock index a7d331d..b33ac9e 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -1,6 +1,13 @@ # Generated by pub # See https://dart.dev/tools/pub/glossary#lockfile packages: + async: + dependency: transitive + description: + name: async + url: "https://pub.dartlang.org" + source: hosted + version: "2.8.2" charcode: dependency: transitive description: @@ -21,7 +28,7 @@ packages: name: http url: "https://pub.dartlang.org" source: hosted - version: "0.13.1" + version: "0.13.4" http_parser: dependency: transitive description: @@ -43,13 +50,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.8.0" - pedantic: - dependency: transitive - description: - name: pedantic - url: "https://pub.dartlang.org" - source: hosted - version: "1.11.0" source_span: dependency: transitive description: @@ -79,4 +79,4 @@ packages: source: hosted version: "1.3.0" sdks: - dart: ">=2.12.0 <3.0.0" + dart: ">=2.14.0 <3.0.0" diff --git a/pubspec.yaml b/pubspec.yaml index 396af29..cf2e6e5 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -2,16 +2,10 @@ name: flutter_wordpress description: This library uses WordPress REST-API-V2 to provide a way for your application to interact with your WordPress website. version: 0.3.0-nullsafety.0 -authors: - - Sachin Ganesh - - Suraj Shettigar - - Harm-Jan Roskam - - Yahya Makarim - - Oladapo Adeola Omonayajo homepage: https://github.com/dreamsoftin/flutter_wordpress environment: sdk: '>=2.12.0-29.7.beta <3.0.0' dependencies: - http: ^0.13.1 + http: ^0.13.4 From 12d1940f27d5248637f9fb0a05cd35a244b3415a Mon Sep 17 00:00:00 2001 From: FantaMagier Date: Tue, 19 Oct 2021 19:48:23 +0200 Subject: [PATCH 2/2] HTTP Version updated --- pubspec.yaml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pubspec.yaml b/pubspec.yaml index cf2e6e5..396af29 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -2,10 +2,16 @@ name: flutter_wordpress description: This library uses WordPress REST-API-V2 to provide a way for your application to interact with your WordPress website. version: 0.3.0-nullsafety.0 +authors: + - Sachin Ganesh + - Suraj Shettigar + - Harm-Jan Roskam + - Yahya Makarim + - Oladapo Adeola Omonayajo homepage: https://github.com/dreamsoftin/flutter_wordpress environment: sdk: '>=2.12.0-29.7.beta <3.0.0' dependencies: - http: ^0.13.4 + http: ^0.13.1