Skip to content

Commit dac4071

Browse files
committed
add TextEditingController option
1 parent f1703c5 commit dac4071

5 files changed

Lines changed: 13 additions & 4 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ dependencies:
7171
flutter_localizations:
7272
sdk: flutter
7373
provider: ^3.0.0+1
74-
flutter_xmllayout_helpers: ^0.0.8
74+
flutter_xmllayout_helpers: ^0.0.9
7575
```
7676
4. Apply one of the following steps:
7777
* Clear all `main.dart` content then use `fxml_app` snippet to create the app.

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.28",
6+
"version": "0.0.30",
77
"icon": "images/logo.png",
88
"repository": {
99
"type": "github",

src/models/config.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,9 @@ export interface Config {
4444
* `{ "DropdownButton": ["items", "children"] }`
4545
*/
4646
arrayProperties?: { [name: string]: string[] };
47+
48+
/**
49+
* `["items"]`
50+
*/
51+
controlsWithTextEditingControllers?: string[];
4752
}

src/property-handlers/form-control.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ export class FormControlHandler extends CustomPropertyHandler {
3636
// });
3737

3838
let addLocalVar = true;
39-
40-
if (['TextField', 'TextFormField'].filter(a => a === targetWidget.type).length === 1) {
39+
const controlsWithTextEditingControllers = ['TextField', 'TextFormField', 'CupertinoTextField', ...(this.propertyResolver.getConfig().controlsWithTextEditingControllers || [])];
40+
if (controlsWithTextEditingControllers.filter(a => a === targetWidget.type).length === 1) {
4141
addLocalVar = false;
4242
const controllerName = element.attributes['controller'] ? element.attributes['controller'].split(' ')[1] : '';
4343
const privateControllerName = `ctrl._attachController(ctrl.${formGroupName}, ${name}, ${controllerName || '() => TextEditingController()'})`;

src/resolvers/property-resolver.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,4 +218,8 @@ export class PropertyResolver {
218218

219219
return unnamed[widgetType];
220220
}
221+
222+
getConfig(): Config {
223+
return this.config;
224+
}
221225
}

0 commit comments

Comments
 (0)