Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

360
Vistas
¿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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda