GoFilament
You're reading the docs for v1.39.1, an older release. Go to v1.40.1 (latest).

Docs v1.39.1 Guide

Flutter Multiplatform & Mobile-First Admin Engine

GoFilament introduces multi-engine admin panel support. In addition to the default Templ SSR web engine, you can run your admin panel with Flutter Multiplatform (filament.EngineFlutter), turning your admin panel into a native, responsive, mobile-first experience across iOS, Android, macOS, Windows, Linux, and compiled Web SPA:

panel := filament.NewPanel("admin").
    Path("/admin").
    BrandName("TechMart Operations").
    Flutter(). // Automatically enables Flutter engine & mounts client/build/web
    Resource(productResource)

📱 Mobile-First Features:#

  • One-Thumb Navigation: Bottom NavigationBar for natural mobile interaction without stretching across large phone screens.
  • Pull-to-Refresh: Native RefreshIndicator on all resource listings for seamless pull-to-refresh data updates.
  • Floating Action Button (FAB): Quick one-tap record creation docked at the bottom right.
  • Bottom-Sheet Forms: Record creation and editing occur inside mobile-optimized bottom sheets (showModalBottomSheet) rather than cumbersome desktop modals.
  • Swipe-to-Delete: Dismissible swipe gestures (Dismissible) with confirmation feedback.

🖥️ Responsive Desktop & Tablet Adaptation:#

  • Adaptive Breakpoints: Screen widths > 768px seamlessly switch from the bottom nav bar to an expandable NavigationRail sidebar.
  • Split-Pane & Data Grid: Displays dense tables with column sorting and split-view master-detail inspection on tablets and desktops.

⚡ Scaffolding a Flutter Admin:#

# 1. Create a Flutter-enabled panel provider
php artisan make:filament-panel MobileStore --engine=flutter

# 2. Generate the responsive Flutter admin client
php artisan make:filament-flutter MobileStore --dir=client

# 3. Run natively or compile for web
cd client && flutter run         # iOS, Android, Desktop
cd client && flutter build web   # Compiles to Web SPA served by GoLaravel

🧬 Typed Dart from the panel (flutterclient.GenerateFromPanel)#

The gofilament_admin package renders a panel from its API at runtime. When you also want static, typed Dart for your own screens, generate it from the Go panel instead of writing it by hand:

// tools/gen-flutter/main.go — run with `go run ./tools/gen-flutter`
err := flutterclient.GenerateFromPanel(panels.Admin(), "resources/flutter", flutterclient.GenerateOptions{})

or register the artisan command (it needs a function that builds your panel):

reg.Register(commands.FlutterGenerateCommand(panels.Admin, commands.DefaultFlutterDir, flutterclient.GenerateOptions{}))
// artisan filament:flutter-generate [--out=dir] [--check]

The panel is booted in-process and read through its own API with httptest: no port is opened and no create / update / delete / action handler runs (list, form and option loaders do). Five files are written to lib/generated/, each marked DO NOT EDIT; the only other files it creates are stubs for pages that have no file yet:

FileContents
schema.g.dartpanelSchema (a snapshot of /api/schema) and panelForms (resource, relation and action forms)
models.g.darta class per resource record, built from the Go record type (fromJson / toJson, unknown keys kept in raw); an …Input class per form, relation form and action form; classes for endpoint request / response types
client.g.dartPanelClient: list / find / create / update / delete / run<Action> per resource, a client per relation, and a typed method per filament.Endpoint
pages.g.dartpanelPages(PanelPageBuilders(...)): the AdminPages of every filament.FlutterPage, with one required builder each
registry.g.dartpanelAppPages and panelComponents: your pages and components from lib/pages and lib/components

resources/flutter: your Dart lives next to your Go#

Like Laravel’s resources/ folder, the panel’s Flutter app sits in the Go project, and hand-written Dart has a fixed place in it:

