| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152 |
- import 'package:flutter/material.dart';
- import 'tools/binomial_distribution.dart';
- import 'tools/bisection_method.dart';
- import 'tools/chi_square.dart';
- import 'tools/circle_equation.dart';
- import 'tools/convolution_calculator.dart';
- import 'tools/cuo_wei_xiang_jian.dart';
- import 'tools/function_plotter.dart';
- import 'tools/histogram.dart';
- import 'tools/hypergeometric_distribution.dart';
- import 'tools/mixed_variance.dart';
- import 'tools/parametric_plotter.dart';
- import 'tools/regression.dart';
- import 'tools/statistical_charts.dart';
- import 'tools/symmetry.dart';
- import 'tools/vector_normal.dart';
- /// 一个数学工具插件。
- ///
- /// 插件是**编译期**的 Dart 模块 —— Dart 是 AOT 编译的,没有运行时动态加载,
- /// 所以"插件"在这里就是「一套接口 + 一张写死的注册表」,加插件要重新编译。
- /// 按设计(Q18),用户和 MCP 都不能创建插件,只有开发者能。
- @immutable
- class ToolPlugin {
- /// 显示名,同时用于搜索。
- final String name;
- final IconData icon;
- /// 页面入口。每次导航都新建实例,保证工具状态是干净的。
- final Widget Function() build;
- /// 命令入口(可选)。
- ///
- /// 按 Q26b 的约定 **先只做页面入口,命令入口增量补** —— 目前全部为 null。
- /// 接命令时,这里填命令名,并在控制台的 _runCommand 里分发。
- final String? command;
- /// 额外的搜索关键词(拼音首字母等)。
- final List<String> keywords;
- const ToolPlugin({
- required this.name,
- required this.icon,
- required this.build,
- this.command,
- this.keywords = const [],
- });
- bool matches(String q) {
- final query = q.trim().toLowerCase();
- if (query.isEmpty) return true;
- if (name.toLowerCase().contains(query)) return true;
- if (command?.toLowerCase().contains(query) ?? false) return true;
- return keywords.any((k) => k.toLowerCase().contains(query));
- }
- }
- /// 全部插件。顺序沿用 mathtool2 的注册表。
- final List<ToolPlugin> kTools = [
- ToolPlugin(
- name: '错位相减法',
- icon: Icons.functions,
- keywords: ['cuowei', 'cwxj', '数列'],
- build: () => CuoWeiXiangJianPage(),
- ),
- ToolPlugin(
- name: '二项分布',
- icon: Icons.casino_outlined,
- keywords: ['binomial', 'exbf', '概率'],
- build: () => BinomialDistributionPage(),
- ),
- ToolPlugin(
- name: '超几何分布',
- icon: Icons.pie_chart_outline,
- keywords: ['hypergeometric', 'cjhf', '概率'],
- build: () => HypergeometricDistributionPage(),
- ),
- ToolPlugin(
- name: '卷积分布列',
- icon: Icons.layers_outlined,
- keywords: ['convolution', 'juanji', 'jj'],
- build: () => ConvolutionCalculatorPage(),
- ),
- ToolPlugin(
- name: '卡方检验',
- icon: Icons.rule,
- keywords: ['chi square', 'kfjy', '统计'],
- build: () => ChiSquarePage(),
- ),
- ToolPlugin(
- name: '线性回归',
- icon: Icons.show_chart,
- keywords: ['regression', 'xxhg', '统计'],
- build: () => RegressionPage(),
- ),
- ToolPlugin(
- name: '混合方差',
- icon: Icons.balance_outlined,
- keywords: ['variance', 'hhfc', '统计'],
- build: () => MixedVariancePage(),
- ),
- ToolPlugin(
- name: '直方图统计',
- icon: Icons.bar_chart,
- keywords: ['histogram', 'zft', '统计'],
- build: () => HistogramPage(),
- ),
- ToolPlugin(
- name: '统计图表',
- icon: Icons.area_chart,
- keywords: ['chart', 'tjth', '图表'],
- build: () => StatisticalChartsPage(),
- ),
- ToolPlugin(
- name: '对称变换',
- icon: Icons.swap_horiz,
- keywords: ['symmetry', 'dcbh', '几何'],
- build: () => SymmetryPage(),
- ),
- ToolPlugin(
- name: '圆的方程',
- icon: Icons.circle_outlined,
- keywords: ['circle', 'ydfc', '几何'],
- build: () => CircleEquationPage(),
- ),
- ToolPlugin(
- name: '三点法向量',
- icon: Icons.view_in_ar_outlined,
- keywords: ['normal', 'sdfxl', '向量', '立体几何'],
- build: () => VectorNormalPage(),
- ),
- ToolPlugin(
- name: '二分法求根',
- icon: Icons.search,
- keywords: ['bisection', 'effqg', '求根'],
- build: () => BisectionMethodPage(),
- ),
- ToolPlugin(
- name: '函数图像绘制',
- icon: Icons.timeline,
- keywords: ['plot', 'hstx', '绘图'],
- build: () => FunctionPlotterPage(),
- ),
- ToolPlugin(
- name: '参数方程绘图',
- icon: Icons.gesture,
- keywords: ['parametric', 'csfc', '绘图'],
- build: () => ParametricPlotterPage(),
- ),
- ];
|