59 lines
1.7 KiB
Dart
59 lines
1.7 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:get/get.dart';
|
|
import 'package:star_lock/debug/controller.dart';
|
|
import 'package:star_lock/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 void showFloatWidget() {
|
|
Rx<Offset> offset = Offset(20, 100).obs; // 初始位置
|
|
OverlayEntry overlayEntry = OverlayEntry(builder: (context) {
|
|
return Obx(() => Positioned(
|
|
left: offset.value.dx,
|
|
top: offset.value.dy,
|
|
child: GestureDetector(
|
|
onPanUpdate: (details) {
|
|
offset.value += details.delta;
|
|
},
|
|
child: FloatingActionButton(
|
|
child: Icon(Icons.bug_report),
|
|
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: [],
|
|
expandStackTrace: false,
|
|
savePath: null,
|
|
),
|
|
));
|
|
}
|
|
},
|
|
),
|
|
)));
|
|
});
|
|
Get.key.currentState?.overlay?.insert(overlayEntry);
|
|
}
|
|
|
|
DeBug();
|
|
}
|