nativeapi 0.2.7 copy "nativeapi: ^0.2.7" to clipboard
nativeapi: ^0.2.7 copied to clipboard

Flutter bindings for nativeapi - providing seamless, unified access to native system APIs.

nativeapi-flutter #

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

Android iOS Linux macOS Windows
✅ ✅ ✅ ✅ ✅

🚧 Work in Progress: this package is under active development.

English | 简体中文

Installation #

flutter pub add nativeapi

Quick Start #

import 'package:nativeapi/nativeapi.dart';

for (final display in DisplayManager.instance.getAll()) {
  print('${display.name ?? ''}: ${display.size.width}x${display.size.height}');
}

Custom window chrome #

Wrap a custom title bar in DragToMoveArea to move the window by dragging (double tap to maximize/restore), and the window content in DragToResizeArea to resize from its edges and corners:

DragToResizeArea(
  resizeEdgeSize: 8,
  child: Column(
    children: [
      DragToMoveArea(
        child: SizedBox(height: 40, child: Center(child: Text('My window'))),
      ),
      Expanded(child: MyContent()),
    ],
  ),
)

Both widgets use WindowManager.instance.getCurrent() unless a window is passed. Moving via DragToMoveArea is not yet implemented on Linux.

Flutter-rendered secondary windows #

Not in the pub.flutter-io.cn package yet. package:nativeapi/windowing.dart follows Flutter's main channel and does not analyze on stable, so 0.2.7 ships without it. To use it, depend on the git repository instead.

Window.create() opens a bare native window with no Flutter view in it. To render widgets in a second window, create it with Flutter's multi-window API and hand the controller to nativeapi:

import 'package:flutter/src/widgets/_window.dart' as fw;
import 'package:nativeapi/nativeapi.dart';
import 'package:nativeapi/windowing.dart';

final controller = fw.WindowController(
  size: const Size(320, 48),
  title: 'Toolbar',
);

// In the widget tree: fw.Window(controller: controller, child: ...)

final window = controller.nativeWindow; // a nativeapi Window, same id as WindowManager's
window?.titleBarStyle = TitleBarStyle.hidden;
window?.isAlwaysOnTop = true;

All windows share one engine and one isolate, so they talk to each other through ordinary Dart objects — no runner changes, no message channels. Flutter's multi-window API is experimental: it needs the main channel and flutter config --enable-windowing, which is why the bridge lives in its own library, package:nativeapi/windowing.dart. See floating_toolbar_example for a child window built this way, and browser_tabs_example and detachable_window_example.

Examples #

See examples/. Each directory is a Flutter app for one module:

flutter pub get
cd examples/display_example
flutter run

Contributing #

This repository is developed from the workspace, which checks out the core library, every binding and the code generator together:

git clone --recursive https://github.com/libnativeapi/workspace.git

Files marked AUTO-GENERATED. DO NOT EDIT. are generated from the C++ headers in nativeapi. To change the API, send a pull request there; maintainers regenerate the bindings.

License #

MIT

30
likes
0
points
4.03k
downloads

Publisher

verified publisherleanflutter.dev

Weekly Downloads

Flutter bindings for nativeapi - providing seamless, unified access to native system APIs.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

cnativeapi, ffi, flutter, meta, path

More

Packages that depend on nativeapi