resources/flutter/
  lib/main.dart                 ← written once by make:filament-flutter-app
  lib/pages/pos_page.dart       ← yours: class PosPage, one file per filament.FlutterPage("pos", ...)
  lib/components/fields/signature_pad_field.dart    ← class SignaturePadField: forms.Custom(name, "signature_pad")
  lib/components/cells/paid_badge_cell.dart         ← class PaidBadgeCell: tables.CustomColumn(name, "paid_badge")
  lib/components/widgets/sales_total_widget.dart    ← class SalesTotalWidget: filament.FlutterWidget(id, "sales_total")
  lib/generated/*.g.dart        ← generator only (DO NOT EDIT)
artisan make:filament-flutter-app                 # resources/flutter, typed main.dart
artisan make:filament-flutter-page pos --label="Point of sale" --fullscreen
#   → lib/pages/pos_page.dart and the Go line: panel.Pages(filament.FlutterPage("pos", "Point of sale").Fullscreen())
artisan filament:flutter-generate                 # writes lib/generated, stubs missing pages

A page id maps to lib/pages/<snake_id>_page.dart and the class <PascalId>Page({super.key, required AdminController admin}). Declaring a page in Go and regenerating creates that file once if it is missing; the generator never changes an existing page. A page file that does not define its class stops generation with a clear error, and --check lists pages that have no file yet.

Build and ship it in the Go binary#

Like npm run build for Laravel’s resources/, one command regenerates the typed code and builds the web app; --embed turns the build into a Go package, so the panel ships as a single binary:

reg.Register(commands.FlutterBuildCommand(panels.Admin, commands.DefaultFlutterDir, flutterclient.GenerateOptions{}))
artisan filament:flutter-build --embed=internal/adminweb          # generate + flutter build web --release
artisan filament:flutter-build --no-generate -- --wasm            # extra flutter build web arguments after --
import "yourapp/internal/adminweb"

panel.FlutterFS(adminweb.FS) // instead of panel.Flutter("resources/flutter/build/web")

--embed=<dir> writes <dir>/dist (the web build) and <dir>/embed.go (package <dir name>, var FS fs.FS). Rebuilds replace dist; a dist the command did not write is never touched. FlutterFS serves any fs.FS the same way the directory server does: base href set to the panel path, version / build id tags, the loading screen, no caching of the entry files, and index.html for client-side routes. In Go code without artisan, call flutterclient.BuildWeb(appDir, flutterclient.BuildOptions{EmbedDir: ...}).

Custom field, cell and dashboard components#

When a built-in input or cell is not enough, name a Flutter component in Go and write it once in Dart:

forms.Custom("signature", "signature_pad").Required().
    Props(map[string]any{"pen_color": "#112233", "height": 160}).
    Rule(func(ctx context.Context, v any) string { /* server-side check */ return "" })

tables.CustomColumn[*Order]("paid", "paid_badge").Props(BadgeProps{Tone: "success"})

panel.Widget(filament.FlutterWidget("sales", "sales_total").Heading("Sales today").
    Data(func(ctx *filament.Context) (any, error) { return salesToday(ctx) }).
    Visible(func(ctx *filament.Context) bool { return isManager(ctx) }))

The generator creates lib/components/<kind>s/<name>_<kind>.dart with class <Name>Field / <Name>Cell / <Name>Widget once, a typed <Name><Kind>Props class in models.g.dart (inferred from the props values set in Go: a key is non-null only when every use sets it, and keeps its type only when every use agrees), and panelComponents in registry.g.dart for GoFilamentAdmin(components: panelComponents).

ComponentReceivesServer keeps
fieldAdminFieldContext: value, onChanged(v), enabled, required, errorText, propsRequired / RequiredOnCreate / Disabled / Visible and your Rule on every save
cellAdminCellContext: value, the whole row, propswhat the list endpoint returns for the user
widgetAdminWidgetContext: data from Data(...) for this user, heading, propsVisible, and Data runs per request

A component missing from the app falls back to a read-only value (cells), a “not available in this app” note (fields, widgets). The web engine shows custom fields and cells as read-only values and does not show Flutter widgets. Avoid component names whose class would clash with Flutter’s own (for example text → TextField).

void main() => runApp(GoFilamentAdmin(
      initialSchema: panelSchema, // first frame without waiting for /api/schema
      pages: panelAppPages,       // or panelPages(PanelPageBuilders(pos: ...)) to wire them yourself
    ));

// in lib/pages/pos_page.dart (PanelClient get client => PanelClient(admin.api);)
final orders = await client.salesOrders.list(search: 'SO');
await client.salesOrders.runRefund('12', const SalesOrderRefundInput(amount: 5));
final summary = await client.salesSummary(till: 't1');

Declare Flutter pages and typed endpoints in Go:

panel.
    Pages(filament.FlutterPage("pos", "Point of sale").Icon("heroicon-o-shopping-cart").Fullscreen().
        Visible(func(ctx *filament.Context) bool { return ctx.User() != nil })).
    Endpoints(filament.Endpoint("salesSummary", "GET", "/pos/tills/:till/summary",
        func(ctx *filament.Context, q SummaryQuery) (Summary, error) { ... }).
        Authorize(func(ctx *filament.Context) bool { ... }))

Endpoints are mounted under <panel>/api behind the panel’s authentication; GET and DELETE read the request struct from the query string, other methods from the JSON body. Use struct{} for no request or no response.

The server stays authoritative. The snapshot has no permissions, dashboard values, tenants or data-loaded select options: until the live schema arrives nothing can be created, edited or run, and Flutter pages are shown only when the live schema lists them in client_pages. Every request is still checked on the server. Abilities, row visibility and validation never come from generated code.

