mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-17 15:24:35 +01:00
48 lines
1.4 KiB
Dart
48 lines
1.4 KiB
Dart
import 'dart:async';
|
|
import 'dart:io';
|
|
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter/services.dart';
|
|
import 'package:url_launcher/url_launcher.dart';
|
|
|
|
import 'misc.dart';
|
|
import 'platform.dart';
|
|
import '../extension/stringx.dart';
|
|
import '../extension/uint8list.dart';
|
|
|
|
Future<bool> openUrl(String url) async {
|
|
return await launchUrl(url.uri, mode: LaunchMode.externalApplication);
|
|
}
|
|
|
|
void setTransparentNavigationBar(BuildContext context) {
|
|
if (isAndroid) {
|
|
SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge);
|
|
SystemChrome.setSystemUIOverlayStyle(
|
|
const SystemUiOverlayStyle(
|
|
systemNavigationBarColor: Colors.transparent,
|
|
systemNavigationBarContrastEnforced: true),
|
|
);
|
|
}
|
|
}
|
|
|
|
Future<void> loadFontFile(String localPath) async {
|
|
if (localPath.isEmpty) return;
|
|
final name = getFileName(localPath);
|
|
if (name == null) return;
|
|
final file = File(localPath);
|
|
if (!await file.exists()) return;
|
|
var fontLoader = FontLoader(name);
|
|
fontLoader.addFont(file.readAsBytes().byteData);
|
|
await fontLoader.load();
|
|
}
|
|
|
|
void switchStatusBar({required bool hide}) {
|
|
if (hide) {
|
|
SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersiveSticky,
|
|
overlays: []);
|
|
} else {
|
|
SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge,
|
|
overlays: [SystemUiOverlay.top, SystemUiOverlay.bottom]);
|
|
}
|
|
}
|