KDE KRunner 应用程序的易用 API。
功能
- 创建 KRunner 插件(“runners”)
- 类型安全
- 空值安全
- 命名参数
- 解释各个部分的文档
用法
创建插件
import 'package:krunner/krunner.dart';
Future<void> main() async {
/// Create a runner instance.
final runner = KRunnerPlugin(
identifier: 'com.example.plugin_name',
name: '/plugin_name',
matchQuery: (String query) async {
/// If the KRunner query matches exactly `hello` we return a match.
if (query == 'hello') {
return [
QueryMatch(
id: 'uniqueMatchId',
title: 'This is presented to the user',
icon: 'checkmark',
rating: QueryMatchRating.exact,
relevance: 1.0,
properties: QueryMatchProperties(subtitle: 'Subtitle for match'),
),
];
} else {
return []; // Empty response (no matches).
}
},
retrieveActions: () async => [
SecondaryAction(
id: 'uniqueActionId',
text: 'hoverText',
icon: 'addressbook-details',
),
],
runAction: ({required String actionId, required String matchId}) async {
if (actionId == 'uniqueActionId') {
print('User clicked secondary action!');
}
},
);
/// Start the runner.
await runner.init();
}
请参阅 example 目录以获取完整的示例,包括说明
用于调试和安装插件。
有关使用此 API 创建的插件的实际示例,请参阅 VSCode Runner。