You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
**This SDK is compatible with Appwrite server version 0.11.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-flutter/releases).**
@@ -79,6 +79,23 @@ For **Mac OS** add your app name and Bundle ID, You can find your Bundle Identif
79
79
### Web
80
80
Appwrite 0.7, and the Appwrite Flutter SDK 0.3.0 have added support for Flutter Web. To build web apps that integrate with Appwrite successfully, all you have to do is add a web platform on your Appwrite project's dashboard and list the domain your website will use to allow communication to the Appwrite API.
81
81
82
+
For web in order to capture the OAuth2 callback URL and send it to the application using JavaScript `postMessage()`, you need to create an html file inside `./web` folder of your Flutter project. For example `auth.html` with the following content.
83
+
84
+
```html
85
+
<!DOCTYPE html>
86
+
<title>Authentication complete</title>
87
+
<p>Authentication is complete. If this does not happen automatically, please
88
+
close the window.
89
+
<script>
90
+
window.opener.postMessage({
91
+
flutter-web-auth:window.location.href
92
+
}, window.location.origin);
93
+
window.close();
94
+
</script>
95
+
```
96
+
97
+
Redirection URL passed to the authentication service must be the same as the URL on which the application is running (schema, host, port if necessary) and the path must point to created HTML file, /auth.html in this case. The callbackUrlScheme parameter of the authenticate() method does not take into account, so it is possible to use a schema for native platforms in the code.
98
+
82
99
#### Flutter Web Cross-Domain Communication & Cookies
83
100
While running Flutter Web, make sure your Appwrite server and your Flutter client are using the same top-level domain and the same protocol (HTTP or HTTPS) to communicate. When trying to communicate between different domains or protocols, you may receive HTTP status error 401 because some modern browsers block cross-site or insecure cookies for enhanced privacy. In production, Appwrite allows you set multiple [custom-domains](https://appwrite.io/docs/custom-domains) for each project.
84
101
@@ -91,14 +108,16 @@ For **Windows** add your app <u>name</u> and <u>package name</u>, Your package n
91
108
92
109
```dart
93
110
import 'package:appwrite/appwrite.dart';
94
-
Client client = Client();
95
111
112
+
void main() {
113
+
Client client = Client();
96
114
97
-
client
98
-
.setEndpoint('https://localhost/v1') // Your Appwrite Endpoint
99
-
.setProject('5e8cf4f46b5e8') // Your project ID
100
-
.setSelfSigned() // Use only on dev mode with a self-signed SSL cert
101
-
;
115
+
client
116
+
.setEndpoint('https://localhost/v1') // Your Appwrite Endpoint
117
+
.setProject('5e8cf4f46b5e8') // Your project ID
118
+
.setSelfSigned() // Use only on dev mode with a self-signed SSL cert
119
+
;
120
+
}
102
121
```
103
122
104
123
Before starting to send any API calls to your new Appwrite instance, make sure your Android or iOS emulators has network access to the Appwrite server hostname or IP address.
@@ -124,25 +143,28 @@ Response user = await account
124
143
125
144
```dart
126
145
import 'package:appwrite/appwrite.dart';
127
-
Client client = Client();
128
146
147
+
void main() {
148
+
Client client = Client();
129
149
130
-
client
131
-
.setEndpoint('https://localhost/v1') // Your Appwrite Endpoint
132
-
.setProject('5e8cf4f46b5e8') // Your project ID
133
-
.setSelfSigned() // Use only on dev mode with a self-signed SSL cert
134
-
;
135
150
151
+
client
152
+
.setEndpoint('https://localhost/v1') // Your Appwrite Endpoint
153
+
.setProject('5e8cf4f46b5e8') // Your project ID
154
+
.setSelfSigned() // Use only on dev mode with a self-signed SSL cert
0 commit comments