Flap is a template project that enables seamless integration of Go code into Flutter applications. It allows you to compile Go code directly into your Flutter app, providing high-performance native functionality across multiple platforms.
- Cross-platform support: Web, Android, and iOS
- RPC communication: Bidirectional RPC between Dart and Go
- Push notifications: One-way push messages from Go to Dart
- Protocol Buffers: Efficient serialization with protobuf
- SQLite integration: Built-in SQLite support for data persistence
- WebAssembly: Web platform support via TinyGo and WebAssembly
- 🌐 Web (using TinyGo and WebAssembly)
- 🤖 Android
- 🍎 iOS
-
Install the Flap CLI:
brew install nosuta/flap/flap
-
Create a new project:
flap
This will check dependencies, prompt for your app name and bundle ID, clone the template, and run the full setup automatically.
- Go 1.25.0 or later
- Flutter 3.10.0 or later
- Protocol Buffers compiler (
protoc) - Perl
- npm (for Web development)
- TinyGo (for Web platform)
- Chrome (for Web testing)
-
Clone this repository:
git clone https://github.com/nosuta/flap.git cd flap -
Create custom configuration:
cp template.mk custom.mk
Edit
custom.mkto fill in your environment variables. -
Prepare the project:
make prepare
-
For Web development, prepare WebAssembly testing:
make prepare_go_wasm_test
Run on different platforms:
# Web
make web_runSee all available commands:
make helpFlap uses Protocol Buffers to define RPC services between Dart and Go. The code generators use service name suffixes to determine what code to emit.
Services ending with Service generate standard RPC clients:
service NostrService {
rpc FetchNotes(NotesRequest) returns (stream Note);
}| Side | Generated Code |
|---|---|
| Dart | NostrRpcClient — Call Go from Dart |
| Go | NostrRPCHandler interface + HandleNostrRPC() router |
Services ending with ReverseService generate reverse RPC where Go calls Dart:
service NostrReverseService {
rpc Nip07SignEvent(Nip07SignEventRequest) returns (Nip07SignEventResponse);
}| Side | Generated Code |
|---|---|
| Dart | NostrReverseRpc abstract class — Extend and implement methods |
| Go | NostrReverseRPCNip07SignEvent(ctx, req) caller function |
Messages starting with Push are one-way notifications:
message PushNip05 { ... }| Side | Generated Code |
|---|---|
| Dart | PushHandler — Typed streams per message type |
| Go | SendPushNip05(msg) pusher function |
If you started from this template, you can pull in updates:
git fetch upstream
git merge upstream/masterAt the early stage of this project, it was heavily influenced by flutter-openpgp, which convinced me of the potential of the Go–Flutter bridge.
