Skip to content

Commit 4111a08

Browse files
committed
fix attachController
1 parent 1df89d0 commit 4111a08

5 files changed

Lines changed: 5 additions & 5 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"displayName": "XML Layout for Flutter",
44
"description": "XML Layout for Flutter. Brings Angular's style to Flutter!",
55
"publisher": "WaseemDev",
6-
"version": "0.0.19",
6+
"version": "0.0.21",
77
"icon": "images/logo.png",
88
"repository": {
99
"type": "github",

src/generators/class-generator.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ export class ClassCodeGenerator {
138138
formCode = `
139139
Map<String, dynamic> _attachedControllers = Map();
140140
141-
dynamic _attachController(String controlName, controllerBuilder) {
141+
dynamic _attachController(FormGroup formGroup, String controlName, controllerBuilder) {
142142
if (_attachedControllers.containsKey(controlName)) {
143143
final controller = _attachedControllers[controlName];
144144
return controller;

src/property-handlers/form-control.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export class FormControlHandler extends CustomPropertyHandler {
4040
if (['TextField', 'TextFormField'].filter(a => a === targetWidget.type).length === 1) {
4141
addLocalVar = false;
4242
const controllerName = element.attributes['controller'] ? element.attributes['controller'].split(' ')[1] : '';
43-
const privateControllerName = `ctrl._attachController(${name}, ${controllerName || '() => TextEditingController()'})`;
43+
const privateControllerName = `ctrl._attachController(ctrl.${formGroupName}, ${name}, ${controllerName || '() => TextEditingController()'})`;
4444

4545
if (!controllerName) {
4646
// only add controller if there is no one present

src/property-handlers/form.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ suite("Forms", function () {
9696
return SizedBox(
9797
width: 80,
9898
child: TextField(
99-
controller: ctrl._attachController('quantity', () => TextEditingController()),
99+
controller: ctrl._attachController(ctrl.formGroup, 'quantity', () => TextEditingController()),
100100
),
101101
);
102102
},

src/property-handlers/if-element.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ Container(
389389
stream: ctrl.formGroup.get('test').valueStream,
390390
builder: (BuildContext context, ctrlFormGroupGetTestValueStreamSnapshot) {
391391
return TextField(
392-
controller: ctrl._attachController('test', () => TextEditingController()),
392+
controller: ctrl._attachController(ctrl.formGroup, 'test', () => TextEditingController()),
393393
);
394394
},
395395
)

0 commit comments

Comments
 (0)