me gustaria que puedan ayudarme con este problema que tengo al usar una columna con su ultimo elemento abajo con expanded. bueno les comparto mi codigo:
Este esel build que aqui pienso que no es el problema que pero lo comparto por si acaso.
Widget build(BuildContext context) {
blocGeneral = Provider.of(context);
return Scaffold(
appBar: AppBar(
title: Text("AYUDA"),
centerTitle: true,
actions: <Widget>[
IconButton(icon: Icon(Icons.call) , onPressed: () { }),
],
),
body: Stack(
children: <Widget>[
_fondo(),
_demasElementos(context)
],
),
);
}
en este pedazo de codigo es donde estoy utilizando mi columna:
Widget _demasElementos(BuildContext contexto){
return Column(
children: <Widget>[
SizedBox( height: 10.0, ),
_contactaMe(contexto),
SizedBox( height: 10.0, ),
_textField(contexto),
SizedBox( height: 20.0 ),
_preguntasLabel(contexto),
SizedBox( height: 20.0 ),
Expanded(child: _listaDePreguntasFrecuentes(contexto)),
],
);
}
y aqui esta mi ultimo elemento de la columna.
Widget _listaDePreguntasFrecuentes(BuildContext contexto){
final tamanoPhone = MediaQuery.of(contexto).size;
return FutureBuilder(
future: getQuestions(contexto),
builder: (BuildContext contexto , AsyncSnapshot<List<Pregunta>> asyncSnapshot){
if (!asyncSnapshot.hasData) {
return Center(
child: Text("Solicitando datos...")
);
}
List<Pregunta> listaPreguntas = asyncSnapshot.data;
return ListView.builder(
itemCount: asyncSnapshot.data.length ,
itemBuilder: ( BuildContext contexto, int indice ) {
return Card(
color: Colors.brown,
elevation: 10.0,
child: ListTile(
title: Text(
listaPreguntas[indice].question,
style: TextStyle( color: Colors.white ),
),
),
);
},
);
}
);
}
y con todo este codigo de arriba me funciona bien el problema es cuando presiono el TextField
para escribir y cuando se abre el teclado me sale el error de desbordado.
abajo pongo la imagen.
LO QUE INTENTE: lo primero que hice fue cambiar mi columna por un ListView con sus childrens pero me da el siguiente error y en la pantalla al final no me muestra nada mas que el fondo y el appBar.
flutter: Another exception was thrown: 'package:flutter/src/widgets/sliver.dart': Failed
assertion: line 1312 pos 14: '_childElements.containsKey(index)': is not true.
flutter: Another exception was thrown: NoSuchMethodError: The getter
'scrollOffsetCorrection' was called on null.
flutter: Another exception was thrown: NoSuchMethodError: The method 'debugAssertIsValid'
was called on null.
flutter: Another exception was thrown: NoSuchMethodError: The getter 'visible' was called on null.
Muchas gracias amigos , espero me puedan ayudar gracias. si hay algo mas que deba incluir en la pregunta con mucho gusto.
EDITADO: AQUI ESTAN LOS DEMAS WIDGETS:
Widget _contactaMe(BuildContext contexto){
ContactProvider proveedorContacto = new ContactProvider();
final tamanoPhone = MediaQuery.of(contexto).size;
String mensajeMostrar = "";
return FutureBuilder(
future: proveedorContacto.obTainContacts(),
builder: (BuildContext contexto , AsyncSnapshot
asyncSnapshot){
Contacto contactoRecibido = asyncSnapshot.data;
if(asyncSnapshot.hasData){
if(!contactoRecibido.status){
mensajeMostrar = contactoRecibido.email;
}else {
mensajeMostrar = "Contactanos a traves
de ${contactoRecibido.email} o usando el formulario de consultas :";
}
return Container(
child: Text(mensajeMostrar, style:
TextStyle( fontSize: tamanoPhone.width * 0.04 , color: Colors.white,
),
textAlign: TextAlign.center,),
padding: EdgeInsets.symmetric(horizontal:
20.0 ),
);
} else {
return Container(
child: Center(
child: CircularProgressIndicator(
valueColor: new
AlwaysStoppedAnimation<Color>(Colors.brown),
),
),
);
}
},
);
}
EL TEXFIELD:
Widget _textField(BuildContext contexto){
final tamanoPhone = MediaQuery.of(contexto).size;
return Container(
height: tamanoPhone.height * 0.30,
padding: EdgeInsets.symmetric( horizontal: 20.0 ),
width: double.infinity,
// color: Colors.red,
child: Stack(
children: <Widget>[
_elTextFieldEnSi(contexto),
_elBotonEnSi(contexto),
],
),
);
}
Y ESTE ES PREGUNTAS LABEL:
Widget _preguntasLabel(BuildContext contexto){
final tamanoPhone = MediaQuery.of(contexto).size;
return Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.all( Radius.circular(10.0) ),
color: Color.fromRGBO(0, 0, 0, 0.5)
),
padding: EdgeInsets.all(10.0),
child: Text("PREGUNTAS Y RESPUESTAS FRECUENTES", style:
TextStyle( fontSize: tamanoPhone.width * 0.04 , color:
Colors.white, )),
);
}
MODIFICADO AQUI ANADO EL TEXTFIELDEN SI Y EL BOTON EN SI.
EN TEXTFIELD EN SI:
Widget _elTextFieldEnSi(BuildContext contexto){
return TextField(
style: TextStyle( color: Colors.white ),
maxLines: 10,
onChanged: (value){
this.blocGeneral.addDataToStreamMensaje(value);
},
decoration: InputDecoration(
filled: true,
fillColor: Color.fromRGBO(3, 3, 3, 0.5),
border: new OutlineInputBorder(
borderRadius: const BorderRadius.all(
const Radius.circular(20.0),
),
),
enabledBorder: const OutlineInputBorder(
borderSide: const BorderSide(color:
Colors.white, width: 0.5),
),
hintText: "Escriba su mensaje...",
hintStyle: TextStyle( color: Colors.white )
),
);
}
EL BOTON EN SI:
Widget _elBotonEnSi(BuildContext contexto){
return StreamBuilder<String>(
stream: this.blocGeneral.mensajeStream,
builder: (context, snapshot) {
return Align(
alignment: Alignment.bottomCenter,
child: MaterialButton(
elevation: 10.0,
minWidth: 200.0,
height: 50.0,
onPressed: () {
String ultimoValor = snapshot.data;
if(ultimoValor.length == 0){
final snackBar = SnackBar(content:
Text("Porfavor ingresa un mensaje para"));
Scaffold.of(context).showSnackBar(snackBar);
}else {
//enviar el mensaje
}
},
color: Colors.brown,
child: Text("Enviar Mensaje", style:
TextStyle(color: Colors.white)),
),
);
}
);
}