发布模式下 Flutter 灰屏错误如何解决?
Posted
技术标签:
【中文标题】发布模式下 Flutter 灰屏错误如何解决?【英文标题】:Flutter gray screnn error in release mode how to Solve it? 【发布时间】:2021-04-12 08:15:18 【问题描述】:我不知道为什么在颤振释放模式下会出现灰屏错误,但我想正确解决它知道有人给我完美的答案,因为我想以任何方式解决它,请告诉我
在下面的代码中,在发布模式下出现灰屏...................................... ..................................................... ..................................................... .....................
drawer.dart
class MyDrawer extends StatelessWidget
@override
Widget build(BuildContext context)
return Drawer(
child: ListView(
children: [
Container(
padding:EdgeInsets.only(top: 25.0,bottom:10.0),
decoration: new BoxDecoration(
gradient: new LinearGradient(
colors: [Colors.indigo,
Colors.lightGreenAccent],
begin: const FractionalOffset(0.0, 0.0),
end: const FractionalOffset(1.0,0.0),
stops: [0.0,1.0],
tileMode: TileMode.clamp,
),
),
child: Column(
children: [
Material(
borderRadius:BorderRadius.all(
Radius.circular(80.0)),
elevation: 8.0,
child: Container(
height: 120.0,
width: 120.0,
child: CircleAvatar(
backgroundImage:NetworkImage(
EcommerceApp.sharedPreferences.getString(EcommerceApp.userAvatarUrl),
),
),
),
),
SizedBox(
height: 10.0,),
Text(
EcommerceApp.sharedPreferences.getString(EcommerceApp.userName),
style: TextStyle(color: Colors.white,fontSize: 35.0,fontFamily: "Signatra"
),
),
],
),
),
SizedBox(height:12.0,),
Container(padding:EdgeInsets.only(top:1.0),
decoration:new BoxDecoration(
gradient:new LinearGradient(
colors:[Colors.blue,Colors.lightGreenAccent],
begin:const FractionalOffset(0.0,0.0),
end:const FractionalOffset(1.0,0.0),
stops:[0.0,1.0],
tileMode:TileMode.clamp,
),
),
child:Column(
children: [
ListTile(
leading:Icon(Icons.home,color:Colors.white),
title: Text("Home",style: TextStyle(color: Colors.white),),
onTap:()
Route route =MaterialPageRoute(builder:(c)=>MainPage());
Navigator.push(context, route);
,
),
Divider(height: 10.0,color:Colors.white,thickness: 6.0,),
ListTile(
leading:Icon(Icons.reorder,color:Colors.white),
title: Text("My Orders",style: TextStyle(color: Colors.white),),
onTap:()
Route route =MaterialPageRoute(builder:(c)=>MyOrders());
Navigator.push(context, route);
,
),
Divider(height: 10.0,color:Colors.white,thickness: 6.0,),
ListTile(
leading:Icon(Icons.shopping_cart_outlined,color:Colors.white),
title: Text("My Cart",style: TextStyle(color: Colors.white),),
onTap:()
Route route =MaterialPageRoute(builder:(c)=>CartPage());
Navigator.push(context, route);
,
),
Divider(height: 10.0,color:Colors.white,thickness: 6.0,),
ListTile(
leading:Icon(Icons.search,color:Colors.white),
title: Text("Search",style: TextStyle(color: Colors.white),),
onTap:()
Route route =MaterialPageRoute(builder:(c)=>SearchProduct());
Navigator.push(context, route);
,
),
Divider(height: 10.0,color:Colors.white,thickness: 6.0,),
ListTile(
leading:Icon(Icons.add_location,color:Colors.white),
title: Text("Add New address",style: TextStyle(color: Colors.white),),
onTap:()
Route route =MaterialPageRoute(builder:(c)=>AddAddress());
Navigator.push(context, route);
,
),
Divider(height: 10.0,color:Colors.white,thickness: 6.0,),
ListTile(
leading:Icon(Icons.exit_to_app,color:Colors.white),
title: Text("Logout",style: TextStyle(color: Colors.white),),
onTap:()
EcommerceApp.auth.signOut().then((c)
Route route =MaterialPageRoute(builder: (c)
=> ChooseScreen());
Navigator.pushReplacement(context, route);
);
,
),
Divider(height: 10.0,color:Colors.white,thickness: 6.0,),
SizedBox(height: 30.0,),
Text(
"Welcome Dear "+EcommerceApp.sharedPreferences.getString(EcommerceApp.userName), style: TextStyle
(color: Colors.white, fontSize: 15.0,fontWeight:FontWeight.bold),),
Text(
"World largest & Number One Online Shop ", style: TextStyle
(color: Colors.white, fontSize: 15.0,fontWeight:FontWeight.w100),),
Text(
"E-Store-Shopping", style: TextStyle
(color: Colors.black,fontFamily: "Signatra",fontSize: 25.0),),
Text(
"Made in india", style: TextStyle
(color: Colors.black,),),
Text(
"Copyright @ 2021", style: TextStyle
(color: Colors.black,),),
SizedBox(height: 30.0,),
],
),
),
],
),
);
【问题讨论】:
让我们看看代码:) 通常我在使用 Expanded, Flexible 时会遇到这个问题 它发生在一个孩子中有不正确的父小部件,这通常在扩展,灵活的小部件中,检查您的终端是否有错误或警告消息,例如“父小部件的错误使用”@Aakib Algohar跨度> 【参考方案1】:如果您在发布模式下出现灰屏,则可能是您的屏幕代码有问题。 尝试调试模式并检查您的代码。
【讨论】:
以上是关于发布模式下 Flutter 灰屏错误如何解决?的主要内容,如果未能解决你的问题,请参考以下文章
Flutter - Sentry如何在调试模式下发送事件和停止发送
如何使用Android Studio解决抖动中的gradle错误?