Skip to main content

native_kit_platform_interface 0.1.1 copy "native_kit_platform_interface: ^0.1.1" to clipboard
native_kit_platform_interface: ^0.1.1 copied to clipboard

Platform interface and Pigeon contract for native_kit, the federated plugin that invokes true OS-native UI, pickers, scanners and system sheets.

example/README.md

native_kit_platform_interface example #

Apps should depend on native_kit. This package is useful when you implement a new platform or want to fake the native layer in tests.

Faking native UI in tests #

Every Pigeon host API is a plain class, so tests can extend it and inject the fake through PigeonNativeKitPlatform:

import 'package:flutter_test/flutter_test.dart';
import 'package:native_kit/native_kit.dart';
import 'package:native_kit_platform_interface/native_kit_platform_interface.dart';

class FakeOverlays extends OverlaysHostApi {
  @override
  Future<AlertResultDto?> showAlert(AlertRequestDto request) async =>
      AlertResultDto(actionId: 'delete', textValues: <String>[]);
}

void main() {
  test('confirms deletion', () async {
    NativeKitPlatform.instance = PigeonNativeKitPlatform(overlays: FakeOverlays());

    final NativeAlertResult? result = await NativeKit.showAlert(title: 'Delete?');

    expect(result?.actionId, 'delete');
  });
}

Implementing a platform #

Extend PigeonNativeKitPlatform (or NativeKitPlatform) and register it:

class NativeKitMyPlatform extends PigeonNativeKitPlatform {
  static void registerWith() {
    NativeKitPlatform.instance = NativeKitMyPlatform();
  }
}

The native side implements the six host APIs generated from pigeons/native_kit_api.dart (OverlaysHostApi, ValuePickersHostApi, ZeroPermPickersHostApi, VisionMediaHostApi, SystemUtilitiesHostApi, SecurityHardwareHostApi).

0
likes
160
points
0
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Platform interface and Pigeon contract for native_kit, the federated plugin that invokes true OS-native UI, pickers, scanners and system sheets.

Repository (GitHub)
View/report issues
Contributing

Topics

#native #ui #adaptive #modals #pickers

License

MIT (license)

Dependencies

flutter, meta, plugin_platform_interface

More

Packages that depend on native_kit_platform_interface