Skip to content

Commit b0ea424

Browse files
committed
Update Flutter SDK to add offline support
1 parent 811bd17 commit b0ea424

21 files changed

+2099
-174
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 9.0.0
2+
3+
* Add offline support
4+
15
## 8.3.0
26

37
* Fix: back navigation bringing back web browser after OAuth session creation

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22

33
[![pub package](https://img.shields.io/pub/v/appwrite?style=flat-square)](https://pub.dartlang.org/packages/appwrite)
44
![License](https://img.shields.io/github/license/appwrite/sdk-for-flutter.svg?style=flat-square)
5-
![Version](https://img.shields.io/badge/api%20version-1.2.1-blue.svg?style=flat-square)
5+
![Version](https://img.shields.io/badge/api%20version-1.3.0-blue.svg?style=flat-square)
66
[![Build Status](https://img.shields.io/travis/com/appwrite/sdk-generator?style=flat-square)](https://travis-ci.com/appwrite/sdk-generator)
77
[![Twitter Account](https://img.shields.io/twitter/follow/appwrite?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite)
88
[![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord)
99

10-
**This SDK is compatible with Appwrite server version 1.2.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-flutter/releases).**
10+
**This SDK is compatible with Appwrite server version 1.3.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-flutter/releases).**
1111

1212
Appwrite is an open-source backend as a service server that abstract and simplify complex and repetitive development tasks behind a very simple to use REST API. Appwrite aims to help you develop your apps faster and in a more secure way. Use the Flutter SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs)
1313

@@ -21,7 +21,7 @@ Add this to your package's `pubspec.yaml` file:
2121

2222
```yml
2323
dependencies:
24-
appwrite: ^8.3.0
24+
appwrite: ^9.0.0
2525
```
2626
2727
You can install packages from the command line:

example/pubspec.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
name: appwrite_example
22
environment:
3-
sdk: '>=2.17.0 <3.0.0'
3+
sdk: ">=2.17.0 <3.0.0"

lib/appwrite.dart

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,27 @@
11
library appwrite;
22

33
import 'dart:async';
4+
import 'dart:math';
45
import 'dart:typed_data';
56
import 'src/enums.dart';
67
import 'src/service.dart';
78
import 'src/input_file.dart';
89
import 'models.dart' as models;
910
import 'src/upload_progress.dart';
1011

11-
export 'src/response.dart';
1212
export 'src/client.dart';
1313
export 'src/exception.dart';
14+
export 'src/input_file.dart';
1415
export 'src/realtime.dart';
15-
export 'src/upload_progress.dart';
16-
export 'src/realtime_subscription.dart';
1716
export 'src/realtime_message.dart';
18-
export 'src/input_file.dart';
17+
export 'src/realtime_subscription.dart';
18+
export 'src/response.dart';
19+
export 'src/upload_progress.dart';
1920

20-
part 'query.dart';
21+
part 'id.dart';
2122
part 'permission.dart';
23+
part 'query.dart';
2224
part 'role.dart';
23-
part 'id.dart';
2425
part 'services/account.dart';
2526
part 'services/avatars.dart';
2627
part 'services/databases.dart';

lib/id.dart

+35-8
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,40 @@
11
part of appwrite;
22

33
class ID {
4-
ID._();
5-
6-
static String unique() {
7-
return 'unique()';
8-
}
4+
ID._();
5+
6+
// Generate a unique ID based on timestamp
7+
// Recreated from https://www.php.net/manual/en/function.uniqid.php
8+
static String _uniqid() {
9+
final now = DateTime.now();
10+
final secondsSinceEpoch = (now.millisecondsSinceEpoch / 1000).floor();
11+
final msecs = now.microsecondsSinceEpoch - secondsSinceEpoch * 1000000;
12+
return secondsSinceEpoch.toRadixString(16) +
13+
msecs.toRadixString(16).padLeft(5, '0');
14+
}
15+
16+
// Generate a unique ID with padding to have a longer ID
17+
// Recreated from https://github.com/utopia-php/database/blob/main/src/Database/ID.php#L13
18+
static String _unique({int padding = 7}) {
19+
String id = _uniqid();
20+
21+
if (padding > 0) {
22+
StringBuffer sb = StringBuffer();
23+
for (var i = 0; i < padding; i++) {
24+
sb.write(Random().nextInt(16).toRadixString(16));
25+
}
926

10-
static String custom(String id) {
11-
return id;
27+
id += sb.toString();
1228
}
13-
}
29+
30+
return id;
31+
}
32+
33+
static String unique() {
34+
return _unique();
35+
}
36+
37+
static String custom(String id) {
38+
return id;
39+
}
40+
}

0 commit comments

Comments
 (0)