MCPcopy Index your code
hub / github.com/bernaferrari/FigmaToCode / flutterFrame

Function flutterFrame

packages/backend/src/flutter/flutterMain.ts:171–222  ·  view source on GitHub ↗
(
  node: SceneNode & BaseFrameMixin & MinimalBlendMixin,
)

Source from the content-addressed store, hash-verified

169};
170
171const flutterFrame = (
172 node: SceneNode & BaseFrameMixin & MinimalBlendMixin,
173): string => {
174 // Check if any direct children need absolute positioning
175 const hasAbsoluteChildren = node.children.some(
176 (child: any) => (child as any).layoutPositioning === "ABSOLUTE",
177 );
178
179 // Add warning if we need to use Stack due to absolute positioning
180 if (hasAbsoluteChildren && node.layoutMode !== "NONE") {
181 addWarning(
182 `Frame "${node.name}" has absolute positioned children. Using Stack instead of ${
183 node.layoutMode === "HORIZONTAL" ? "Row" : "Column"
184 }.`,
185 );
186 }
187
188 // Generate widget code for children
189 const children = flutterWidgetGenerator(node.children);
190
191 // Force Stack for any frame that has absolute positioned children
192 if (hasAbsoluteChildren) {
193 return flutterContainer(
194 node,
195 generateWidgetCode("Stack", {
196 children: children !== "" ? [children] : [],
197 }),
198 );
199 }
200
201 if (node.layoutMode !== "NONE") {
202 const rowColumnWrap = makeRowColumnWrap(node, children);
203 return flutterContainer(node, rowColumnWrap);
204 } else {
205 if (node.inferredAutoLayout) {
206 const rowColumnWrap = makeRowColumnWrap(node.inferredAutoLayout, children);
207 return flutterContainer(node, rowColumnWrap);
208 }
209
210 if (node.isAsset) {
211 return flutterContainer(node, generateWidgetCode("FlutterLogo", {}));
212 }
213
214 // Default to Stack for frames without any layout
215 return flutterContainer(
216 node,
217 generateWidgetCode("Stack", {
218 children: children !== "" ? [children] : [],
219 }),
220 );
221 }
222};
223
224const makeRowColumnWrap = (
225 autoLayout: InferredAutoLayoutResult,

Callers 1

flutterWidgetGeneratorFunction · 0.85

Calls 5

addWarningFunction · 0.90
generateWidgetCodeFunction · 0.90
flutterWidgetGeneratorFunction · 0.85
flutterContainerFunction · 0.70
makeRowColumnWrapFunction · 0.70

Tested by

no test coverage detected