#flutter #dart #flutter-renderflex-error
Вопрос:
Я пытался исправить ошибку, но я не смог, как новичок, развеяться. Он продолжал исправлять ошибку. Я попытался исправить это, используя некоторые ответы на переполнение стека, но не смог.
Это и есть код
@override
Widget build(BuildContext context) {
return Scaffold(backgroundColor: Color(0xfff1f3f6),
body: Stack(children: [ Column(children: [
Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [
Container(height: 150, width: MediaQuery.of(context).size.width*0.6, decoration: BoxDecoration(borderRadius: BorderRadius.only(bottomRight: Radius.circular(60)), color: Colors.white),
child: Center(child: Row(mainAxisAlignment: MainAxisAlignment.center, children: [
Container(width: 50, height: 50, decoration: BoxDecoration(shape: BoxShape.circle, color: Color(0xfff1f3f6), image: DecorationImage(image: AssetImage('asset/images/avatar4.png'), fit: BoxFit.contain))),
SizedBox(width: 10,),
Column(mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.start, children: [
Text("Carol Johnson", style: TextStyle(fontSize: 19, fontWeight: FontWeight.w700),),
Text("Seattle Washington", style: TextStyle(fontSize: 13, fontWeight: FontWeight.w400, color: Colors.grey
),)
],
)
],
),
),
)
],
),
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.center, children: [
navigatorTitle("Home", true),
navigatorTitle("Profile", false),
navigatorTitle("Accounts", false),
navigatorTitle("Transactions", false),
navigatorTitle("Stats", false),
navigatorTitle("Settings", false),
navigatorTitle("Help", false),
],
),
),
Container(
padding: EdgeInsets.all(20), child: Row(children: [Icon(Icons.power_settings_new, size: 30,),
Text("Logout", style: TextStyle(fontSize: 20, fontWeight: FontWeight.w700),)],),),
Container(alignment: Alignment.bottomLeft, padding: EdgeInsets.all(20), child: Text("Ver 2.0.1",style: TextStyle(color: Colors.grey),),)],),
AnimatedPositioned(
duration: Duration(milliseconds: 200),
left: (sideBarActive) ? MediaQuery.of(context).size.width*0.6 : 0,
top: (sideBarActive)? MediaQuery.of(context).size.height*0.2 : 0,
child: RotationTransition(
turns: (sideBarActive) ? Tween(begin: -0.05, end: 0.0).animate(_rotationController) : Tween(begin: 0.0, end: -0.05).animate(_rotationController),
child: AnimatedContainer(
duration: Duration(milliseconds: 200),
height: (sideBarActive) ? MediaQuery.of(context).size.height*0.7 : MediaQuery.of(context).size.height,
width: (sideBarActive) ? MediaQuery.of(context).size.width*0.8 : MediaQuery.of(context).size.width,
decoration: BoxDecoration(borderRadius: BorderRadius.all(Radius.circular(40)), color: Colors.white),
child: ClipRRect(borderRadius: BorderRadius.all(Radius.circular(40)), child: HomePage(),),),),),
Positioned(right: 0, top: 20, child: (sideBarActive) ? IconButton(padding: EdgeInsets.all(30), onPressed: closeSideBar,
icon: Icon(Icons.close, color: Colors.black, size: 30,),): InkWell(onTap: openSideBar,
child: Container(margin: EdgeInsets.all(17), height: 30, width: 30, decoration: BoxDecoration(image: DecorationImage(image: AssetImage('asset/images/menu.png'))),),
),
)
],
),
);
}
Row navigatorTitle(String name, bool isSelected)
{
return Row(
children: [(isSelected) ? Container(width: 5, height: 60, color: Color(0xffffac30),):
Container(width: 5, height: 60,),
SizedBox(width: 10,height: 60,),
Text(name, style: TextStyle(fontSize: 16, fontWeight: (isSelected) ? FontWeight.w700: FontWeight.w400),)],);
}
void closeSideBar()
{
sideBarActive = false;
setState(() {
});
}
void openSideBar()
{
sideBarActive = true;
setState(() {
});
}
Это ошибка, которую я получаю
======== Exception caught by rendering library =====================================================
The following assertion was thrown during layout:
A RenderFlex overflowed by 5.0 pixels on the right.
The relevant error-causing widget was:
Row file:///Users/wikiwoo/AndroidStudioProjects/etransfa/lib/christdoes/view/home_with_sidebar.dart:44:42
The overflowing RenderFlex has an orientation of Axis.horizontal.
The edge of the RenderFlex that is overflowing has been marked in the rendering with a yellow and black striped pattern. This is usually caused by the contents being too big for the RenderFlex.
Consider applying a flex factor (e.g. using an Expanded widget) to force the children of the RenderFlex to fit within the available space instead of being sized to their natural size.
This is considered an error condition because it indicates that there is content that cannot be seen. If the content is legitimately bigger than the available space, consider clipping it with a ClipRect widget before putting it in the flex, or using a scrollable container rather than a Flex, like a ListView.
The specific RenderFlex in question is: RenderFlex#3d9c3 relayoutBoundary=up1 OVERFLOWING
... parentData: offset=Offset(0.0, 0.0) (can use size)
... constraints: BoxConstraints(0.0<=w<=192.0, 0.0<=h<=150.0)
... size: Size(192.0, 150.0)
... direction: horizontal
... mainAxisAlignment: center
... mainAxisSize: max
... crossAxisAlignment: center
... textDirection: ltr
... verticalDirection: down
◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤
====================================================================================================
======== Exception caught by rendering library =====================================================
A RenderFlex overflowed by 129 pixels on the bottom.
The relevant error-causing widget was:
Column file:///Users/wikiwoo/AndroidStudioProjects/etransfa/lib/christdoes/view/home_with_sidebar.dart:60:24
====================================================================================================
======== Exception caught by rendering library =====================================================
A RenderFlex overflowed by 21 pixels on the bottom.
The relevant error-causing widget was:
Column file:///Users/wikiwoo/AndroidStudioProjects/etransfa/lib/christdoes/view/home_page.dart:37:60
====================================================================================================
Комментарии:
1. Обратите внимание, что здесь мы предпочитаем технический стиль письма. Мы мягко препятствуем приветствиям, надеемся, что вы можете помочь, спасибо, заранее благодарим, благодарственные письма, пожелания, добрые пожелания, подписи, пожалуйста, помогите, болтливые материалы и сокращенные txtspk, мольбы, как долго вы застряли, советы по голосованию, мета-комментарии и т. Д. Просто объясните свою проблему и покажите, что вы пробовали, чего ожидали и что на самом деле произошло.