Keep it in sync in CI. Output is deterministic (sorted keys, stable order), so regenerate and fail on a diff, or use --check:

go run ./tools/gen-flutter && git diff --exit-code resources/flutter/lib/generated

The generator reads the panel as a SimpleShieldUser with the super-admin role and the * permission. If your authorization callbacks type-assert your own user type, pass one in GenerateOptions.User. Generated files are not dart formatted; leave lib/generated out of format checks. flutterclient.GenerateFlutterAdmin (the old 12k-line scaffold) is deprecated: use GenerateAdminApp for the app and GenerateFromPanel for its typed code.

📎 Uploads from API clients#

POST <panel>/api/resources/<slug>/uploads?field=<name> (multipart file) stores a file for a FileUpload / ImageUpload field of the resource form and answers {value, url, name}; the client then saves value in the form. The user must be able to see the resource; the field’s MaxSize (KB) and AcceptedFileTypes are checked against the bytes, not the client’s claim (PNG, JPEG, GIF, WebP, PDF, ZIP… are sniffed; other types go by extension). Files are stored on the field’s golaravel storage Disk(...) under Directory(...) with a random name, or by your panel.UploadsUsing(fn). Disk("") without UploadsUsing refuses uploads (501). The saved value is only a reference: check it in your handler before trusting it.

🔐 Panel login on golaravel sessions#

Give the panel a credential check and a user loader; golaravel’s session manager does the rest (cookie, driver, lifetime, CSRF, logout):

drv, _ := session.NewSQLDriver(db, database.Postgres) // or NewRedisDriver, NewFileDriver...
_ = drv.Migrate(ctx)
mgr := session.NewManager(session.Config{Driver: drv, SecretKey: os.Getenv("APP_KEY"), Lifetime: 8 * time.Hour})

panel.Login().
    AuthValidator(checkPassword). // func(ctx, login, password) (auth.Authenticatable, token, error); token is ignored for the web engine
    Sessions(mgr, func(ctx *filament.Context, id string) (auth.Authenticatable, error) {
        return users.Find(ctx.GoContext(), id) // reloaded on every request
    })

Sign-in calls auth.Login (new session id, new CSRF token, the session row gets user_id), sign-out calls auth.Logout, and auth.User(c) works in your own handlers. Sessions(nil, users) uses session.DefaultManager() (keyed by APP_KEY). To end a user’s sessions everywhere, call mgr.DestroyUserSessions(userID). The session lifetime is the manager’s Lifetime; SessionDuration / RememberMeDuration apply to API tokens.

For the API and Flutter, panel.BearerGuard(auth.BearerGuardFunc(jwt, provider)) checks bearer tokens with golaravel’s guard (TokenValidator still works).

Migrating: replace WebSessionsUsing(s.WebSessions(), loader) with Sessions(mgr, loader). WebSessionsUsing and the in-memory fallback are deprecated; existing sessions in gofilament_web_sessions are not carried over, so users sign in once more. Using a TokenValidator token as the web cookie keeps working but is superseded by Sessions.

👤 Profile, password and two-factor screens#

panel.Accounts(...) turns on the web engine’s account screens. Each group of callbacks enables one feature:

panel.Accounts(filament.Accounts{
    // Profile page (user menu → Profile)
    Profile:       func(ctx *filament.Context, u auth.Authenticatable) (name, email string, err error) { ... },
    UpdateProfile: func(ctx *filament.Context, u auth.Authenticatable, name, email string) error { ... },
    // Change password (profile page) and reset password
    PasswordHash:   func(ctx *filament.Context, u auth.Authenticatable) (string, error) { ... },
    UpdatePassword: func(ctx *filament.Context, u auth.Authenticatable, newHash string) error { ... },
    // Forgot password: "Forgot password?" on the sign-in page
    FindByEmail:   func(ctx *filament.Context, email string) (auth.Authenticatable, error) { ... },
    SendResetLink: func(ctx *filament.Context, u auth.Authenticatable, email, link string) error { ... }, // e.g. golaravel mail
    ResetTokens:   resets, // auth.NewSQLResetTokenStore(db, dialect); default in memory
    // Two-factor sign-in with an authenticator app (needs panel.Sessions)
    TwoFactorSecret:     func(ctx *filament.Context, u auth.Authenticatable) (string, error) { ... },
    SaveTwoFactorSecret: func(ctx *filament.Context, u auth.Authenticatable, secret string) error { ... },
    // Optional single-use recovery codes (the panel passes SHA-256 hashes)
    RecoveryCodes:     func(ctx *filament.Context, u auth.Authenticatable) ([]string, error) { ... },
    SaveRecoveryCodes: func(ctx *filament.Context, u auth.Authenticatable, hashes []string) error { ... },
})
  • Changing the password needs the current one and signs out the user’s other devices; a reset signs out all of them (with panel.Sessions).
  • Reset links are single-use, expire after ResetTTL (60 minutes), and the page answers the same for unknown addresses. Requests are throttled.
  • With a TOTP secret saved, sign-in asks for a code after the password. Codes are single-use (golaravel’s cache; use a shared cache store on several instances) and attempts are throttled. Turning it off needs the password.
  • With RecoveryCodes, turning two-factor on makes 8 recovery codes, shown once on the profile page. Each one replaces a code at sign-in once; the profile shows how many are left and can make a new set.
  • The topbar now shows the signed-in user’s name with the user menu (Profile when available, Sign Out, and panel.UserMenu items).

