Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated Http Version to the newest #76

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 62 additions & 30 deletions example/lib/display_posts.dart
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,19 @@ class PostsBuilderState extends State<PostsBuilder> {

// yahya

Future<void> createUser({@required String email, @required String username, @required String password, @required List<String> roles}) async {
await widget.wordPress.createUser(
user: wp.User(
email: email,
password: password,
username: username,
roles: roles
)
).then((p) {
Future<void> createUser(
{@required String email,
@required String username,
@required String password,
@required List<String> 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');
Expand All @@ -96,7 +100,8 @@ class PostsBuilderState extends State<PostsBuilder> {
// =====================

Future<void> 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!',
Expand All @@ -109,38 +114,46 @@ class PostsBuilderState extends State<PostsBuilder> {
sticky: true,
),
id: id, //
).then((p) {
)
.then((p) {
print('Post updated successfully with ID ${p}');
}).catchError((err) {
print('Failed to update post: $err');
});
}

Future<void> updateComment({@required int id, @required int postId, @required wp.User user}) async {
await widget.wordPress.updateComment(
Future<void> 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<void> updateUser({@required int id, @required String username, @required String email}) async {
await widget.wordPress.updateUser(
Future<void> 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');
Expand Down Expand Up @@ -239,7 +252,7 @@ class PostsBuilderState extends State<PostsBuilder> {
title: title,
content: content,
featuredMedia: featuredMedia,
id : id,
id: id,
),
),
);
Expand Down Expand Up @@ -279,7 +292,7 @@ class PostsBuilderState extends State<PostsBuilder> {
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),
Expand Down Expand Up @@ -352,27 +365,43 @@ class PostsBuilderState extends State<PostsBuilder> {
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),
),
),
ElevatedButton.icon(
onPressed: () {
createUser(roles: ["subscriber"], username: "myUserName", password: "123", email: "[email protected]");
createUser(
roles: ["subscriber"],
username: "myUserName",
password: "123",
email: "[email protected]");
},
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),
),
),
ElevatedButton.icon(
onPressed: () {
updateUser(id: 1, email: "[email protected]", username: "newuser");
updateUser(
id: 1,
email: "[email protected]",
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),
Expand All @@ -382,7 +411,10 @@ class PostsBuilderState extends State<PostsBuilder> {
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),
Expand Down
2 changes: 1 addition & 1 deletion example/lib/post_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ class PostWithCommentsState extends State<PostWithComments> {
padding: EdgeInsets.all(8.0),
child: Text(
'No comments',
style: Theme.of(context).textTheme.display1,
style: Theme.of(context).textTheme.bodyText1,
),
),
);
Expand Down
18 changes: 9 additions & 9 deletions pubspec.lock
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand Down Expand Up @@ -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"