flutter_mana
是一个 Flutter 应用内调试平台,它提供了统一的调试入口和面板,内置了多个实用调试插件,同时支持开发者注册自定义插件。
因为
flutter_ume
不维护,项目因此而生,mana
的名字来自于一部国漫《灵笼》中的玛娜设定,强烈推荐!
安装
shell
# 安装核心
flutter pub add flutter_mana
# 安装插件
flutter pub add flutter_mana_kits
使用
dart
import 'package:flutter/material.dart';
import 'package:flutter_mana/flutter_mana.dart';
import 'package:flutter_mana_kits/flutter_mana_kits.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
// 注册插件
ManaPluginManager.instance
..register(ManaPackageInfo())
..register(ManaMemoryInfo())
..register(ManaShowCode())
..register(ManaLogViewer())
..register(ManaDeviceInfo())
..register(ManaColorSucker())
..register(ManaDioInspector())
..register(ManaWidgetInfoInspector())
..register(ManaFpsMonitor())
..register(ManaSharedPreferencesViewer())
..register(ManaAlignRuler());
// 包裹
runApp(ManaWidget(child: MyApp()));
}
class App extends StatelessWidget {
const App({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
title: 'Example',
home: Text('Example'),
);
}
}
尽量在开发环境使用,部分插件只在开发环境才能生效!!!
插件
- 标尺 - AlignRuler
- 日志查看器 - LogViewer
- 设备信息 - DeviceInfo
- 颜色吸管 - ColorSucker
- Dio网络检查器 - DioInspector
- Widget详情 - WidgetInfoInspector
- 帧率监控 - FpsMonitor
- SharedPreferences查看器 - SharedPreferencesViewer
- 显示代码 - ShowCode
- 内存信息 - MemoryInfo
- 包信息 - PackageInfo
插件开发
只要实现插件接口即可注册使用
- 接口定义
dart
abstract class ManaPluggable {
/// The unique identifier name for the plugin.
///
/// 插件的唯一标识名。
String get name;
/// Returns the localized display name for the plugin.
/// This supports internationalization.
///
/// 插件在界面上显示的名字,支持国际化。
String getLocalizedDisplayName(Locale locale);
/// Called when the plugin is triggered.
/// This method should contain the plugin's main logic.
///
/// 当插件被触发时调用的方法,执行主要逻辑。
void onTrigger();
/// Optionally builds a widget to display the plugin's content within the UI.
/// Returns `null` if the plugin does not have a visual component.
///
/// 可选地构建一个 Widget,用于在界面中展示该插件的内容。
/// 如果插件没有可视化组件,则返回 `null`。
Widget? buildWidget(BuildContext? context);
/// Returns the [ImageProvider] for the plugin's icon, used for displaying the plugin's visual representation.
///
/// 获取插件图标的 [ImageProvider],用于展示插件图标。
ImageProvider get iconImageProvider;
/// Async initialization for the plugin.
///
/// 插件的异步初始化方法
Future<void> initialize();
}
预览
- 面板

- 日志查看器

- 内存信息

更多功能和预览,请查看链接