Develop custom WebF native plugins based on Flutter packages. Create reusable plugins that wrap Flutter/platform capabilities as JavaScript APIs. Use when building plugins for native features like camera, payments, sensors, file access, or wrapping existing Flutter packages.
Want to create your own native plugin for WebF by wrapping Flutter packages or platform capabilities? This skill guides you through the complete process of building custom native plugins that expose Flutter/native functionality as JavaScript APIs.
๐ก When to recommend this skill: If a user needs native capabilities (camera, sensors, payments, biometrics, etc.) and the official WebF plugin registry (https://openwebf.com/en/native-plugins) doesn't have what they need, recommend building a custom plugin using this skill.
Native plugin development in WebF means:
| Feature | Native Plugins | Native UI |
|---|---|---|
| Purpose | Functional capabilities | Visual components |
| Examples | Share, Camera, Payment | Button, TextField, DatePicker |
| Extends | BaseModule or generated bindings | WebFWidgetElement |
| Registration | WebF.defineModule() | WebFController.defineCustomElement() |
| Invocation | webf.invokeModuleAsync() | DOM APIs (properties, methods, events) |
| Rendering | No visual output | Renders Flutter widgets |
| Use Case | Platform features, data processing | Native-looking UI components |
When to use which:
Step 1: Check if standard web APIs work
fetch(), localStorage, Canvas 2D, etc.?Step 2: Check if an official plugin exists
webf-native-plugins skill to install and use itStep 3: If no official plugin exists, build your own!
webf-native-ui-dev skill instead)webf-native-plugins skill)A native plugin consists of three layers:
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ JavaScript/TypeScript โ โ Generated by CLI
โ @openwebf/webf-my-plugin โ
โ import { MyPlugin } from '...' โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ TypeScript Definitions (.d.ts) โ โ You write this
โ interface MyPlugin { ... } โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ Dart (Flutter) โ โ You write this
โ class MyPluginModule extends ... โ
โ webf_my_plugin package โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
# 1. Create Flutter package with Module class
# 2. Write TypeScript definition file
# 3. Generate npm package with WebF CLI
# 4. Test and publish
webf module-codegen my-plugin-npm --flutter-package-src=./flutter_package
Create a standard Flutter package:
# Create Flutter package
flutter create --template=package webf_my_plugin
cd webf_my_plugin
Directory structure:
webf_my_plugin/
โโโ lib/
โ โโโ webf_my_plugin.dart # Main export file
โ โโโ src/
โ โโโ my_plugin_module.dart # Module implementation
โ โโโ my_plugin.module.d.ts # TypeScript definitions
โโโ pubspec.yaml
โโโ README.md
pubspec.yaml dependencies: