CodelesslyWidget class

Shows a published layout: the canvas for the space it's given (picked by the layout's breakpoints), sized by its scale mode, running (interactive), with a loading and an error state.

The Codelessly it uses is codelessly, else controller's, else a CodelesslyScope's above it, else Codelessly.instance.

CodelesslyWidget(
  codelessly: codelessly,
  layoutId: 'profile-card',
  data: {'user': {'name': 'Ada'}},   // ${data.user.name}
  params: {'userId': 'u_42'},        // ${route.userId}
  loadingBuilder: (context) => const CircularProgressIndicator(),
  errorBuilder: (context, error) => Text('$error'),
)

Without a layoutId it shows the project's entry screen (or initialScreen). Navigation actions push routes on the nearest Navigator; onNavigate handles them first. For a project that is the whole app, give MaterialApp.onGenerateRoute onGenerateRoute.

Navigation actions need a Navigator above it (a MaterialApp gives one); without one they do nothing.

Inheritance

Constructors

CodelesslyWidget({Key? key, String? layoutId, String? canvasId, String? initialScreen, CodelesslyWidgetController? controller, Codelessly? codelessly, Map<String, Object?> params = const {}, Map<String, Object?> data = const {}, CanvasSizing sizing = CanvasSizing.fill, WidgetBuilder? loadingBuilder, CodelesslyWidgetErrorBuilder? errorBuilder, CodelesslyWidgetLayoutBuilder? layoutBuilder, CodelesslyNavigationHandler? onNavigate, PaywallSession? paywall, String paywallAppVersion = '', void onActionError(Object error, StackTrace stack, String? action)?})
const

Properties

canvasId → String?
Shows this canvas of the layout whatever the width (no breakpoints).
final
codelessly → Codelessly?
The project. Null: controller's, else the CodelesslyScope's above, else Codelessly.instance.
final
controller → CodelesslyWidgetController?
Reads and changes the shown screen, and names the layout when layoutId is null.
final
data → Map<String, Object?>
Data over the Codelessly's (data.<key>). A screen variable named like a key starts at its value and follows it until the screen changes the variable itself. Rebuilding with other data updates the screen in place.
final
errorBuilder → CodelesslyWidgetErrorBuilder?
What shows when the layout fails to load (default: CodelesslyErrorScreen). The error is usually a PublishLoadException.
final
hashCode → int
The hash code for this object.
no setterinherited
initialScreen → String?
The screen to open when no layout is named: a location (guide/42, matched against the screens' paths), a canvas or layout id, or a screen name matched loosely (record-form opens "Record form"). Unknown screens open the entry screen.
final
key → Key?
Controls how one widget replaces another widget in the tree.
finalinherited
layoutBuilder → CodelesslyWidgetLayoutBuilder?
Wraps the loaded layout (a SafeArea, an overlay).
final
layoutId → String?
The layout to show: a layout id, a custom id, or the id of one of its canvases. Null: controller's, else initialScreen, else the project's entry screen.
final
loadingBuilder → WidgetBuilder?
What shows while the layout loads (default: CodelesslyLoadingScreen).
final
onActionError → void Function(Object error, StackTrace stack, String? action)?
Failed action chains stop and report here, so the host can show its designed toast or recovery UI. Propagated to routes and modals.
final
onNavigate → CodelesslyNavigationHandler?
Handles navigation actions first (an app routing screens itself).
final
params → Map<String, Object?>
Params the screen opens with: route.<name> in the layout, and the start value of its variables of the same name.
final
paywall → PaywallSession?
The route's session. Its owner disposes it; nested modal actions use the same session. Normal navigation does not implicitly open a paywall.
final
paywallAppVersion → String
Host app version passed to server placement resolution.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
sizing → CanvasSizing
How the canvas sizes itself in the space it's given.
final

Methods

createElement() → StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
inherited
createState() → State<CodelesslyWidget>
Creates the mutable state for this widget at a given location in the tree.
override
debugDescribeChildren() → List<DiagnosticsNode>
Returns a list of DiagnosticsNode objects describing this node's children.
inherited
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep.
inherited
toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) → String
A string representation of this object.
inherited
toStringDeep({String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) → String
Returns a string representation of this node and its descendants.
inherited
toStringShallow({String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String
Returns a one-line detailed description of the object.
inherited
toStringShort() → String
A short, textual description of this widget.
inherited

Operators

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

Static Methods

encodeRawLocation(String location) → String
location with what can't stand in a URL as is (spaces, non-ASCII characters, a % that starts no escape) percent-encoded, and its escapes (%20) and URL punctuation kept.
onGenerateInitialRoutes(Codelessly codelessly, {CodelesslyWidget? template}) → List<Route> Function(String location)
A navigator's onGenerateInitialRoutes for a link to location: the screens beneath it (CanvasLocation.beneath) and then its own, so a link opens a screen as navigating there would have (back lands on the screen beneath; a translucent one shows it behind).
onGenerateRoute(Codelessly codelessly, {CodelesslyWidget? template}) → RouteFactory
Routes for a Navigator or MaterialApp.onGenerateRoute: / opens the entry screen, any other name the screen it locates (initialScreen): a URL path, a canvas or layout id, or a screen name.
resolveScreen(PublishModel model, String? screen) → (String, Map<String, Object?>)?
The layout and params screen opens.
route<T>({required Codelessly codelessly, required String layoutId, Map<String, Object?> params = const {}, CodelesslyWidget? template, PaywallSession? paywall, String? name, RouteTransition? transition, RevealAnchor anchor = const RevealAnchor(), PageTransition pageTransition = PageTransition.platform, int? transitionMs, int? reverseTransitionMs}) → Route<T>
A route showing layout layoutId of codelessly, as navigation pushes them. template passes its builders and handler along. With transition it plays that custom transition (its reveals growing from anchor); else pageTransition over transitionMs (the platform's, none on the web).