@@ -48,10 +48,10 @@ To use the client it first needs to be initialized with an endpoint and cache. I
48
48
import 'package:graphql_flutter/graphql_flutter.dart';
49
49
50
50
void main() {
51
- ValueNotifier<Client> client = new ValueNotifier(
52
- new Client(
51
+ ValueNotifier<Client> client = ValueNotifier(
52
+ Client(
53
53
endPoint: 'https://api.github.com/graphql',
54
- cache: new InMemoryCache(),
54
+ cache: InMemoryCache(),
55
55
apiToken: '<YOUR_GITHUB_PERSONAL_ACCESS_TOKEN>',
56
56
),
57
57
);
@@ -69,9 +69,9 @@ In order to use the client, you app needs to be wrapped with the `GraphqlProvide
69
69
``` dart
70
70
...
71
71
72
- return new GraphqlProvider(
72
+ return GraphqlProvider(
73
73
client: client,
74
- child: new MaterialApp(
74
+ child: MaterialApp(
75
75
title: 'Flutter Demo',
76
76
...
77
77
),
@@ -106,7 +106,7 @@ In your widget:
106
106
``` dart
107
107
...
108
108
109
- new Query(
109
+ Query(
110
110
readRepositories, // this is the query you just created
111
111
variables: {
112
112
'nRepositories': 50,
@@ -118,22 +118,22 @@ new Query(
118
118
String error,
119
119
}) {
120
120
if (error != '') {
121
- return new Text(error);
121
+ return Text(error);
122
122
}
123
123
124
124
if (loading) {
125
- return new Text('Loading');
125
+ return Text('Loading');
126
126
}
127
127
128
128
// it can be either Map or List
129
129
List repositories = data['viewer']['repositories']['nodes'];
130
130
131
- return new ListView.builder(
131
+ return ListView.builder(
132
132
itemCount: repositories.length,
133
133
itemBuilder: (context, index) {
134
134
final repository = repositories[index];
135
135
136
- return new Text(repository['name']);
136
+ return Text(repository['name']);
137
137
});
138
138
},
139
139
);
@@ -163,20 +163,20 @@ The syntax for mutations is fairly similar to that of a query. The only diffence
163
163
``` dart
164
164
...
165
165
166
- new Mutation(
166
+ Mutation(
167
167
addStar,
168
168
builder: (
169
169
runMutation, { // you can name it whatever you like
170
170
bool loading,
171
171
var data,
172
172
String error,
173
173
}) {
174
- return new FloatingActionButton(
174
+ return FloatingActionButton(
175
175
onPressed: () => runMutation({
176
176
'starrableId': <A_STARTABLE_REPOSITORY_ID>,
177
177
}),
178
178
tooltip: 'Star',
179
- child: new Icon(Icons.star),
179
+ child: Icon(Icons.star),
180
180
);
181
181
},
182
182
onCompleted: (Map<String, dynamic> data) {
@@ -208,12 +208,12 @@ You can always access the client direcly from the `GraphqlProvider` but to make
208
208
``` dart
209
209
...
210
210
211
- return new GraphqlConsumer(
211
+ return GraphqlConsumer(
212
212
builder: (Client client) {
213
213
// do something with the client
214
214
215
- return new Container(
216
- child: new Text('Hello world'),
215
+ return Container(
216
+ child: Text('Hello world'),
217
217
);
218
218
},
219
219
);
@@ -233,10 +233,10 @@ The in-memory cache can automatically be saved to and restored from offline stor
233
233
class MyApp extends StatelessWidget {
234
234
@override
235
235
Widget build(BuildContext context) {
236
- return new GraphqlProvider(
236
+ return GraphqlProvider(
237
237
client: client,
238
- child: new CacheProvider(
239
- child: new MaterialApp(
238
+ child: CacheProvider(
239
+ child: MaterialApp(
240
240
title: 'Flutter Demo',
241
241
...
242
242
),
0 commit comments