PheasantTemplate class abstract

The base class for all Pheasant App Components

All Pheasant app components are derived from this base class, and are used to render pheasant code internally and return the desired html app component.

Every PheasantTemplate class instance has two main parts:

  1. The template field, which represents the pheasant template string that is to be rendered. The template variable is of type String and is automatically overrided for every instance of this class from the renderFunc function

  2. The render function, which returns the rendered html element to be injected into the DOM. The render function takes in one required parameter, the template, and one optional parameter, state. There is no base definition of this function, as the definition of the function is generated by the renderFunc function.

Any other variables or functions defined in the <script> part of the .phs file, is added as normal fields and methods repsectively to the class.

Here is an instance of this class definition:

class MyComponent extends PheasantTemplate {
  @override
  String? template = """
<div>
  <p>Hello World</p>
</div>
"""

  PheasantTemplate({super.template});

  @override
  Element render(String temp) {
    // Generated Code
    return element;
  }
}

This class is not intended for direct usage, but mainly for implementation

Implementers

Constructors

PheasantTemplate({required String? template})

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
template String?
The template variable, which forms the html text body to be rendered.
getter/setter pair

Methods

del() → void
Function used to declare the final state of a component. This function is called at the end of the component's life cycle, either when removed from the DOM or navigating to another page
fetchState() → dynamic
Fetches any parsed data from the previous component/page route as either a List or a Map.
freezeState([ElementState? state]) → void
Freeze the state of the component
init() → void
Function used to declare the initial state/case of a component.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
refresh() → void
Refresh the given page on the browser
reloadState([ElementState? state]) → void
Reloads the state of the component
render(String temp, [TemplateState? state]) Element
The render function.
toString() String
A string representation of this object.
inherited
unfreezeState([ElementState? state]) → void
Unfreeze the state of the component

Operators

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