Skip to content

Commit 0721992

Browse files
authored
Merge pull request #1214 from appwrite/chore-improve-dart-flutter-pub-dev-score
chore: ensure the full analysis options are used when formatting
2 parents 6a75a4d + e95cd68 commit 0721992

File tree

12 files changed

+30
-19
lines changed

12 files changed

+30
-19
lines changed

templates/dart/.github/workflows/format.yml.twig

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ jobs:
2020
persist-credentials: true
2121
ref: ${{ '{{'}} github.event.pull_request.head.ref {{ '}}' }}
2222

23+
- name: Install dependencies
24+
run: dart pub get
25+
2326
- name: Format Dart code
2427
run: dart format .
2528

@@ -29,5 +32,5 @@ jobs:
2932
- name: Add & Commit
3033
uses: EndBug/[email protected]
3134
with:
32-
add: lib
35+
add: '["lib", "test"]'
3336

templates/dart/base/requests/oauth.twig

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,11 @@
1616
params.forEach((key, value) {
1717
if (value is List) {
1818
for (var item in value) {
19-
query.add(Uri.encodeComponent(key + '[]') + '=' + Uri.encodeComponent(item));
19+
query.add(
20+
'${Uri.encodeComponent('$key[]')}=${Uri.encodeComponent(item)}');
2021
}
2122
} else if (value != null) {
22-
query.add(Uri.encodeComponent(key) + '=' + Uri.encodeComponent(value));
23+
query.add('${Uri.encodeComponent(key)}=${Uri.encodeComponent(value)}');
2324
}
2425
});
2526

templates/dart/lib/query.dart.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ class Query {
66
final String? attribute;
77
final dynamic values;
88

9-
Query._(this.method, [this.attribute = null, this.values = null]);
9+
Query._(this.method, [this.attribute, this.values]);
1010

1111
Map<String, dynamic> toJson() {
1212
final result = <String, dynamic>{};

templates/dart/lib/src/client.dart.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ abstract class Client {
4242
///
4343
/// {{header.description}}
4444
{% endif %}
45-
Client set{{header.key | caseUcfirst}}(value);
45+
Client set{{header.key | caseUcfirst}}(String value);
4646

4747
{% endfor %}
4848
/// Add headers that should be sent with all API calls.

templates/dart/lib/src/client_mixin.dart.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ mixin ClientMixin {
4545
return MapEntry(key, value.toString());
4646
}
4747
if (value is List) {
48-
return MapEntry(key + "[]", value);
48+
return MapEntry("$key[]", value);
4949
}
5050
return MapEntry(key, value);
5151
});

templates/flutter/.github/workflows/format.yml.twig

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ on:
1010
jobs:
1111
format:
1212
runs-on: ubuntu-latest
13-
container:
14-
image: dart:stable
1513

1614
steps:
1715
- name: Checkout repository
@@ -20,6 +18,14 @@ jobs:
2018
persist-credentials: true
2119
ref: ${{ '{{'}} github.event.pull_request.head.ref {{ '}}' }}
2220

21+
- name: Install Flutter
22+
uses: subosito/flutter-action@v2
23+
with:
24+
channel: stable
25+
26+
- name: Install dependencies
27+
run: flutter pub get
28+
2329
- name: Format Dart code
2430
run: dart format .
2531

@@ -29,5 +35,5 @@ jobs:
2935
- name: Add & Commit
3036
uses: EndBug/[email protected]
3137
with:
32-
add: lib
38+
add: '["lib", "test"]'
3339

templates/flutter/base/requests/oauth.twig

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,11 @@
1616
params.forEach((key, value) {
1717
if (value is List) {
1818
for (var item in value) {
19-
query.add(Uri.encodeComponent(key + '[]') + '=' + Uri.encodeComponent(item));
19+
query.add(
20+
'${Uri.encodeComponent('$key[]')}=${Uri.encodeComponent(item)}');
2021
}
2122
} else if(value != null) {
22-
query.add(Uri.encodeComponent(key) + '=' + Uri.encodeComponent(value));
23+
query.add('${Uri.encodeComponent(key)}=${Uri.encodeComponent(value)}');
2324
}
2425
});
2526

templates/flutter/lib/src/client.dart.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ abstract class Client {
6161
///
6262
/// {{header.description}}.
6363
{% endif %}
64-
Client set{{header.key | caseUcfirst}}(value);
64+
Client set{{header.key | caseUcfirst}}(String value);
6565

6666
{% endfor %}
6767
/// Add headers that should be sent with all API calls.

templates/flutter/lib/src/client_io.dart.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ class ClientIO extends ClientBase with ClientMixin {
181181
} catch (e) {
182182
debugPrint('Error getting device info: $e');
183183
device = Platform.operatingSystem;
184-
addHeader('user-agent', '$device');
184+
addHeader('user-agent', device);
185185
}
186186

187187
_initialized = true;

templates/flutter/lib/src/client_mixin.dart.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ mixin ClientMixin {
4545
return MapEntry(key, value.toString());
4646
}
4747
if (value is List) {
48-
return MapEntry(key + "[]", value);
48+
return MapEntry("$key[]", value);
4949
}
5050
return MapEntry(key, value);
5151
});

0 commit comments

Comments
 (0)