clean(packages): apply dart fix (close #106)
continuous-integration/drone/push Build is passing

This commit was merged in pull request #107.
This commit is contained in:
AN12345
2022-12-13 13:52:49 -05:00
parent 3c8ff373a1
commit 17ff0f8ba1
74 changed files with 222 additions and 287 deletions
@@ -21,7 +21,7 @@ class Convert {
final buffer = StringBuffer();
for (final int part in bytes) {
if (part & 0xff != part) {
throw FormatException('Non-byte integer detected');
throw const FormatException('Non-byte integer detected');
}
buffer.write('${part < 16 ? '0' : ''}${part.toRadixString(16)}');
}
@@ -21,8 +21,8 @@ import 'package:crypto/crypto.dart';
class Crypto {
/// Hash a string using MD5
static String md5Hash(String data) {
final content = Utf8Encoder().convert(data);
final md5Crypto = md5;
final content = const Utf8Encoder().convert(data);
const md5Crypto = md5;
final digest = md5Crypto.convert(content).toString();
return digest;
}
@@ -24,9 +24,9 @@ abstract class Delay {
return Duration.zero;
}
final rand = Random();
final Duration delayFactor = const Duration(milliseconds: 200);
final double randomizationFactor = 0.25;
final Duration maxDelay = const Duration(seconds: 30);
const Duration delayFactor = Duration(milliseconds: 200);
const double randomizationFactor = 0.25;
const Duration maxDelay = Duration(seconds: 30);
final rf = randomizationFactor * (rand.nextDouble() * 2 - 1) + 1;
final exp = min(attempt, 31); // prevent overflows.
@@ -19,7 +19,9 @@ import 'dart:math';
import 'package:wyatt_http_client/src/utils/convert.dart';
import 'package:wyatt_http_client/src/utils/crypto.dart';
class DigestAuth {
class DigestAuth { // request counter
DigestAuth(this.username, this.password);
String username;
String password;
@@ -30,9 +32,7 @@ class DigestAuth {
String? _nonce;
String? _opaque;
int _nc = 0; // request counter
DigestAuth(this.username, this.password);
int _nc = 0;
/// Splits WWW-Authenticate header into a map.
Map<String, String>? splitWWWAuthenticateHeader(String header) {
@@ -61,9 +61,7 @@ class DigestAuth {
return Convert.toHex(values);
}
String _formatNonceCount(int nc) {
return nc.toRadixString(16).padLeft(8, '0');
}
String _formatNonceCount(int nc) => nc.toRadixString(16).padLeft(8, '0');
String _computeHA1(
String realm,
@@ -148,7 +146,7 @@ class DigestAuth {
}
String getAuthString(String method, Uri url) {
final _cnonce = _computeNonce();
final cnonce = _computeNonce();
_nc += 1;
// if url has query parameters, append query to path
final path = url.hasQuery ? '${url.path}?${url.query}' : url.path;
@@ -162,7 +160,7 @@ class DigestAuth {
_qop,
_opaque,
_realm!,
_cnonce,
cnonce,
_nonce,
_nc,
username,
@@ -192,7 +190,5 @@ class DigestAuth {
}
}
bool isReady() {
return _nonce != null && (_nc == 0 || _qop != null);
}
bool isReady() => _nonce != null && (_nc == 0 || _qop != null);
}
@@ -95,29 +95,17 @@ enum HttpStatus {
return false;
}
bool isInfo() {
return statusCode >= 100 && statusCode < 200;
}
bool isInfo() => statusCode >= 100 && statusCode < 200;
bool isSuccess() {
return statusCode >= 200 && statusCode < 300;
}
bool isSuccess() => statusCode >= 200 && statusCode < 300;
bool isRedirection() {
return statusCode >= 300 && statusCode < 400;
}
bool isRedirection() => statusCode >= 300 && statusCode < 400;
bool isClientError() {
return statusCode >= 400 && statusCode < 500;
}
bool isClientError() => statusCode >= 400 && statusCode < 500;
bool isServerError() {
return statusCode >= 500 && statusCode < 600;
}
bool isServerError() => statusCode >= 500 && statusCode < 600;
factory HttpStatus.from(int status) {
return HttpStatus.values
factory HttpStatus.from(int status) => HttpStatus.values
.firstWhere((element) => element.statusCode == status);
}
}