Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: type errors #228

Merged
merged 2 commits into from
Jan 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Add this to your package's `pubspec.yaml` file:

```yml
dependencies:
appwrite: ^13.1.0
appwrite: ^13.1.1
```

You can install packages from the command line:
Expand Down
3 changes: 3 additions & 0 deletions lib/src/client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ abstract class Client {
/// Add headers that should be sent with all API calls.
Client addHeader(String key, String value);

/// Sends a "ping" request to Appwrite to verify connectivity.
Future<String> ping();

/// Send the API request.
Future<Response> call(
HttpMethod method, {
Expand Down
3 changes: 3 additions & 0 deletions lib/src/client_base.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ abstract class ClientBase implements Client {
@override
ClientBase addHeader(String key, String value);

@override
Future<String> ping();

@override
Future<Response> call(
HttpMethod method, {
Expand Down
11 changes: 10 additions & 1 deletion lib/src/client_browser.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class ClientBrowser extends ClientBase with ClientMixin {
'x-sdk-name': 'Flutter',
'x-sdk-platform': 'client',
'x-sdk-language': 'flutter',
'x-sdk-version': '13.1.0',
'x-sdk-version': '13.1.1',
'X-Appwrite-Response-Format': '1.6.0',
};

Expand Down Expand Up @@ -115,6 +115,15 @@ class ClientBrowser extends ClientBase with ClientMixin {
return this;
}

@override
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both the methods in client_io and client_browser are same they don't need specific access to io or browser features. This method should go into base class instead

Future<String> ping() async {
final String apiPath = '/ping';
final response = await call(HttpMethod.get,
path: apiPath, responseType: ResponseType.plain);

return response.data;
}

Future init() async {
final cookieFallback = web.window.localStorage['cookieFallback'];
if (cookieFallback != null) {
Expand Down
11 changes: 10 additions & 1 deletion lib/src/client_io.dart
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class ClientIO extends ClientBase with ClientMixin {
'x-sdk-name': 'Flutter',
'x-sdk-platform': 'client',
'x-sdk-language': 'flutter',
'x-sdk-version': '13.1.0',
'x-sdk-version': '13.1.1',
'X-Appwrite-Response-Format': '1.6.0',
};

Expand Down Expand Up @@ -147,6 +147,15 @@ class ClientIO extends ClientBase with ClientMixin {
return this;
}

@override
Future<String> ping() async {
final String apiPath = '/ping';
final response = await call(HttpMethod.get,
path: apiPath, responseType: ResponseType.plain);

return response.data;
}

Future init() async {
if (_initProgress) return;
_initProgress = true;
Expand Down
3 changes: 2 additions & 1 deletion lib/src/models/document.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ class Document implements Model {
$databaseId: map['\$databaseId'].toString(),
$createdAt: map['\$createdAt'].toString(),
$updatedAt: map['\$updatedAt'].toString(),
$permissions: map['\$permissions'] ?? [],
$permissions: List<String>.from(
map['\$permissions']?.map((x) => x.toString()) ?? []),
data: map,
);
}
Expand Down
3 changes: 2 additions & 1 deletion lib/src/models/execution.dart
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ class Execution implements Model {
$id: map['\$id'].toString(),
$createdAt: map['\$createdAt'].toString(),
$updatedAt: map['\$updatedAt'].toString(),
$permissions: map['\$permissions'] ?? [],
$permissions: List<String>.from(
map['\$permissions']?.map((x) => x.toString()) ?? []),
functionId: map['functionId'].toString(),
trigger: map['trigger'].toString(),
status: map['status'].toString(),
Expand Down
3 changes: 2 additions & 1 deletion lib/src/models/file.dart
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ class File implements Model {
bucketId: map['bucketId'].toString(),
$createdAt: map['\$createdAt'].toString(),
$updatedAt: map['\$updatedAt'].toString(),
$permissions: map['\$permissions'] ?? [],
$permissions: List<String>.from(
map['\$permissions']?.map((x) => x.toString()) ?? []),
name: map['name'].toString(),
signature: map['signature'].toString(),
mimeType: map['mimeType'].toString(),
Expand Down
2 changes: 1 addition & 1 deletion lib/src/models/membership.dart
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class Membership implements Model {
joined: map['joined'].toString(),
confirm: map['confirm'],
mfa: map['mfa'],
roles: map['roles'] ?? [],
roles: List<String>.from(map['roles']?.map((x) => x.toString()) ?? []),
);
}

Expand Down
3 changes: 2 additions & 1 deletion lib/src/models/mfa_recovery_codes.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ class MfaRecoveryCodes implements Model {

factory MfaRecoveryCodes.fromMap(Map<String, dynamic> map) {
return MfaRecoveryCodes(
recoveryCodes: map['recoveryCodes'] ?? [],
recoveryCodes: List<String>.from(
map['recoveryCodes']?.map((x) => x.toString()) ?? []),
);
}

Expand Down
3 changes: 2 additions & 1 deletion lib/src/models/session.dart
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,8 @@ class Session implements Model {
countryCode: map['countryCode'].toString(),
countryName: map['countryName'].toString(),
current: map['current'],
factors: map['factors'] ?? [],
factors:
List<String>.from(map['factors']?.map((x) => x.toString()) ?? []),
secret: map['secret'].toString(),
mfaUpdatedAt: map['mfaUpdatedAt'].toString(),
);
Expand Down
2 changes: 1 addition & 1 deletion lib/src/models/user.dart
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class User implements Model {
hashOptions: map['hashOptions'],
registration: map['registration'].toString(),
status: map['status'],
labels: map['labels'] ?? [],
labels: List<String>.from(map['labels']?.map((x) => x.toString()) ?? []),
passwordUpdate: map['passwordUpdate'].toString(),
email: map['email'].toString(),
phone: map['phone'].toString(),
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: appwrite
version: 13.1.0
version: 13.1.1
description: Appwrite is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API
homepage: https://appwrite.io
repository: https://github.com/appwrite/sdk-for-flutter
Expand Down