Flutter and other API clients get the same screens over the API (bearer token): GET/PUT /account, POST /account/password, /account/two-factor/{enable,confirm,disable,recovery-codes} and POST /forgot-password (the link opens the web reset page). GET /boot lists the available ones under auth.accounts. The Flutter app shows Your account in the account menu, a Forgot your password? link and the code step at sign-in.

With two-factor on, POST /login answers {"two_factor": true, "challenge": "..."} instead of a token; POST /login/two-factor {challenge, code} returns the token once a valid authenticator or recovery code is given. The issued token waits in golaravel’s cache (use a shared store on several instances); without panel.Sessions the user is looked up as a PanelUser with the login id, so TwoFactorSecret should find users by GetAuthIdentifier().

Sign-up and email verification:

panel.Registration().Accounts(filament.Accounts{
    // ...the callbacks above, plus:
    Register: func(ctx *filament.Context, name, email, passwordHash string) (auth.Authenticatable, error) {
        // create the user; return filament.ErrEmailTaken for a used address
    },
    EmailVerified:        func(ctx *filament.Context, u auth.Authenticatable) (bool, error) { ... },
    MarkEmailVerified:    func(ctx *filament.Context, u auth.Authenticatable) error { ... },
    SendVerificationLink: func(ctx *filament.Context, u auth.Authenticatable, email, link string) error { ... },
})
  • /register (web) and POST /api/register create the account (throttled per IP) and sign the new user in; the login screens link to it.
  • With the verification callbacks, new users get a signed link (golaravel’s EmailVerificationBroker, keyed by VerificationSecret or APP_KEY, valid VerificationTTL, default 60 minutes). Until it is opened the web panel shows only a “verify your email” page and the API answers 403 with "email_unverified": true; the Flutter app shows a matching screen. EmailVerified runs on every request, and existing users must count as verified, so mark them before you turn this on.

🗄️ Keeping runtime state in your database (pkg/sqlstore)#

By default (without Sessions, see above) web-engine sessions, database notifications, the activity log and support tickets live in process memory: they vanish on restart and are not shared between processes. sqlstore keeps them in any database/sql database (SQLite, MySQL, Postgres):

s := sqlstore.New(db, sqlstore.Postgres)
if err := s.Migrate(ctx); err != nil { log.Fatal(err) } // creates gofilament_* tables

notifications.SetDefaultStore(s.Notifications())
activitylog.SetDefaultStore(s.Activities())
gsupport.SetDefaultStore(s.Tickets()) // golaravel/pkg/support

panel.WebSessionsUsing(s.WebSessions(), func(ctx *filament.Context, id string) (auth.Authenticatable, error) {
    return users.Find(ctx.GoContext(), id) // reloaded on every request: disabling a user ends their sessions
})

Session ids are stored as hashes, never as the cookie value; s.WebSessions().DeleteUserSessions(ctx, userID) signs a user out everywhere. Broadcast notifications (sent to "all") are marked read per user. For login throttling across processes, give golaravel’s ratelimit a Redis store.

🔌 Standardized Panel REST API:#

The Flutter client and external integrations connect to GoFilament’s standardized JSON REST API:

  • GET /admin/api/schema: Panel metadata, registered resources, fields, and navigation groups.
  • GET /admin/api/resources/:slug: Paginated, searchable, sortable list endpoints.
  • GET /admin/api/resources/:slug/export: Direct streaming data export (format=csv|tsv|json, ids, search, filters).
  • POST /admin/api/resources/:slug/import: High-throughput batch import (multipart CSV file, raw CSV string, or JSON array batches).
  • GET/POST/PUT/DELETE /admin/api/resources/:slug/:id: Full CRUD with Shield policy authorization.
  • GET /admin/api/tenants & POST /admin/api/tenants/switch: Active tenant management.
  • GET /admin/api/widgets: Real-time KPI stats overview and sparklines.

Generated from README.md at v1.39.1 · released Nov 17, 2026