query static method
按条件查询设置项定义列表
根据场景类型、隐藏元素集合和屏幕方向过滤并排序设置项定义。
Queries setting item definitions filtered by scene type, hidden elements, and screen orientation, sorted by group index (insertion order preserved within the same group since Dart's List.sort is stable).
Implementation
static List<SettingItemDefinition> query({
required SceneType sceneType,
Set<String>? hiddenElements,
Orientation? orientation,
}) {
_ensureInitialized();
final results = _definitions.where((def) {
// 1. SceneType 过滤
if (def.excludedScenes.contains(sceneType)) {
return false;
}
// 2. hiddenElements 过滤
if (hiddenElements != null &&
hiddenElements.isNotEmpty &&
!hiddenElements.isElementVisible(def.elementKey)) {
return false;
}
// 3. Orientation 过滤
if (orientation == Orientation.portrait && !def.showInPortraitPanel) {
return false;
}
if (orientation == Orientation.landscape && !def.showInLandscapePanel) {
return false;
}
return true;
}).toList();
// 按 group 枚举顺序排序,同组内保持注册插入顺序(Dart List.sort 是稳定排序)
results.sort((a, b) => a.group.index.compareTo(b.group.index));
return results;
}