Add android vpn options Support proxies icon configuration Optimize android immersion display Fix some issues
51 lines
1.1 KiB
Dart
51 lines
1.1 KiB
Dart
import 'dart:convert';
|
|
import 'dart:typed_data';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
extension StringExtension on String {
|
|
bool get isUrl {
|
|
return RegExp(r'^(http|https|ftp)://').hasMatch(this);
|
|
}
|
|
|
|
int compareToLower(String other) {
|
|
return toLowerCase().compareTo(
|
|
other.toLowerCase(),
|
|
);
|
|
}
|
|
|
|
List<int> get encodeUtf16LeWithBom {
|
|
final byteData = ByteData(length * 2);
|
|
final bom = [0xFF, 0xFE];
|
|
for (int i = 0; i < length; i++) {
|
|
int charCode = codeUnitAt(i);
|
|
byteData.setUint16(i * 2, charCode, Endian.little);
|
|
}
|
|
return bom + byteData.buffer.asUint8List();
|
|
}
|
|
|
|
Uint8List? get getBase64 {
|
|
final regExp = RegExp(r'base64,(.*)');
|
|
final match = regExp.firstMatch(this);
|
|
final realValue = match?.group(1) ?? '';
|
|
if (realValue.isEmpty) {
|
|
return null;
|
|
}
|
|
try {
|
|
return base64.decode(realValue);
|
|
} catch (e) {
|
|
return null;
|
|
}
|
|
}
|
|
|
|
bool get isRegex {
|
|
try {
|
|
RegExp(this);
|
|
return true;
|
|
} catch (e) {
|
|
debugPrint(e.toString());
|
|
return false;
|
|
}
|
|
}
|
|
}
|