AppBuilder class final

Entry point builder for Pulsar applications.

AppBuilder replaces mountApp as the primary way to configure and launch a Pulsar app. It follows a builder pattern — each method returns the same AppBuilder instance — and executes lazily when mount is called.

Responsibilities

  • Configuring the HTML document (title, lang, meta tags, favicon)
  • Injecting global stylesheets not colocated with any component
  • Awaiting async initialization before mounting (content, auth, config)
  • Mounting the root component into the DOM

Without initialization

void main() {
  AppBuilder()
    .title('My App')
    .lang('en')
    .favicon('assets/favicon.ico')
    .stylesheet('styles/global.css')
    .meta('description', 'A Pulsar application')
    .mount(() => App());
}

With async initialization

void main() {
  AppBuilder()
    .title('My App')
    .lang('en')
    .initialize(() async {
      final registry = await ContentRegistry.load(...);
      final auth = await AuthService.init();
      return (registry: registry, auth: auth);
    })
    .mount((deps) => App(
      registry: deps.registry,
      auth: deps.auth,
    ));
}

Relationship with component styles

stylesheet is for global CSS not belonging to any specific component. Component-specific styles belong in Component.styles — colocated with the component that uses them. The two are complementary, not redundant.

Constructors

AppBuilder()

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

favicon(String path) AppBuilder
Injects a <link rel="icon"> tag with path as the favicon URL.
initialize<T>(Future<T> fn()) InitializedDocument<T>
Registers an async initializer and returns a typed InitializedDocument.
lang(String value) AppBuilder
Sets the lang attribute on the <html> element. Defaults to 'en'.
meta(String name, String content) AppBuilder
Adds a <meta name="[name]" content="[content]"> tag.
mount(Component factory()) → void
Mounts the app without async initialization.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
selector(String value) AppBuilder
Sets the CSS selector for the mount point. Defaults to '#app'.
stylesheet(String path) AppBuilder
Injects a global <link rel="stylesheet"> tag.
title(String value) AppBuilder
Sets the document title — appears in the browser tab.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited