Skip to main content

nativeapi_flutter 0.5.10 copy "nativeapi_flutter: ^0.5.10" to clipboard
nativeapi_flutter: ^0.5.10 copied to clipboard

Flutter integration for nativeapi: widgets, dart:ui conversions and the multi-window bridge on top of package:nativeapi.

nativeapi_flutter #

Flutter integration for nativeapi: unified access to native system APIs — windows, tray icons, menus, displays, keyboard, dialogs, storage and more.

nativeapi itself is plain Dart. This package is what a Flutter app depends on: it re-exports nativeapi and adds

  • widgets: DragToMoveArea, DragToResizeArea, DragOutArea, DropRegion, ContextMenuRegion;
  • ImageAsset.fromAsset(), loading a nativeapi Image from a Flutter asset;
  • conversions between nativeapi's value types and dart:ui's: point.toOffset(), size.toSize(), rectangle.toRect(), color.toColor(), and toNative() on Offset, Size, Rect, Color and Brightness;
  • package:nativeapi_flutter/windowing.dart, which bridges Flutter's experimental multi-window API to nativeapi windows.

Installation #

flutter pub add nativeapi_flutter
import 'package:flutter/widgets.dart';
import 'package:nativeapi_flutter/nativeapi_flutter.dart';

final window = WindowManager.instance.getCurrent();
window?.contentSize = const Size(800, 600).toNative();
final Rect bounds = window!.bounds.toRect();

Size conversions #

Flutter's Size and nativeapi's Size are different types. Use toNative() when passing a Flutter size to nativeapi, and toSize() when reading a nativeapi size into Flutter:

import 'package:flutter/widgets.dart';
import 'package:nativeapi_flutter/nativeapi_flutter.dart';

Size configureWindow(Window window) {
  // Flutter Size -> nativeapi Size.
  window.minimumSize = const Size(400, 300).toNative();
  window.setSize(const Size(800, 600).toNative(), false);

  // nativeapi Size -> Flutter Size.
  return window.size.toSize();
}

The same conversions apply to contentSize and maximumSize. Both extensions are exported by nativeapi_flutter; no direct dependency on or import of nativeapi is needed for these conversions.

Native type names #

The nativeapi names that Flutter already uses are not re-exported: Brightness, Color, Display, Image and Size would shadow dart:ui's, and ModifierKey and ShortcutManager would be ambiguous. To name one of them, also depend on nativeapi and import it with a prefix:

import 'package:nativeapi/nativeapi.dart' as na;

final List<na.Display> displays = DisplayManager.instance.getAll();

License #

MIT

4
likes
160
points
47.4k
downloads

Documentation

API reference

Publisher

verified publisherleanflutter.dev

Weekly Downloads

Flutter integration for nativeapi: widgets, dart:ui conversions and the multi-window bridge on top of package:nativeapi.

Homepage
Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

flutter, nativeapi, path

More

Packages that depend on nativeapi_flutter