Skip to content

Commit 4c256dd

Browse files
committed
fix docs & snippent
1 parent 070ab22 commit 4c256dd

3 files changed

Lines changed: 12 additions & 6 deletions

File tree

docs/parameters.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Parameters are used to pass data from one widget to another, and since you can't
2626

2727
And you can access it directly in the XML file:
2828
```XML
29-
<Text text="category.name" />
29+
<Text text="ctrl.category.name" />
3030
```
3131

3232
Or in the controller class **after** `didLoad()`, not in the constructor:
@@ -36,3 +36,9 @@ Or in the controller class **after** `didLoad()`, not in the constructor:
3636
print(category.name);
3737
}
3838
```
39+
40+
Then, from another widget, pass parameter's value as usual:
41+
```xml
42+
<MyWidget category="...value...">
43+
</MyWidget>
44+
```

src/generators/class-generator.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -235,20 +235,20 @@ class _${widgetName}State extends State<${widgetName}>${mixinsCode} {
235235
236236
@override
237237
void initState() {
238-
super.initState();${(stateVarsInit.length > 0 ? '\n' : '') + stateVarsInit.join(`\n `)}
238+
super.initState();${(stateVarsInit.length > 0 ? '\n ' : '') + stateVarsInit.join(`\n `)}
239239
}
240240
241241
@override
242242
void didChangeDependencies() {
243243
super.didChangeDependencies();${routeAware ? `\n _routeObserver = Provider.of<RouteObserver<Route>>(context)..subscribe(this, ModalRoute.of(context));` : ''
244-
}${rootWidget.providers.map(a => `${hasController ? `ctrl._${a.name} = `: ''}${a.name} = Provider.of<${a.type}>(context);`).join('\n ')
245-
}${hasController ? `ctrl._load(context);` : ''}
244+
}${(rootWidget.providers.length ? '\n ' : '') + rootWidget.providers.map(a => `${hasController ? `ctrl._${a.name} = `: ''}${a.name} = Provider.of<${a.type}>(context);`).join('\n ')
245+
}${hasController ? `\n ctrl._load(context);` : ''}
246246
}
247247
248248
@override
249249
void dispose() {${hasController ? `\nctrl.dispose();` : ''
250250
}${routeAware ? `\n _routeObserver.unsubscribe(this);` : ''
251-
}${controllers.filter(a => a.isPrivate).map(a => `${a.name}.dispose();`).join('\n ')}
251+
}${(controllers.length > 0 ? '\n ' : '') + controllers.filter(a => a.isPrivate).map(a => `${a.name}.dispose();`).join('\n ')}
252252
super.dispose();
253253
}
254254
${buildMethodContent}

src/property-handlers/child-builder.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { PropertyResolver } from "../resolvers/property-resolver";
66

77
export class ChildBuilderHandler extends CustomPropertyHandler {
88
priority = -100000; // lowest priority
9-
valueSnippet = 'item of ${0:items}';
9+
valueSnippet = '"item of ${0:items}"';
1010

1111
constructor(private readonly propertyResolver: PropertyResolver) {
1212
super();

0 commit comments

Comments
 (0)