How ajmalbuv/typst_flutter works
typst_flutter embeds the Typst compiler in Flutter through a Rust FFI bridge. The main workflow initializes a compiler, supplies markup and optional virtual files, fonts, and inputs, then compiles to an opaque document handle for querying or exporting/rendering. Flutter widgets provide live previews and can reuse a shared compiler. The graph also shows diagnostics and package resolution. Dart implementation details and several README-described capabilities are not excerpted, so those links are documented relationships rather than claims of inspected call sites.
Main entry points: compiler.dart Compiler API · typst.rs Typst Engine API · document.dart Document Handle · mod.rs Compiler World
Components 17
Flutter API
- Compiler API
lib/src/compiler.dart - Document Handle
lib/src/document.dart - Virtual Files
lib/src/files.dart - Font Inputs
lib/src/fonts.dart - Compiler Provider
lib/src/widgets/typst_compiler_provider.dart - Document Viewer
lib/src/widgets/typst_document_viewer.dart - Typst View
lib/src/widgets/typst_view.dart
FFI Bridge
- Dart Bridge
lib/src/rust/api/typst.dart - Generated Bridge
rust/src/frb_generated.rs
Rust Compiler
- Typst Engine API
rust/src/api/typst.rs - Compiled Document
rust/src/api/typst.rs - Compiler World
rust/src/world/mod.rs
Compiler Support
- Diagnostics
rust/src/diag/mod.rs - Package Resolver
rust/src/package/mod.rs
Other components
- Flutter App
- Typst Registry
- Typst Runtime
Connections 20
- Flutter App → Compiler API: provides markup
README.md - Compiler API → Dart Bridge: calls
- Dart Bridge → Generated Bridge: bridges calls
- Generated Bridge → Typst Engine API: dispatches
rust/src/frb_generated.rs - Typst Engine API → Compiler World: configures
rust/src/api/typst.rs - Typst Engine API → Diagnostics: maps errors
rust/src/api/typst.rs - Compiler World → Package Resolver: resolves files
rust/src/world/mod.rs - Compiler World → Typst Runtime: supplies inputs
- Typst Engine API → Compiled Document: compiles to
rust/src/api/typst.rs - Compiled Document → Typst Runtime: renders document
rust/src/api/typst.rs - Package Resolver → Typst Registry: downloads packages
rust/src/package/mod.rs - Compiler API → Virtual Files: accepts files
README.md - Compiler API → Font Inputs: accepts fonts
README.md - Compiler API → Document Handle: returns handle
README.md - Document Handle → Dart Bridge: exports and queries
- Compiler Provider → Compiler API: shares engine
README.md - Document Viewer → Compiler Provider: reuses compiler
README.md - Document Viewer → Document Handle: previews pages
README.md - Typst View → Compiler Provider: reuses compiler
README.md - Typst View → Document Handle: renders preview