Skip to content

Commit 06d8deb

Browse files
authored
Merge pull request #97 from appwrite/dev
feat: Dart SDK update for version 19.4.0
2 parents bd9aa35 + fdf0f04 commit 06d8deb

26 files changed

+1317
-724
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Change Log
22

3+
## 19.4.0
4+
5+
* Add `getScreenshot` method to `Avatars` service
6+
* Add enums `Theme`, `Output` and `Timezone`
7+
* Update runtime enums to add support for `dart39` and `flutter335` runtimes
8+
* Fix passing of `null` values and stripping only non-nullable optional parameters from the request body
9+
310
## 19.3.0
411

512
* Add `total` parameter to list queries allowing skipping counting rows in a table for improved performance

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Add this to your package's `pubspec.yaml` file:
2323

2424
```yml
2525
dependencies:
26-
dart_appwrite: ^19.3.0
26+
dart_appwrite: ^19.4.0
2727
```
2828
2929
You can install packages from the command line:
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import 'package:dart_appwrite/dart_appwrite.dart';
2+
3+
Client client = Client()
4+
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
5+
.setProject('<YOUR_PROJECT_ID>') // Your project ID
6+
.setSession(''); // The user session to authenticate with
7+
8+
Avatars avatars = Avatars(client);
9+
10+
UInt8List result = await avatars.getScreenshot(
11+
url: 'https://example.com',
12+
headers: {}, // (optional)
13+
viewportWidth: 1, // (optional)
14+
viewportHeight: 1, // (optional)
15+
scale: 0.1, // (optional)
16+
theme: .light, // (optional)
17+
userAgent: '<USER_AGENT>', // (optional)
18+
fullpage: false, // (optional)
19+
locale: '<LOCALE>', // (optional)
20+
timezone: .africaAbidjan, // (optional)
21+
latitude: -90, // (optional)
22+
longitude: -180, // (optional)
23+
accuracy: 0, // (optional)
24+
touch: false, // (optional)
25+
permissions: [], // (optional)
26+
sleep: 0, // (optional)
27+
width: 0, // (optional)
28+
height: 0, // (optional)
29+
quality: -1, // (optional)
30+
output: .jpg, // (optional)
31+
);

lib/enums.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ part 'src/enums/o_auth_provider.dart';
77
part 'src/enums/browser.dart';
88
part 'src/enums/credit_card.dart';
99
part 'src/enums/flag.dart';
10+
part 'src/enums/theme.dart';
11+
part 'src/enums/timezone.dart';
12+
part 'src/enums/output.dart';
1013
part 'src/enums/relationship_type.dart';
1114
part 'src/enums/relation_mutate.dart';
1215
part 'src/enums/index_type.dart';

lib/services/account.dart

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class Account extends Service {
3636
'userId': userId,
3737
'email': email,
3838
'password': password,
39-
'name': name,
39+
if (name != null) 'name': name,
4040
};
4141

