Skip to content

Commit 6a38a32

Browse files
committed
Fix constant naming in Dart templates: CHUNK_SIZE to chunkSize
1 parent 385f804 commit 6a38a32

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import 'upload_progress.dart';
88
/// [Client] that handles requests to {{spec.title | caseUcfirst}}
99
abstract class Client {
1010
/// The size for chunked uploads in bytes.
11-
static const int CHUNK_SIZE = 5 * 1024 * 1024;
11+
static const int chunkSize = 5 * 1024 * 1024;
1212

1313
/// Holds configuration such as project.
1414
late Map<String, String> config;

templates/dart/lib/src/client_browser.dart.twig

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ ClientBase createClient({
1616
ClientBrowser(endPoint: endPoint, selfSigned: selfSigned);
1717

1818
class ClientBrowser extends ClientBase with ClientMixin {
19-
static const int CHUNK_SIZE = 5*1024*1024;
19+
static const int chunkSize = 5*1024*1024;
2020
String _endPoint;
2121
Map<String, String>? _headers;
2222
@override
@@ -106,7 +106,7 @@ class ClientBrowser extends ClientBase with ClientMixin {
106106
int size = file.bytes!.length;
107107

108108
late Response res;
109-
if (size <= CHUNK_SIZE) {
109+
if (size <= chunkSize) {
110110
params[paramName] = http.MultipartFile.fromBytes(paramName, file.bytes!, filename: file.filename);
111111
return call(
112112
HttpMethod.post,
@@ -126,21 +126,21 @@ class ClientBrowser extends ClientBase with ClientMixin {
126126
headers: headers,
127127
);
128128
final int chunksUploaded = res.data['chunksUploaded'] as int;
129-
offset = chunksUploaded * CHUNK_SIZE;
129+
offset = chunksUploaded * chunkSize;
130130
} on {{spec.title | caseUcfirst}}Exception catch (_) {}
131131
}
132132

133133
while (offset < size) {
134134
List<int> chunk = [];
135-
final end = min(offset + CHUNK_SIZE, size);
135+
final end = min(offset + chunkSize, size);
136136
chunk = file.bytes!.getRange(offset, end).toList();
137137
params[paramName] =
138138
http.MultipartFile.fromBytes(paramName, chunk, filename: file.filename);
139139
headers['content-range'] =
140-
'bytes $offset-${min<int>((offset + CHUNK_SIZE - 1), size - 1)}/$size';
140+
'bytes $offset-${min<int>((offset + chunkSize - 1), size - 1)}/$size';
141141
res = await call(HttpMethod.post,
142142
path: path, headers: headers, params: params);
143-
offset += CHUNK_SIZE;
143+
offset += chunkSize;
144144
if (offset < size) {
145145
headers['x-{{spec.title | caseLower }}-id'] = res.data['\$id'];
146146
}

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ ClientBase createClient({
2020
);
2121

2222
class ClientIO extends ClientBase with ClientMixin {
23-
static const int CHUNK_SIZE = 5*1024*1024;
23+
static const int chunkSize = 5*1024*1024;
2424
String _endPoint;
2525
Map<String, String>? _headers;
2626
@override
@@ -120,7 +120,7 @@ class ClientIO extends ClientBase with ClientMixin {
120120
}
121121

122122
late Response res;
123-
if (size <= CHUNK_SIZE) {
123+
if (size <= chunkSize) {
124124
if (file.path != null) {
125125
params[paramName] = await http.MultipartFile.fromPath(
126126
paramName, file.path!,
@@ -147,7 +147,7 @@ class ClientIO extends ClientBase with ClientMixin {
147147
headers: headers,
148148
);
149149
final int chunksUploaded = res.data['chunksUploaded'] as int;
150-
offset = chunksUploaded * CHUNK_SIZE;
150+
offset = chunksUploaded * chunkSize;
151151
} on {{spec.title | caseUcfirst}}Exception catch (_) {}
152152
}
153153

@@ -160,19 +160,19 @@ class ClientIO extends ClientBase with ClientMixin {
160160
while (offset < size) {
161161
List<int> chunk = [];
162162
if (file.bytes != null) {
163-
final end = min(offset + CHUNK_SIZE, size);
163+
final end = min(offset + chunkSize, size);
164164
chunk = file.bytes!.getRange(offset, end).toList();
165165
} else {
166166
raf!.setPositionSync(offset);
167-
chunk = raf.readSync(CHUNK_SIZE);
167+
chunk = raf.readSync(chunkSize);
168168
}
169169
params[paramName] =
170170
http.MultipartFile.fromBytes(paramName, chunk, filename: file.filename);
171171
headers['content-range'] =
172-
'bytes $offset-${min<int>((offset + CHUNK_SIZE - 1), size - 1)}/$size';
172+
'bytes $offset-${min<int>((offset + chunkSize - 1), size - 1)}/$size';
173173
res = await call(HttpMethod.post,
174174
path: path, headers: headers, params: params);
175-
offset += CHUNK_SIZE;
175+
offset += chunkSize;
176176
if (offset < size) {
177177
headers['x-{{spec.title | caseLower }}-id'] = res.data['\$id'];
178178
}

0 commit comments

Comments
 (0)