Ask the assistant
0/400
Your question is processed by an AI service and kept to improve answers. Do not enter personal data.

    Device, screen and scrolling as data

    Generators that publish into @ variables what the device or the screen knows: location ( GeoData ), a platform permission ( PermissionData ), the content version ( AppUpdate ), the visibility of a block ( InView ), scrolling ( ScrollData ). Clipboard gives a ready copy callback. None of them draws anything of its own — what they wrap is drawn; actions ( request , apply , copy ) come as callbacks in variables , and any button calls them with onPressed:$name .

    All six are available in every build. Where a capability is missing, the outputs say so ( supported:false , null), and the children are drawn as usual — one template opens everywhere.

    GeoData

    The device's location.

    Type: wrapper

    @lat:0.0
    @lon:0.0
    GeoData supported:@hasGeo status:@geoStatus request:@locate onLocated:(la, lo){lat = la; lon = lo}
      Column spacing:8
        IconButton onPressed:$locate tooltip:"Where am I" if:$hasGeo
          Icon my_location
        Text $"${lat}, ${lon}"
    Parameter Type Default Description
    supported output @name — true if the build has geolocation
    status output @name — idle / requesting / granted / denied / deniedForever / unavailable
    latitude output @name — Latitude, after a successful fix
    longitude output @name — Longitude
    request output @name — A ready “find my location” callback for a button
    onLocated callback (la, lo){…} — Called after a successful fix; the coordinates arrive in order (latitude, longitude) in the declared arguments under any names, asynchronously, and the template decides where to write them

    A typical pairing: onLocated writes into variables that the address of an HttpData reads, and the data is re-requested by itself.

    PermissionData

    One platform permission: whether it is granted and how to ask for it.

    Type: wrapper

    PermissionData "notifications" supported:@hasPerms status:@notif request:@ask
      ElevatedButton onPressed:$ask if:{hasPerms && notif != "granted"}
        Text "Allow notifications"
    Parameter Type Default Description
    (positional) string '' Permission name: notifications , location , camera , …
    supported output @name — true if the build can work with permissions
    status output @name — idle before the first check, then granted / denied / deniedForever / restricted / unavailable
    request output @name — A ready “ask for the permission” callback

    Clipboard

    Copying that announces itself: it puts text on the clipboard and shows a short notification. Not a button but a wrapper: what to press is up to the markup; the element gives a ready copy callback.

    Type: wrapper

    @code:"A1B2"
    Clipboard text:{"https://example.com/?ref=" + code} message:"Link copied" icon:"check" copy:@copy
      TextButton onPressed:$copy
        Text "Copy link"
    Parameter Type Default Description
    text string '' What to copy. Read at the moment of the press : a link from data that arrived after the button is copied fresh
    message string '' What to say after copying. Without it, copies silently
    icon string '' The notification icon (a ligature, as for Icon )
    iconFont string — The icon font, if not the standard set
    duration num 2 How many seconds to keep the notification
    copy output @name — A ready callback for onPressed: / onTap:

    Empty text is neither copied nor announced: an empty clipboard is an erased clipboard, and “Copied” about nothing is not true.

    AppUpdate

    Which content version is running now and what can be done to run a newer one. There is no built-in dialog: the update notice is part of the app's design, in its own words.

    Type: data (one child or slots)

    AppUpdate revision:@rev installedAt:@at state:@st pending:@waiting apply:@apply
      Column spacing:8
        Text $"Version ${rev ?? "-"}"
        Text {at == null ? "" : formatDate(at, "d MMMM HH:mm")}
        FilledButton onPressed:$apply if:$waiting
          Text "Update now"
        Text "A new version from the store is required" if:{st == "needsAppUpdate"}
    Parameter Type Default Description
    revision output @name — Number of the running publication — what a person recognises. Null if the build runs what it shipped with
    revisionId output @name — An opaque identifier of the same publication — for support
    installedAt output @name — When the running publication arrived
    pending output @name — Whether there is a downloaded but not yet applied publication
    pendingRevision output @name — Its number
    pendingRevisionId output @name — Its identifier
    state output @name — Result of the last check: upToDate , installed , refused , unavailable , stillRunning , needsAppUpdate
    checkedAt output @name — When the last check happened
    apply output @name — The “apply the pending one” callback. Null while there is nothing to wait for — a button on it is disabled without a condition
    check output @name — The “check now” callback

    needsAppUpdate deserves a separate screen: the server has a publication that this build cannot draw, and nothing more will arrive until a new version is released in the store.

    A build without over-the-air updates (including a run in the editor) leaves the outputs empty, and the children are drawn as usual.

    InView

    Publishes whether the child is on screen and what share of it is visible. Almost all scroll effects are built from this: a block appearing, a counter that starts when shown, highlighting a section in the navigation.

    Type: wrapper

    InView visible:@shown once:true
      AnimatedOpacity opacity:{shown ? 1 : 0} duration:600
        Text "I appear on scroll"
    Parameter Type Default Description
    visible output @name — true as soon as enough of the child is on screen (see threshold )
    amount output @name — The visible share of the child, 0..1
    once bool false Latch on the first showing and never go back to false — the appearance plays once
    threshold double 0.01 What share of the child must be visible for visible to become true . A child taller than the window counts as seen once it fills the screen. Does not affect amount

    Visibility is measured relative to the nearest scrollable, and without one relative to the window: on a short page with no scrolling the block counts as visible, and the appearance plays.

    InView amount:@part
      Opacity opacity:$part
        Container height:300
          #decoration color:0xFF4F46E5

    ScrollData

    Publishes how far the nearest scrollable is scrolled. A reading progress bar and parallax are built on this.

    Type: wrapper

    ScrollData progress:@p
      Container height:3
        #decoration color:0xFF4F46E5
        FractionallySizedBox widthFactor:$p alignment:centerLeft
          ColoredBox color:0xFFE11D48
    Parameter Type Default Description
    progress output @name — Scroll share 0..1. Stays 0 when there is nothing to scroll
    offset output @name — Scroll position in pixels

    Differences between the app and the site

    • GeoData on the site publishes supported:false and status:"unavailable" ; request is empty, and a button on it does nothing. Hide it by supported .
    • PermissionData and AppUpdate are not supported on the site: building the site issues an unsupported widget warning, only the child is drawn, the outputs are empty.
    • Clipboard works: the callback writes the text to the browser's clipboard and shows a notification at the bottom of the page.
    • InView and ScrollData work in the browser: in the page's HTML the outputs are still empty, and a script sets the values after loading and on scrolling. InView honours threshold and once the same way as the app.

    See also

    • HttpData — data from an address built from the coordinates
    • Video — another generator with callbacks in variables
    • State — State , Storage