Skip to content

Commit fcac80f

Browse files
committed
shorter example
1 parent 8caee07 commit fcac80f

File tree

1 file changed

+20
-49
lines changed

1 file changed

+20
-49
lines changed

templates/flutter/docs/example.md.twig

Lines changed: 20 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -3,71 +3,42 @@ import 'dart:io';
33
{% endif %}
44
import 'package:{{ language.params.packageName }}/{{ language.params.packageName }}.dart';
55

6-
{% if method.type == 'location' %}
7-
Client client = Client();
8-
{{ service.name | caseUcfirst }} {{ service.name | caseCamel }} = {{service.name | caseUcfirst}}(client);
6+
void main() { // Init SDK
7+
Client client = Client();
8+
{{ service.name | caseUcfirst }} {{ service.name | caseCamel }} = {{service.name | caseUcfirst}}(client);
99

1010
{% if method.security|length > 0 %}
11-
client
12-
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
11+
client
12+
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
1313
{% for node in method.security %}
1414
{% for key,header in node|keys %}
15-
.set{{header}}('{{node[header]['x-appwrite']['demo']}}') // {{node[header].description}}
15+
.set{{header}}('{{node[header]['x-appwrite']['demo']}}') // {{node[header].description}}
1616
{% endfor %}
1717
{% endfor %} ;
1818
{% endif %}
19-
20-
void main() { // Init SDK
21-
runApp(MyApp());
19+
{% if method.type == 'location' %}
2220
}
2321

24-
class MyApp extends StatelessWidget {
25-
@override
26-
Widget build(BuildContext context) {
27-
return Scaffold(
28-
appBer: AppBar(
29-
title: Text("Appwrite+Flutter Private Image"),
30-
),
31-
body: Container(
32-
child: FutureBuilder(
33-
future: {{ service.name | caseCamel }}.{{ method.name | caseCamel }}({% for parameter in method.parameters.all %}
22+
//displaying image
23+
FutureBuilder(
24+
future: {{ service.name | caseCamel }}.{{ method.name | caseCamel }}({% for parameter in method.parameters.all %}
3425
{% if loop.first %}
3526

3627
{% endif %}
3728
{% if parameter.required %}
38-
{{ parameter.name | caseCamel }}: {{ parameter | paramExample }},
29+
{{ parameter.name | caseCamel }}: {{ parameter | paramExample }},
3930
{% endif %}
4031
{% endfor %}{% if method.parameters.all|length > 0 %} {% endif %}
41-
), //works for both public file and private file, for private files you need to be logged in
42-
builder: (context, snapshot) {
43-
return snapshot.hasData && snapshot.data != null
44-
? Image.memory(
45-
snapshot.data.data,
46-
)
47-
: CircularProgressIndicator();
48-
},
49-
),
50-
)
51-
)
52-
}
53-
}
54-
32+
), //works for both public file and private file, for private files you need to be logged in
33+
builder: (context, snapshot) {
34+
return snapshot.hasData && snapshot.data != null
35+
? Image.memory(
36+
snapshot.data.data,
37+
)
38+
: CircularProgressIndicator();
39+
},
40+
);
5541
{% else %}
56-
57-
void main() { // Init SDK
58-
Client client = Client();
59-
{{ service.name | caseUcfirst }} {{ service.name | caseCamel }} = {{service.name | caseUcfirst}}(client);
60-
61-
{% if method.security|length > 0 %}
62-
client
63-
.setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
64-
{% for node in method.security %}
65-
{% for key,header in node|keys %}
66-
.set{{header}}('{{node[header]['x-appwrite']['demo']}}') // {{node[header].description}}
67-
{% endfor %}
68-
{% endfor %} ;
69-
70-
{% endif %}
7142
Future result = {{ service.name | caseCamel }}.{{ method.name | caseCamel }}({% for parameter in method.parameters.all %}
7243
{% if loop.first %}
7344

0 commit comments

Comments
 (0)