html2app • JS Bridge
    Preparing search index...

    Variable WebViewConst

    WebView: {
        get isReady(): boolean;
        get isWebView(): boolean;
        on: (event: string, listener: (...args: any[]) => void) => void;
        off: (event: string, listener: (...args: any[]) => void) => void;
        offMany: (events: string) => void;
        init: () => void;
        destroy: () => void;
        sendAsync: <T extends Record<string, any>>(
            message: Message,
        ) => Promise<MessageResponse<T>>;
        sendVoid: (message: Message) => void;
        get fullscreen(): { enter: () => void; exit: () => void };
        get persistentStorage(): {
            setItem: (key: string, value: string) => Promise<boolean>;
            getItem: (key: string) => Promise<string | null>;
            removeItem: (key: string) => Promise<boolean>;
            clear: () => Promise<boolean>;
        };
        get statusBar(): {
            setColor: (color: string) => Promise<MessageResponse<{}>>;
            setIconsBrightness: (
                brightness: "light" | "dark",
            ) => Promise<MessageResponse<{}>>;
        };
        get navigationBar(): {
            setColor: (color: string) => Promise<MessageResponse<{}>>;
        };
        getPlatform(): Promise<"android" | "ios" | "web" | "unknown">;
        get orientation(): {
            setLandscape: () => void;
            setPortrait: () => void;
            setAutoRotate: () => void;
        };
        exitApp(): void;
        deviceInfo(): Promise<MessageResponse<DeviceInfo>>;
        packageInfo(): Promise<MessageResponse<PackageInfo>>;
    } = ...

    Main interface for Flutter WebView communication.

    Type Declaration

    • get isReady(): boolean

      Whether the bridge is initialized and ready

    • get isWebView(): boolean

      Whether running inside Flutter WebView

    • on: (event: string, listener: (...args: any[]) => void) => void

      Add an event listener for a specific event name.

    • off: (event: string, listener: (...args: any[]) => void) => void

      Remove a specific event listener for a specific event name.

    • offMany: (events: string) => void

      Remove all event listeners with a specific event name.

    • init: () => void

      Initialize or reinitialize the communication bridge.

    • destroy: () => void

      Clean up all resources to prevent memory leaks.

    • sendAsync: <T extends Record<string, any>>(message: Message) => Promise<MessageResponse<T>>

      Send a raw async message to Flutter and wait for response (useful for debugging).

    • sendVoid: (message: Message) => void

      Send a raw fire-and-forget message to Flutter (useful for debugging).

    • get fullscreen(): { enter: () => void; exit: () => void }
    • get persistentStorage(): {
          setItem: (key: string, value: string) => Promise<boolean>;
          getItem: (key: string) => Promise<string | null>;
          removeItem: (key: string) => Promise<boolean>;
          clear: () => Promise<boolean>;
      }
    • get statusBar(): {
          setColor: (color: string) => Promise<MessageResponse<{}>>;
          setIconsBrightness: (
              brightness: "light" | "dark",
          ) => Promise<MessageResponse<{}>>;
      }
    • getPlatform: function
      • Get the platform the app is running on

        Returns Promise<"android" | "ios" | "web" | "unknown">

    • get orientation(): { setLandscape: () => void; setPortrait: () => void; setAutoRotate: () => void }

      Get orientation controls

    • exitApp: function
      • Exit the app

        Returns void

    • deviceInfo: function
    • packageInfo: function

    Provides access to platform services like status bar, persistent storage, orientation, and device information through readonly properties.

    import { WebView } from '@yandeu/js-bridge'

    if (WebView.isReady) {
    await WebView.statusBar.setColor('#000000')
    }