Asm*_*oun 4 dart flutter flutter-layout
我有以下AlertDialog小部件,其行为如下:
\n
\n这是我的代码:
showDialog(\n context: context,\n builder: (context) {\n return StatefulBuilder(\n builder: (context, setState) {\n return AlertDialog(\n title: Text(\n "Information sur le client $code",\n ),\n content: Container(\n height: mobileHeight * 0.75,\n width: mobileWidth * 0.9,\n child: Column(\n mainAxisAlignment: MainAxisAlignment.spaceBetween,\n children: <Widget>[\n Row(\n mainAxisAlignment: MainAxisAlignment.start,\n children: [\n Container(\n child: IconButton(\n icon: Icon(\n Icons.edit,\n color: Colors.blue,\n size: mobileWidth * 0.05,\n ),\n onPressed: () {\n setState(() => modifyNom = !modifyNom);\n _textNameController.text = snapshot.data.nom;\n },\n ),\n ),\n modifyNom\n ? Flexible(\n child: TextField(\n textAlign: TextAlign.center,\n style: TextStyle(\n fontSize: mobileWidth * 0.05,\n ),\n controller: _textNameController,\n decoration: InputDecoration(),\n ),\n )\n : Flexible(\n child: Text(\n \'${snapshot.data.nom}\',\n style: TextStyle(\n fontSize: mobileWidth * 0.05,\n ),\n ),\n ),\n ],\n ),\n Row(\n children: [\n Container(\n child: IconButton(\n onPressed: () {\n setState(() => modifyContact = !modifyContact);\n _textContactController.text = snapshot.data.contact;\n },\n ),\n ),\n Text(\n \'Contact : \',\n ),\n modifyContact\n ? Flexible(\n child: TextField(\n textAlign: TextAlign.center,\n controller: _textContactController,\n decoration: InputDecoration(),\n ),\n )\n : Flexible(\n child: Text(\n \'${snapshot.data.contact}\',\n ),\n ),\n ],\n ),\n ],\n ),\n ),\n actions: [\n FlatButton(\n child: Text("Annuler"),\n onPressed: () {\n Navigator.of(context).pop(); // dismiss dialog\n },\n ),\n ],\n );\n },\n );\nRun Code Online (Sandbox Code Playgroud)\n问题是当我编辑TextField并显示键盘时我收到此错误:
\xe2\x95\x90\xe2\x95\x90\xe2\x95\xa1 EXCEPTION CAUGHT BY RENDERING LIBRARY \xe2\x95\x9e\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\nThe following assertion was thrown during layout:\nA RenderFlex overflowed by 211 pixels on the bottom.\n\nThe relevant error-causing widget was:\n Column file:///C:/Users/asmou/AndroidStudioProjects/flutter_app/lib/Alerts/showAlertInfo.dart:49:28\n\nThe overflowing RenderFlex has an orientation of Axis.vertical.\nThe edge of the RenderFlex that is overflowing has been marked in the rendering with a yellow and\nblack striped pattern. This is usually caused by the contents being too big for the RenderFlex.\nConsider applying a flex factor (e.g. using an Expanded widget) to force the children of the\nRenderFlex to fit within the available space instead of being sized to their natural size.\nThis is considered an error condition because it indicates that there is content that cannot be\nseen. If the content is legitimately bigger than the available space, consider clipping it with a\nClipRect widget before putting it in the flex, or using a scrollable container rather than a Flex,\nlike a ListView.\nThe specific RenderFlex in question is: RenderFlex#a3d43 OVERFLOWING:\n needs compositing\n creator: Column \xe2\x86\x90 FutureBuilder<Client> \xe2\x86\x90 ConstrainedBox \xe2\x86\x90 Container \xe2\x86\x90 DefaultTextStyle \xe2\x86\x90 Padding \xe2\x86\x90\n Flexible \xe2\x86\x90 Column \xe2\x86\x90 IntrinsicWidth \xe2\x86\x90 DefaultTextStyle \xe2\x86\x90 AnimatedDefaultTextStyle \xe2\x86\x90\n _InkFeatures-[GlobalKey#50b4d ink renderer] \xe2\x86\x90 \xe2\x8b\xaf\n parentData: <none> (can use size)\n constraints: BoxConstraints(w=283.4, h=173.1)\n size: Size(283.4, 173.1)\n direction: vertical\n mainAxisAlignment: spaceBetween\n mainAxisSize: max\n crossAxisAlignment: center\n verticalDirection: down\n\xe2\x97\xa2\xe2\x97\xa4\xe2\x97\xa2\xe2\x97\xa4\xe2\x97\xa2\xe2\x97\xa4\xe2\x97\xa2\xe2\x97\xa4\xe2\x97\xa2\xe2\x97\xa4\xe2\x97\xa2\xe2\x97\xa4\xe2\x97\xa2\xe2\x97\xa4\xe2\x97\xa2\xe2\x97\xa4\xe2\x97\xa2\xe2\x97\xa4\xe2\x97\xa2\xe2\x97\xa4\xe2\x97\xa2\xe2\x97\xa4\xe2\x97\xa2\xe2\x97\xa4\xe2\x97\xa2\xe2\x97\xa4\xe2\x97\xa2\xe2\x97\xa4\xe2\x97\xa2\xe2\x97\xa4\xe2\x97\xa2\xe2\x97\xa4\xe2\x97\xa2\xe2\x97\xa4\xe2\x97\xa2\xe2\x97\xa4\xe2\x97\xa2\xe2\x97\xa4\xe2\x97\xa2\xe2\x97\xa4\xe2\x97\xa2\xe2\x97\xa4\xe2\x97\xa2\xe2\x97\xa4\xe2\x97\xa2\xe2\x97\xa4\xe2\x97\xa2\xe2\x97\xa4\xe2\x97\xa2\xe2\x97\xa4\xe2\x97\xa2\xe2\x97\xa4\xe2\x97\xa2\xe2\x97\xa4\xe2\x97\xa2\xe2\x97\xa4\xe2\x97\xa2\xe2\x97\xa4\xe2\x97\xa2\xe2\x97\xa4\xe2\x97\xa2\xe2\x97\xa4\xe2\x97\xa2\xe2\x97\xa4\xe2\x97\xa2\xe2\x97\xa4\xe2\x97\xa2\xe2\x97\xa4\xe2\x97\xa2\xe2\x97\xa4\xe2\x97\xa2\xe2\x97\xa4\xe2\x97\xa2\xe2\x97\xa4\xe2\x97\xa2\xe2\x97\xa4\xe2\x97\xa2\xe2\x97\xa4\xe2\x97\xa2\xe2\x97\xa4\xe2\x97\xa2\xe2\x97\xa4\xe2\x97\xa2\xe2\x97\xa4\xe2\x97\xa2\xe2\x97\xa4\xe2\x97\xa2\xe2\x97\xa4\xe2\x97\xa2\xe2\x97\xa4\xe2\x97\xa2\xe2\x97\xa4\xe2\x97\xa2\xe2\x97\xa4\xe2\x97\xa2\xe2\x97\xa4\xe2\x97\xa2\xe2\x97\xa4\xe2\x97\xa2\xe2\x97\xa4\nRun Code Online (Sandbox Code Playgroud)\n
使用 ListView 或 SingleChildScrollView 包装容器小部件。
showDialog(
context: context,
builder: (context) {
return StatefulBuilder(
builder: (context, setState) {
return AlertDialog(
title: Text(
"Information sur le client $code",
),
content: SingleChildScrollView(
child: Container(
height: mobileHeight * 0.75,
width: mobileWidth * 0.9,
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Container(
child: IconButton(
icon: Icon(
Icons.edit,
color: Colors.blue,
size: mobileWidth * 0.05,
),
onPressed: () {
setState(() => modifyNom = !modifyNom);
_textNameController.text = snapshot.data.nom;
},
),
),
modifyNom
? Flexible(
child: TextField(
textAlign: TextAlign.center,
style: TextStyle(
fontSize: mobileWidth * 0.05,
),
controller: _textNameController,
decoration: InputDecoration(),
),
)
: Flexible(
child: Text(
'${snapshot.data.nom}',
style: TextStyle(
fontSize: mobileWidth * 0.05,
),
),
),
],
),
Row(
children: [
Container(
child: IconButton(
onPressed: () {
setState(() => modifyContact = !modifyContact);
_textContactController.text = snapshot.data.contact;
},
),
),
Text(
'Contact : ',
),
modifyContact
? Flexible(
child: TextField(
textAlign: TextAlign.center,
controller: _textContactController,
decoration: InputDecoration(),
),
)
: Flexible(
child: Text(
'${snapshot.data.contact}',
),
),
],
),
],
),
),
),
actions: [
FlatButton(
child: Text("Annuler"),
onPressed: () {
Navigator.of(context).pop(); // dismiss dialog
},
),
],
);
},
);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3703 次 |
| 最近记录: |