A user-friendly API for KDE’s KRunner application
Read Time:52 Second

A user-friendly API for KDE’s KRunner application

0 0
A user-friendly API for KDE's KRunner application

A user-friendly API for KDE’s KRunner application.

Features

  • Create KRunner plugins (“runners”)
    • Type safe
    • Null safe
    • Named parameters
    • Documentation explaining the various parts

Usage

Creating plugins

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();
}

Refer to the example directory for a complete example, including instructions
for debugging and installing plugins.

For a real-world example of a plugin made with this API see VSCode Runner.

Additional Information

API Documentation

GitHub

View Github

Happy
Happy
0 %
Sad
Sad
0 %
Excited
Excited
0 %
Sleepy
Sleepy
0 %
Angry
Angry
0 %
Surprise
Surprise
0 %

Average Rating

5 Star
0%
4 Star
0%
3 Star
0%
2 Star
0%
1 Star
0%

Deja una respuesta

Entrada anterior Flutter’s core Dropdown Button widget with steady dropdown menu and many options you can customize to your needs
Entrada siguiente An Instagram homepage design experiment with Flutter