Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

359
Views
¿Cómo proporciono un valor inicial a un campo de texto?

Me gustaría proporcionar un valor inicial a un campo de texto y volver a dibujarlo con un valor vacío para borrar el texto. ¿Cuál es el mejor enfoque para hacer eso con las API de Flutter?

over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

Puede usar un TextFormField en lugar de TextField y usar la propiedad initialValue . por ejemplo

 TextFormField(initialValue: "I am smart")
over 4 years ago · Santiago Trujillo Report

0

(De la lista de correo. No se me ocurrió esta respuesta).

 class _FooState extends State<Foo> { TextEditingController _controller; @override void initState() { super.initState(); _controller = new TextEditingController(text: 'Initial value'); } @override Widget build(BuildContext context) { return new Column( children: <Widget>[ new TextField( // The TextField is first built, the controller has some initial text, // which the TextField shows. As the user edits, the text property of // the controller is updated. controller: _controller, ), new RaisedButton( onPressed: () { // You can also use the controller to manipuate what is shown in the // text field. For example, the clear() method removes all the text // from the text field. _controller.clear(); }, child: new Text('CLEAR'), ), ], ); } }
over 4 years ago · Santiago Trujillo Report

0

No tiene que definir una variable separada en el alcance del widget, solo hágalo en línea:

 TextField( controller: TextEditingController()..text = 'Your initial value', onChanged: (text) => {}, )
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!