
我是Flutter的新手,使用底板工作.底板具有正常的恒定高度.它的高度会随着拖动而增加.请参考下面的代码.问题是当底页尺寸正常时视图溢出.请参考所附图片.我想删除窗口中的溢出消息.
class MyBottomSheet extends StatefulWidget { @overrIDe _MyBottomSheetState createState() => new _MyBottomSheetState();}class _MyBottomSheetState extends State<MyBottomSheet> { Offset dragDetail; double slIDingPercent; static const PAGE_FulL_HEIGHT= 600.0; static const PAGE_norMAL_HEIGHT=80.0; SlIDeDirection direction; static double pageHeight = PAGE_norMAL_HEIGHT; static Pageposition pageposition = Pageposition.Bottom; onVerticalStart(DragStartDetails details) { dragDetail = details.globalposition; } onVerticalEnd(DragEndDetails details) { setState(() { if (pageHeight < 300) { pageHeight = PAGE_norMAL_HEIGHT; pageposition = Pageposition.Bottom; } else if (pageHeight > 300) { pageHeight = PAGE_FulL_HEIGHT; pageposition = Pageposition.top; } }); } onVerticalUpdate(DragUpdateDetails details) { setState(() { if (dragDetail != null) { final newposition = details.globalposition; final dy = dragDetail.dy - newposition.dy; if (dy > 0.0) { direction = SlIDeDirection.bottomTotop; } else if (dy < 0.0) { direction = SlIDeDirection.topToBottom; } if (direction == SlIDeDirection.bottomTotop && pageposition != Pageposition.top) { pageHeight = ((dy / PAGE_FulL_HEIGHT) * 1000).abs().clamp(PAGE_norMAL_HEIGHT, PAGE_FulL_HEIGHT); } else if (direction == SlIDeDirection.topToBottom && pageposition != Pageposition.Bottom) { pageHeight = PAGE_FulL_HEIGHT - ((dy / PAGE_FulL_HEIGHT) * 1000).abs().clamp(PAGE_norMAL_HEIGHT, PAGE_FulL_HEIGHT); } } }); } Column buildbuttonColumn(IconData icon, String label) { return new Column( mainAxisSize: MainAxisSize.min, mainAxisAlignment: MainAxisAlignment.center, children: [ new Icon(icon), new Container( margin: const EdgeInsets.only(left: 30.0,right: 30.0), child: new Text( label, style: new TextStyle( FontSize: 12.0, FontWeight: FontWeight.w400, color: colors.blue, ), ), ), ], ); } @overrIDe Widget build(BuildContext context) { return new Container( height: pageHeight, wIDth: Mediaquery.of(context).size.wIDth, child: new Stack( children: <Widget>[ new padding( padding: const EdgeInsets.fromLTRB(5.0, 5.0, 5.0, 0.0), child: new Card( elevation: 5.0, child: new PhysicalModel( shape: BoxShape.rectangle, borderRadius: new borderRadius.circular(5.0), color: colors.black12, child: new padding( padding: const EdgeInsets.all(8.0), child: new Column( children: <Widget>[ new Align( alignment: Alignment.topCenter, child: new Row( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ buildbuttonColumn(Icons.local_offer, 'Offer'), buildbuttonColumn(Icons.notifications_active, 'Notification'), buildbuttonColumn(Icons.shopPing_cart, 'Cart'), ], ), ), new divIDer(color: colors.black,) ], ), )), ), ), new GestureDetector( onVerticalDragStart: onVerticalStart, onVerticalDragEnd: onVerticalEnd, onVerticalDragUpdate: onVerticalUpdate, ) ], ), ); }}正常尺寸
全尺寸
解决方法:
在抖动中,溢出被视为错误.并且应该固定,不容忽视.
在您的情况下,它的高度是:底板的根容器中的height:pageHeight,因为它太小会导致问题.
删除或增加其价值应该可以解决您的问题.
总结以上是内存溢出为你收集整理的android-如何在Flutter中隐藏布局溢出消息全部内容,希望文章能够帮你解决android-如何在Flutter中隐藏布局溢出消息所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)