4242
final Map<String, String> apiHeaders = {
@@ -82,8 +82,8 @@ class Account extends Service {
8282
final String apiPath = '/account/identities';
8383

8484
final Map<String, dynamic> apiParams = {
85-
'queries': queries,
86-
'total': total,
85+
if (queries != null) 'queries': queries,
86+
if (total != null) 'total': total,
8787
};
8888

8989
final Map<String, String> apiHeaders = {};
@@ -137,8 +137,8 @@ class Account extends Service {
137137
final String apiPath = '/account/logs';
138138

139139
final Map<String, dynamic> apiParams = {
140-
'queries': queries,
141-
'total': total,
140+
if (queries != null) 'queries': queries,
141+
if (total != null) 'total': total,
142142
};
143143

144144
final Map<String, String> apiHeaders = {};
@@ -562,7 +562,7 @@ class Account extends Service {
562562

563563
final Map<String, dynamic> apiParams = {
564564
'password': password,
565-
'oldPassword': oldPassword,
565+
if (oldPassword != null) 'oldPassword': oldPassword,
566566
};
567567

568568
final Map<String, String> apiHeaders = {
@@ -936,7 +936,7 @@ class Account extends Service {
936936
final Map<String, dynamic> apiParams = {
937937
'userId': userId,
938938
'email': email,
939-
'phrase': phrase,
939+
if (phrase != null) 'phrase': phrase,
940940
};
941941

942942
final Map<String, String> apiHeaders = {
@@ -973,8 +973,8 @@ class Account extends Service {
973973
final Map<String, dynamic> apiParams = {
974974
'userId': userId,
975975
'email': email,
976-
'url': url,
977-
'phrase': phrase,
976+
if (url != null) 'url': url,
977+
if (phrase != null) 'phrase': phrase,
978978
};
979979

980980
final Map<String, String> apiHeaders = {
@@ -1010,9 +1010,9 @@ class Account extends Service {
10101010
.replaceAll('{provider}', provider.value);
10111011

10121012
final Map<String, dynamic> params = {
1013-
'success': success,
1014-
'failure': failure,
1015-
'scopes': scopes,
1013+
if (success != null) 'success': success,
1014+
if (failure != null) 'failure': failure,
1015+
if (scopes != null) 'scopes': scopes,
10161016
'project': client.config['project'],
10171017
};
10181018

lib/services/avatars.dart

Lines changed: 81 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ class Avatars extends Service {
2424
'/avatars/browsers/{code}'.replaceAll('{code}', code.value);
2525

2626
final Map<String, dynamic> params = {
27-
'width': width,
28-
'height': height,
29-
'quality': quality,
27+
if (width != null) 'width': width,
28+
if (height != null) 'height': height,
29+
if (quality != null) 'quality': quality,
3030
'project': client.config['project'],
3131
'session': client.config['session'],
3232
};
@@ -54,9 +54,9 @@ class Avatars extends Service {
5454
'/avatars/credit-cards/{code}'.replaceAll('{code}', code.value);
5555

5656
final Map<String, dynamic> params = {
57-
'width': width,
58-
'height': height,
59-
'quality': quality,
57+
if (width != null) 'width': width,
58+
if (height != null) 'height': height,
59+
if (quality != null) 'quality': quality,
6060
'project': client.config['project'],
6161
'session': client.config['session'],
6262
};
@@ -100,9 +100,9 @@ class Avatars extends Service {
100100
'/avatars/flags/{code}'.replaceAll('{code}', code.value);
101101

102102
final Map<String, dynamic> params = {
103-
'width': width,
104-
'height': height,
105-
'quality': quality,
103+
if (width != null) 'width': width,
104+
if (height != null) 'height': height,
105+
if (quality != null) 'quality': quality,
106106
'project': client.config['project'],
107107
'session': client.config['session'],
108108
};
@@ -129,8 +129,8 @@ class Avatars extends Service {
129129

130130
final Map<String, dynamic> params = {
131131
'url': url,
132-
'width': width,
133-
'height': height,
132+
if (width != null) 'width': width,
133+
if (height != null) 'height': height,
134134
'project': client.config['project'],
135135
'session': client.config['session'],
136136
};
@@ -161,10 +161,10 @@ class Avatars extends Service {
161161
final String apiPath = '/avatars/initials';
162162

163163
final Map<String, dynamic> params = {
164-
'name': name,
165-
'width': width,
166-
'height': height,
167-
'background': background,
164+
if (name != null) 'name': name,
165+
if (width != null) 'width': width,
166+
if (height != null) 'height': height,
167+
if (background != null) 'background': background,
168168
'project': client.config['project'],
169169
'session': client.config['session'],
170170
};
@@ -183,9 +183,72 @@ class Avatars extends Service {
183183

184184
final Map<String, dynamic> params = {
185185
'text': text,
186-
'size': size,
187-
'margin': margin,
188-
'download': download,
186+
if (size != null) 'size': size,
187+
if (margin != null) 'margin': margin,
188+
if (download != null) 'download': download,
189+
'project': client.config['project'],
190+
'session': client.config['session'],
191+
};
192+
193+
final res = await client.call(HttpMethod.get,
194+
path: apiPath, params: params, responseType: ResponseType.bytes);
195+
return res.data;
196+
}
197+
198+
/// Use this endpoint to capture a screenshot of any website URL. This endpoint
199+
/// uses a headless browser to render the webpage and capture it as an image.
200+
///
201+
/// You can configure the browser viewport size, theme, user agent,
202+
/// geolocation, permissions, and more. Capture either just the viewport or the
203+
/// full page scroll.
204+
///
205+
/// When width and height are specified, the image is resized accordingly. If
206+
/// both dimensions are 0, the API provides an image at original size. If
207+
/// dimensions are not specified, the default viewport size is 1280x720px.
208+
Future<Uint8List> getScreenshot(
209+
{required String url,
210+
Map? headers,
211+
int? viewportWidth,
212+
int? viewportHeight,
213+
double? scale,
214+
enums.Theme? theme,
215+
String? userAgent,
216+
bool? fullpage,
217+
String? locale,
218+
enums.Timezone? timezone,
219+
double? latitude,
220+
double? longitude,
221+
double? accuracy,
222+
bool? touch,
223+
List<String>? permissions,
224+
int? sleep,
225+
int? width,
226+
int? height,
227+
int? quality,
228+
enums.Output? output}) async {
229+
final String apiPath = '/avatars/screenshots';
230+
231+
final Map<String, dynamic> params = {
232+
'url': url,
233+
if (headers != null) 'headers': headers,
234+
if (viewportWidth != null) 'viewportWidth': viewportWidth,
235+
if (viewportHeight != null) 'viewportHeight': viewportHeight,
236+
if (scale != null) 'scale': scale,
237+
if (theme != null) 'theme': theme!.value,
238+
if (userAgent != null) 'userAgent': userAgent,
239+
if (fullpage != null) 'fullpage': fullpage,
240+
if (locale != null) 'locale': locale,
241+
if (timezone != null) 'timezone': timezone!.value,
242+
if (latitude != null) 'latitude': latitude,
243+
if (longitude != null) 'longitude': longitude,
244+
if (accuracy != null) 'accuracy': accuracy,
245+
if (touch != null) 'touch': touch,
246+
if (permissions != null) 'permissions': permissions,
247+
if (sleep != null) 'sleep': sleep,
248+
if (width != null) 'width': width,
249+
if (height != null) 'height': height,
250+
if (quality != null) 'quality': quality,
251+
if (output != null) 'output': output!.value,
189252
'project': client.config['project'],
190253
'session': client.config['session'],
191254
};

0 commit comments

Comments
 (0)