Models#
flet_pkg.core.models
#
Data models for Dart API parsing and code generation planning.
This module defines two layers of models: - Dart API models (DartParam, DartMethod, etc.): Represent the parsed Dart source code. - Generation plan models (ParamPlan, MethodPlan, etc.): Represent the Python/Dart code to generate.
DartParam
dataclass
#
DartParam(name: str, dart_type: str = 'dynamic', required: bool = False, named: bool = False, default: str | None = None, docstring: str = '')
A parameter from a Dart method signature.
DartMethod
dataclass
#
DartMethod(name: str, return_type: str = 'void', params: list[DartParam] = list(), docstring: str = '', is_static: bool = False, is_getter: bool = False, is_setter: bool = False, is_async: bool = False)
A method from a Dart class.
DartEnum
dataclass
#
A Dart enum declaration.
values
class-attribute
instance-attribute
#
(value_name, docstring) pairs.
DartClass
dataclass
#
DartClass(name: str, methods: list[DartMethod] = list(), constructor_params: list[DartParam] = list(), docstring: str = '', parent_class: str = '', source_file: str = '')
A parsed Dart class with its methods, properties, and metadata.
constructor_params
class-attribute
instance-attribute
#
Constructor parameters (for widget classes in ui_control mode).
DartPackageAPI
dataclass
#
DartPackageAPI(classes: list[DartClass] = list(), enums: list[DartEnum] = list(), helper_classes: list[DartClass] = list(), typedefs: dict[str, str] = dict(), reexported_types: dict[str, str] = dict(), top_level_functions: list[DartMethod] = list(), component_classes: list[DartClass] = list())
Container for the entire parsed Dart package API.
reexported_types
class-attribute
instance-attribute
#
Mapping of type name → source package for re-exported public API types.
top_level_functions
class-attribute
instance-attribute
#
Top-level functions (not inside any class) from the Dart package.
component_classes
class-attribute
instance-attribute
#
Non-widget classes referenced as constructor param types by widgets.
ParamPlan
dataclass
#
ParamPlan(python_name: str, python_type: str = 'Any', dart_name: str = '', dart_type: str = 'dynamic', is_optional: bool = False, is_named: bool = False, default: str | None = None, docstring: str = '')
Plan for a single method parameter.
MethodPlan
dataclass
#
MethodPlan(python_name: str, dart_method_name: str = '', params: list[ParamPlan] = list(), return_type: str = 'None', docstring: str = '', is_async: bool = True, is_getter: bool = False, dart_original_name: str = '', dart_class_name: str = '')
Plan for generating a single Python async method.
PropertyPlan
dataclass
#
PropertyPlan(python_name: str, python_type: str = 'str', default_value: str = '""', docstring: str = '', dart_name: str = '', dart_pre_init_call: str = '', dart_getter: str = '')
Plan for a control property (dataclass field).
dart_name
class-attribute
instance-attribute
#
Original camelCase Dart parameter name.
Used by the Dart widget generator to emit correct constructor calls.
Falls back to python_name when empty.
dart_pre_init_call
class-attribute
instance-attribute
#
Optional Dart code template for pre-init setter call.
Use {var} placeholder for the variable name.
Example: "OneSignal.Debug.setLogLevel(OSLogLevel.values[{var}]);"
dart_getter
class-attribute
instance-attribute
#
Dart getter expression for UI controls.
Example: control.getAlignment("alignment").
Populated by the analyzer for ui_control extensions.
EventPlan
dataclass
#
EventPlan(python_attr_name: str, event_class_name: str, dart_event_name: str = '', fields: list[tuple[str, str]] = list(), dart_listener_method: str = '', dart_sdk_accessor: str = '')
Plan for an event handler attribute.
EnumPlan
dataclass
#
Plan for generating a Python Enum class.
values
class-attribute
instance-attribute
#
(PYTHON_NAME, "value", "docstring") triples.
SubModulePlan
dataclass
#
SubModulePlan(module_name: str, class_name: str, dart_prefix: str = '', methods: list[MethodPlan] = list(), docstring: str = '', dart_class_name: str = '', dart_sdk_accessor: str = '')
Plan for a sub-module file (e.g., user.py, notifications.py).
StubDataClass
dataclass
#
Stub for a re-exported data class from platform_interface.
fields
class-attribute
instance-attribute
#
(field_name, field_type) pairs.
SubControlPlan
dataclass
#
SubControlPlan(control_name: str, dart_class_name: str, properties: list[PropertyPlan] = list(), events: list[EventPlan] = list(), parent_property: str = '', is_list: bool = False, sub_controls: list[SubControlPlan] = list(), depth: int = 1)
Plan for a sub-control class (compound widget child).
control_name
instance-attribute
#
PascalCase name for the generated class (e.g. ActionPane).
dart_class_name
instance-attribute
#
Original Dart class name (e.g. ActionPane).
parent_property
class-attribute
instance-attribute
#
snake_case property name on the parent (e.g. start_action_pane).
is_list
class-attribute
instance-attribute
#
True when the parent references this as List<T>.
sub_controls
class-attribute
instance-attribute
#
Nested sub-controls (recursive, max depth 3).
depth
class-attribute
instance-attribute
#
Nesting depth (1 = direct child of main widget).
WidgetVariant
dataclass
#
SiblingWidgetPlan
dataclass
#
SiblingWidgetPlan(control_name: str, dart_class_name: str, properties: list[PropertyPlan] = list(), events: list[EventPlan] = list(), sub_controls: list[SubControlPlan] = list(), control_name_snake: str = '')
A sibling widget — a separate control in the same package.
Used when a Flutter package exposes multiple distinct widgets with low parameter overlap (e.g. CircularPercentIndicator vs LinearPercentIndicator).
GenerationPlan
dataclass
#
GenerationPlan(control_name: str, package_name: str, base_class: str = 'ft.Service', description: str = '', flutter_package: str = '', properties: list[PropertyPlan] = list(), main_methods: list[MethodPlan] = list(), events: list[EventPlan] = list(), sub_modules: list[SubModulePlan] = list(), enums: list[EnumPlan] = list(), stub_data_classes: list[StubDataClass] = list(), dart_import: str = '', dart_listeners: list[dict[str, str]] = list(), dart_main_class: str = '', control_name_snake: str = '', error_event_class: str = '', sub_controls: list[SubControlPlan] = list(), include_console: bool = True, widget_family_variants: list[WidgetVariant] = list(), widget_family_enum: EnumPlan | None = None, sibling_widgets: list[SiblingWidgetPlan] = list())
Complete plan for code generation. Fed to generators.
stub_data_classes
class-attribute
instance-attribute
#
Stub data classes for re-exported types from platform_interface.
error_event_class
class-attribute
instance-attribute
#
Name of the error event class (e.g. OSErrorEvent).
sub_controls
class-attribute
instance-attribute
#
Sub-control plans for compound widgets (e.g. ActionPane for Slidable).
include_console
class-attribute
instance-attribute
#
Whether to include the debug console module.
widget_family_variants
class-attribute
instance-attribute
#
Variants for widget family pattern (e.g. SpinKit → 30 variants).
widget_family_enum
class-attribute
instance-attribute
#
Enum plan for the widget family type selector.
sibling_widgets
class-attribute
instance-attribute
#
Sibling widget plans for multi-widget packages.