Skip to content

Commit 62fa89d

Browse files
authored
Merge pull request #66 from ragingprodigy/master
Added type-safety
2 parents 1f4bc9d + 7184c96 commit 62fa89d

39 files changed

Lines changed: 1706 additions & 1720 deletions

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## [0.3.0-nullsafety.0] - Type Safety
2+
3+
* Added type safety
4+
15
## [0.2.1] - 26/04/2020
26
* Custom post types
37

example/lib/display_posts.dart

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1+
import 'dart:async';
2+
13
import 'package:flutter/material.dart';
24
import 'package:flutter_wordpress/flutter_wordpress.dart' as wp;
5+
36
import 'post_page.dart';
47

58
class PostListPage extends StatelessWidget {
@@ -298,7 +301,7 @@ class PostsBuilderState extends State<PostsBuilder> {
298301
fontWeight: FontWeight.w200,
299302
),
300303
),
301-
RaisedButton.icon(
304+
ElevatedButton.icon(
302305
onPressed: () {
303306
createComment(postId: 1, userId: 1);
304307
},
@@ -307,7 +310,7 @@ class PostsBuilderState extends State<PostsBuilder> {
307310
"Create New Comment",
308311
),
309312
),
310-
RaisedButton.icon(
313+
ElevatedButton.icon(
311314
onPressed: () {
312315
updateComment(user: widget.user, id: 1, postId: 1);
313316
},
@@ -316,7 +319,7 @@ class PostsBuilderState extends State<PostsBuilder> {
316319
"Update Comment with ID #1",
317320
),
318321
),
319-
RaisedButton.icon(
322+
ElevatedButton.icon(
320323
onPressed: () {
321324
deleteComment(id: 1);
322325
},
@@ -325,8 +328,7 @@ class PostsBuilderState extends State<PostsBuilder> {
325328
"Delete Comment with ID #1",
326329
),
327330
),
328-
RaisedButton.icon(
329-
color: Colors.redAccent,
331+
ElevatedButton.icon(
330332
onPressed: () {
331333
updatePost(userId: widget.user.id, id: 1);
332334
},
@@ -336,8 +338,7 @@ class PostsBuilderState extends State<PostsBuilder> {
336338
style: TextStyle(color: Colors.white),
337339
),
338340
),
339-
RaisedButton.icon(
340-
color: Colors.redAccent,
341+
ElevatedButton.icon(
341342
onPressed: () {
342343
deletePost(id: 1);
343344
},
@@ -347,8 +348,7 @@ class PostsBuilderState extends State<PostsBuilder> {
347348
style: TextStyle(color: Colors.white),
348349
),
349350
),
350-
RaisedButton.icon(
351-
color: Colors.redAccent,
351+
ElevatedButton.icon(
352352
onPressed: () {
353353
createPost(user: widget.user);
354354
},
@@ -358,8 +358,7 @@ class PostsBuilderState extends State<PostsBuilder> {
358358
style: TextStyle(color: Colors.white),
359359
),
360360
),
361-
RaisedButton.icon(
362-
color: Colors.blueAccent,
361+
ElevatedButton.icon(
363362
onPressed: () {
364363
createUser(roles: ["subscriber"], username: "myUserName", password: "123", email: "myEmail@domain.com");
365364
},
@@ -369,8 +368,7 @@ class PostsBuilderState extends State<PostsBuilder> {
369368
style: TextStyle(color: Colors.white),
370369
),
371370
),
372-
RaisedButton.icon(
373-
color: Colors.blueAccent,
371+
ElevatedButton.icon(
374372
onPressed: () {
375373
updateUser(id: 1, email: "newuser@gmaill.com", username: "newuser");
376374
},
@@ -380,8 +378,7 @@ class PostsBuilderState extends State<PostsBuilder> {
380378
style: TextStyle(color: Colors.white),
381379
),
382380
),
383-
RaisedButton.icon(
384-
color: Colors.blueAccent,
381+
ElevatedButton.icon(
385382
onPressed: () {
386383
deleteUser(id: 1, reassign: 1);
387384
},

example/lib/login.dart

Lines changed: 55 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import 'package:flutter/material.dart';
22
import 'package:flutter_wordpress/flutter_wordpress.dart' as wp;
3+
34
import 'display_posts.dart';
45

56
const PADDING_16 = EdgeInsets.all(16.0);
@@ -46,67 +47,64 @@ class LoginFieldsState extends State<LoginFields> {
4647

4748
@override
4849
Widget build(BuildContext context) {
49-
// TODO: implement build
5050
return Center(
5151
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-
RaisedButton(
94-
onPressed: _isValidating ? () {} : _validateUser,
95-
color: Colors.blue,
96-
textColor: Colors.white,
97-
child: Padding(
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(
9885
padding: PADDING_8,
99-
child: _isValidating
100-
? CircularProgressIndicator(
101-
valueColor: AlwaysStoppedAnimation(Colors.white),
102-
)
103-
: Text('Login'),
86+
child: Text(
87+
"Invalid Username / Password",
88+
style: TextStyle(
89+
color: Colors.red,
90+
),
91+
),
10492
),
105-
),
106-
],
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+
),
107103
),
108-
),
109-
));
104+
],
105+
),
106+
),
107+
));
110108
}
111109

112110
Widget _buildFormField({
@@ -155,7 +153,7 @@ class LoginFieldsState extends State<LoginFields> {
155153
);
156154

157155
final response =
158-
wordPress.authenticateUser(username: _username, password: _password);
156+
wordPress.authenticateUser(username: _username, password: _password);
159157

160158
response.then((user) {
161159
setState(() {

example/lib/post_page.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import 'package:flutter/material.dart';
2-
import 'package:flutter_wordpress/flutter_wordpress.dart' as wp;
32
import 'package:flutter_html/flutter_html.dart';
3+
import 'package:flutter_wordpress/flutter_wordpress.dart' as wp;
44

55
class SinglePostPage extends StatelessWidget {
66
final wp.WordPress wordPress;
@@ -58,7 +58,6 @@ class PostWithCommentsState extends State<PostWithComments> {
5858

5959
@override
6060
Widget build(BuildContext context) {
61-
// TODO: implement build
6261
return CustomScrollView(
6362
slivers: <Widget>[
6463
SliverList(

example/pubspec.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ description: Wordpress API testing example.
88
# build by specifying --build-name and --build-number, respectively.
99
# Read more about versioning at semver.org.
1010
version: 1.0.0+1
11+
publish_to: none
1112

1213
environment:
1314
sdk: ">=2.0.0-dev.68.0 <3.0.0"

lib/constants.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ String enumStringToName(String enumString) {
151151
/// Formats a list of [items] to a comma(,) separated string to pass it as a
152152
/// URL parameter.
153153
String listToUrlString<T>(List<T> items) {
154-
if (items == null || items.length == 0) return '';
154+
if (items.length == 0) return '';
155155

156156
return items.join(',');
157157
}

0 commit comments

Comments
 (0)