73 lines
2.2 KiB
Dart
Executable File
73 lines
2.2 KiB
Dart
Executable File
import 'package:flutter/material.dart';
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
import 'package:get/get.dart';
|
|
import 'package:star_lock/app_settings/app_colors.dart';
|
|
import 'package:star_lock/mine/about/debug/debug_console.dart';
|
|
|
|
class DeBug {
|
|
static void log(String message, {String? tag}) {
|
|
DebugConsole.info(message);
|
|
Get.log(message);
|
|
}
|
|
|
|
static bool open = false;
|
|
static bool openInfo = false;
|
|
static late OverlayEntry overlayEntry;
|
|
|
|
static void showFloatWidget() {
|
|
final Rx<Offset> offset = const Offset(20, 100).obs; // 初始位置
|
|
overlayEntry = OverlayEntry(builder: (BuildContext context) {
|
|
return Obx(() => Positioned(
|
|
left: offset.value.dx,
|
|
top: offset.value.dy,
|
|
child: GestureDetector(
|
|
onPanUpdate: (DragUpdateDetails details) {
|
|
offset.value += details.delta;
|
|
},
|
|
child: FloatingActionButton(
|
|
backgroundColor: AppColors.mainColor,
|
|
shape: ContinuousRectangleBorder(
|
|
borderRadius: BorderRadius.all(Radius.circular(20.r)),
|
|
side: BorderSide(color: Colors.white, width: 2.w),
|
|
),
|
|
child: const Icon(
|
|
Icons.bug_report,
|
|
color: Colors.white,
|
|
),
|
|
onPressed: () {
|
|
if (openInfo) {
|
|
Get.back();
|
|
return;
|
|
}
|
|
if (open) {
|
|
open = false;
|
|
Get.back();
|
|
} else {
|
|
open = true;
|
|
Get.to(WillPopScope(
|
|
onWillPop: () async {
|
|
open = false;
|
|
return true;
|
|
},
|
|
child: DebugConsole(
|
|
controller: DebugConsole.instance,
|
|
actions: <PopupMenuItem<void>>[],
|
|
expandStackTrace: false,
|
|
savePath: null,
|
|
),
|
|
));
|
|
}
|
|
},
|
|
),
|
|
)));
|
|
});
|
|
Get.key.currentState?.overlay?.insert(overlayEntry);
|
|
}
|
|
|
|
static void closeFloatWidget() {
|
|
overlayEntry.remove();
|
|
}
|
|
|
|
DeBug();
|
|
}
|