Last active
June 18, 2018 08:10
-
-
Save rahichesoft/afc9e3308a73d8fda713560c82e2d352 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
void main() => runApp(MyApp()); | |
class MyApp extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return new MaterialApp( | |
debugShowCheckedModeBanner: false, | |
theme: ThemeData( | |
primarySwatch: Colors.green, | |
), | |
home: new page(), | |
); | |
} | |
} | |
class page extends StatefulWidget { | |
@override | |
_pageState createState() => new _pageState(); | |
} | |
class _pageState extends State<page> { | |
@override | |
Widget build(BuildContext context) { | |
var d=5; | |
var textEditingControllers = <TextEditingController>[]; | |
var textFields = <TextField>[]; | |
var list = new List<int>.generate(d, (i) =>i + 1 ); | |
list.forEach((i) { | |
var textEditingController = new TextEditingController(text: "test $i"); | |
textEditingControllers.add(textEditingController); | |
return textFields.add(new TextField(controller: textEditingController)); | |
}); | |
return new Scaffold( | |
appBar: new AppBar(), | |
body: new Column( | |
children: textFields), | |
floatingActionButton: new FloatingActionButton( | |
onPressed: (){ | |
textEditingControllers[1].clear(); | |
} , | |
), | |
); | |
} | |
} | |
createTexttextfields (int d){ | |
var textEditingControllers = <TextEditingController>[]; | |
var textFields = <TextField>[]; | |
var list = new List<int>.generate(d, (i) =>i + 1 ); | |
print(list); | |
list.forEach((i) { | |
var textEditingController = new TextEditingController(text: "test $i"); | |
textEditingControllers.add(textEditingController); | |
return textFields.add(new TextField(controller: textEditingController)); | |
}); | |
return textFields; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment