Skip to main content
Stac uses the same idea as Flutter’s Navigator: you push new screens, pop back, or replace the current one. The difference is you can drive it from JSON (e.g. from your backend) or from Dart, and the next screen can be a Stac screen, a Flutter route, or a screen loaded from inline JSON, an asset, or the network.

Where you can go

When you’re pushing a new screen, you pick one way to say where to go:
DestinationGood forIn DartIn JSON
Stac screenScreens from your /stac folder or Stac CloudpushStac('screen_name')routeName + push-style
Flutter routeYour app’s own named routes (e.g. settings)pushFlutter('/path')routeName + pushNamed etc.
Inline JSONScreen defined right in the actionpushJson({ ... })widgetJson
AssetBundled or offline JSON screenspushAsset('assets/screen.json')assetPath
NetworkScreen fetched from an APIpushNetwork(StacNetworkRequest(...))request
Going back is simpler: use pop or popAll with navigationStyle (and optionally result when popping).

Using StacNavigator in Dart

In Dart, StacNavigator gives you clear, type-safe helpers so you don’t hand-build action objects yourself. Going back: StacNavigator.pop({ result }) pops the current route (and can pass result to the previous one). StacNavigator.popAll() pops back to the root. Stac screens: pushStac(routeName), pushReplacementStac(routeName), pushAndRemoveAllStac(routeName). Optional arguments on push, optional result on replacement. Flutter routes: Same pattern with pushFlutter, pushReplacementFlutter, pushAndRemoveAllFlutter—use your app’s route names. Inline JSON, assets, network: pushJson, pushAsset, pushNetwork (and their pushReplacement* and pushAndRemoveAll* variants) do what the names say. Handy when the screen comes from a blob of JSON, a local file, or an API call.
StyleWhat it does
pushNew screen on top of the stack
popDismiss current screen (optional result)
pushReplacementSwap current screen for a new one
pushAndRemoveAllNew screen and clear the stack (e.g. new root)
popAllPop back to the root
pushNamed / pushReplacementNamed / pushNamedAndRemoveAllSame as above but for Flutter named routes

Examples

Each example shows the Dart form (e.g. on a button’s onPressed) and the equivalent JSON you’d use in a Stac action.

Pop and popAll

// Pop current route
onPressed: StacNavigator.pop()

// Pop with a result for the previous screen
onPressed: StacNavigator.pop(result: {'saved': true})

// Pop back to root
onPressed: StacNavigator.popAll()

Push a Stac screen

StacNavigator.pushStac('detail_screen', arguments: {'id': '123'})

Push a Flutter named route

StacNavigator.pushFlutter('/settings', arguments: {'tab': 'profile'})

Push a screen from inline JSON

StacNavigator.pushJson({
  "type": "scaffold",
  "appBar": { "type": "appBar", "title": { "type": "text", "data": "Detail" } },
  "body": { "type": "text", "data": "Hello" }
})

Push a screen from an asset

StacNavigator.pushAsset('assets/screens/detail.json')

Push a screen from the network

StacNavigator.pushNetwork(
  StacNetworkRequest(url: 'https://api.example.com/screen', method: Method.get),
)

Replace and clear stack

// Replace current screen with a Stac screen (e.g. after login)
StacNavigator.pushReplacementStac('home_screen', result: {'loggedIn': true})

// New root: push and remove everything below
StacNavigator.pushAndRemoveAllStac('home_screen')
For full property details, see the Navigate Action reference.