@@ -60,10 +60,10 @@ To use the client it first needs to be initialized with an endpoint and cache. I
60
60
import 'package:graphql_flutter/graphql_flutter.dart';
61
61
62
62
void main() {
63
- ValueNotifier<Client> client = new ValueNotifier(
64
- new Client(
63
+ ValueNotifier<Client> client = ValueNotifier(
64
+ Client(
65
65
endPoint: 'https://api.github.com/graphql',
66
- cache: new InMemoryCache(),
66
+ cache: InMemoryCache(),
67
67
apiToken: '<YOUR_GITHUB_PERSONAL_ACCESS_TOKEN>',
68
68
),
69
69
);
@@ -81,9 +81,9 @@ In order to use the client, you app needs to be wrapped with the `GraphqlProvide
81
81
``` dart
82
82
...
83
83
84
- return new GraphqlProvider(
84
+ return GraphqlProvider(
85
85
client: client,
86
- child: new MaterialApp(
86
+ child: MaterialApp(
87
87
title: 'Flutter Demo',
88
88
...
89
89
),
@@ -118,7 +118,7 @@ In your widget:
118
118
``` dart
119
119
...
120
120
121
- new Query(
121
+ Query(
122
122
readRepositories, // this is the query you just created
123
123
variables: {
124
124
'nRepositories': 50,
@@ -130,22 +130,22 @@ new Query(
130
130
String error,
131
131
}) {
132
132
if (error != '') {
133
- return new Text(error);
133
+ return Text(error);
134
134
}
135
135
136
136
if (loading) {
137
- return new Text('Loading');
137
+ return Text('Loading');
138
138
}
139
139
140
140
// it can be either Map or List
141
141
List repositories = data['viewer']['repositories']['nodes'];
142
142
143
- return new ListView.builder(
143
+ return ListView.builder(
144
144
itemCount: repositories.length,
145
145
itemBuilder: (context, index) {
146
146
final repository = repositories[index];
147
147
148
- return new Text(repository['name']);
148
+ return Text(repository['name']);
149
149
});
150
150
},
151
151
);
@@ -175,20 +175,20 @@ The syntax for mutations is fairly similar to that of a query. The only diffence
175
175
``` dart
176
176
...
177
177
178
- new Mutation(
178
+ Mutation(
179
179
addStar,
180
180
builder: (
181
181
runMutation, { // you can name it whatever you like
182
182
bool loading,
183
183
var data,
184
184
String error,
185
185
}) {
186
- return new FloatingActionButton(
186
+ return FloatingActionButton(
187
187
onPressed: () => runMutation({
188
188
'starrableId': <A_STARTABLE_REPOSITORY_ID>,
189
189
}),
190
190
tooltip: 'Star',
191
- child: new Icon(Icons.star),
191
+ child: Icon(Icons.star),
192
192
);
193
193
},
194
194
onCompleted: (Map<String, dynamic> data) {
@@ -278,12 +278,12 @@ You can always access the client direcly from the `GraphqlProvider` but to make
278
278
``` dart
279
279
...
280
280
281
- return new GraphqlConsumer(
281
+ return GraphqlConsumer(
282
282
builder: (Client client) {
283
283
// do something with the client
284
284
285
- return new Container(
286
- child: new Text('Hello world'),
285
+ return Container(
286
+ child: Text('Hello world'),
287
287
);
288
288
},
289
289
);
@@ -303,10 +303,10 @@ The in-memory cache can automatically be saved to and restored from offline stor
303
303
class MyApp extends StatelessWidget {
304
304
@override
305
305
Widget build(BuildContext context) {
306
- return new GraphqlProvider(
306
+ return GraphqlProvider(
307
307
client: client,
308
- child: new CacheProvider(
309
- child: new MaterialApp(
308
+ child: CacheProvider(
309
+ child: MaterialApp(
310
310
title: 'Flutter Demo',
311
311
...
312
312
),
0 commit comments