mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-18 07:44:26 +01:00
opt.
This commit is contained in:
@@ -6,7 +6,7 @@ enum _BuildMode {
|
||||
profile,
|
||||
}
|
||||
|
||||
final _buildMode = (() {
|
||||
final _buildMode = () {
|
||||
if (const bool.fromEnvironment('dart.vm.product')) {
|
||||
return _BuildMode.release;
|
||||
}
|
||||
@@ -16,7 +16,7 @@ final _buildMode = (() {
|
||||
return true;
|
||||
}());
|
||||
return result;
|
||||
}());
|
||||
}();
|
||||
|
||||
class BuildMode {
|
||||
static bool isDebug = (_buildMode == _BuildMode.debug);
|
||||
|
||||
@@ -15,4 +15,18 @@ extension StringX on String {
|
||||
}
|
||||
|
||||
Uint8List get uint8List => Uint8List.fromList(utf8.encode(this));
|
||||
|
||||
/// Upper the first letter.
|
||||
String get upperFirst {
|
||||
if (isEmpty) {
|
||||
return this;
|
||||
}
|
||||
final runes = codeUnits;
|
||||
if (runes[0] >= 97 && runes[0] <= 122) {
|
||||
final origin = String.fromCharCode(runes[0]);
|
||||
final upper = origin.toUpperCase();
|
||||
return replaceFirst(origin, upper);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:toolbox/core/extension/stringx.dart';
|
||||
|
||||
enum OS {
|
||||
android,
|
||||
@@ -12,7 +13,7 @@ enum OS {
|
||||
fuchsia,
|
||||
unknown;
|
||||
|
||||
static final _os = () {
|
||||
static final type = () {
|
||||
if (kIsWeb) {
|
||||
return OS.web;
|
||||
}
|
||||
@@ -37,48 +38,26 @@ enum OS {
|
||||
return OS.unknown;
|
||||
}();
|
||||
|
||||
static OS get type => _os;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
switch (this) {
|
||||
case OS.android:
|
||||
return 'Android';
|
||||
case OS.ios:
|
||||
return 'iOS';
|
||||
case OS.linux:
|
||||
return 'Linux';
|
||||
case OS.macos:
|
||||
return 'macOS';
|
||||
case OS.windows:
|
||||
return 'Windows';
|
||||
case OS.web:
|
||||
return 'Web';
|
||||
case OS.fuchsia:
|
||||
return 'Fuchsia';
|
||||
case OS.unknown:
|
||||
return 'Unknown';
|
||||
}
|
||||
}
|
||||
String toString() => switch (this) {
|
||||
OS.macos => 'macOS',
|
||||
OS.ios => 'iOS',
|
||||
final val => val.name.upperFirst,
|
||||
};
|
||||
|
||||
/// Whether has platform specific settings.
|
||||
static bool get hasSettings {
|
||||
switch (type) {
|
||||
case OS.android:
|
||||
case OS.ios:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
static final hasSpecSetting = switch (type) {
|
||||
OS.android || OS.ios => true,
|
||||
_ => false,
|
||||
};
|
||||
}
|
||||
|
||||
bool get isAndroid => OS.type == OS.android;
|
||||
bool get isIOS => OS.type == OS.ios;
|
||||
bool get isLinux => OS.type == OS.linux;
|
||||
bool get isMacOS => OS.type == OS.macos;
|
||||
bool get isWindows => OS.type == OS.windows;
|
||||
bool get isWeb => OS.type == OS.web;
|
||||
bool get isMobile => OS.type == OS.ios || OS.type == OS.android;
|
||||
bool get isDesktop =>
|
||||
final isAndroid = OS.type == OS.android;
|
||||
final isIOS = OS.type == OS.ios;
|
||||
final isLinux = OS.type == OS.linux;
|
||||
final isMacOS = OS.type == OS.macos;
|
||||
final isWindows = OS.type == OS.windows;
|
||||
final isWeb = OS.type == OS.web;
|
||||
final isMobile = OS.type == OS.ios || OS.type == OS.android;
|
||||
final isDesktop =
|
||||
OS.type == OS.linux || OS.type == OS.macos || OS.type == OS.windows;
|
||||
|
||||
@@ -9,6 +9,7 @@ import 'package:toolbox/data/res/store.dart';
|
||||
import 'package:webdav_client/webdav_client.dart';
|
||||
|
||||
abstract final class Webdav {
|
||||
/// Some WebDAV provider only support non-root path
|
||||
static const _prefix = 'srvbox/';
|
||||
|
||||
static var _client = WebdavClient(
|
||||
|
||||
@@ -30,7 +30,7 @@ Future<void> loadFontFile(String localPath) async {
|
||||
if (name == null) return;
|
||||
final file = File(localPath);
|
||||
if (!await file.exists()) return;
|
||||
var fontLoader = FontLoader(name);
|
||||
final fontLoader = FontLoader(name);
|
||||
fontLoader.addFont(file.readAsBytes().byteData);
|
||||
await fontLoader.load();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user