【发布时间】:2021-02-01 18:34:50
【问题描述】:
我收到以下错误:
IllegalFloatingActionButtonSizeException:浮动操作按钮必须 是一个圆圈文件“circular_notch_and_corner_clipper.dart”,第 25 行, 在 CircularNotchedAndCorneredRectangleClipper.getClip 文件中 _RenderCustomClip._updateClip 文件中的“proxy_box.dart”,第 1314 行 “proxy_box.dart”,第 1935 行,在 RenderPhysicalShape.paint 文件中 “object.dart”,第 2311 行,在 RenderObject._paintWithContext 文件中 “object.dart”,第 189 行,在 PaintingContext.paintChild 文件中 “box.dart”,第 2826 行,在 RenderBoxContainerDefaultsMixin.defaultPaint 文件“custom_layout.dart”,第 407 行,在 RenderCustomMultiChildLayoutBox.paint 文件“object.dart”,第 2311 行, 在 RenderObject._paintWithContext 文件“object.dart”,第 189 行,在 PaintingContext.paintChild 文件“proxy_box.dart”,第 131 行,在 RenderProxyBoxMixin.paint 文件“material.dart”,第 555 行,在 _RenderInkFeatures.paint 文件“object.dart”,第 2311 行,在 RenderObject._paintWithContext 文件“object.dart”,第 189 行,在 PaintingContext.paintChild 文件“proxy_box.dart”,第 131 行,在 RenderProxyBoxMixin.paint 文件“object.dart”,第 396 行,在 PaintingContext.pushLayer 文件“proxy_box.dart”,第 1862 行,在 RenderPhysicalModel.paint 文件“object.dart”,第 2311 行,在 RenderObject._paintWithContext 文件“object.dart”,第 189 行,在 PaintingContext.paintChild 文件“proxy_box.dart”,第 131 行,在 RenderProxyBoxMixin.paint 文件“object.dart”,第 2311 行,在 RenderObject._paintWithContext 文件“object.dart”,第 189 行,在 PaintingContext.paintChild 文件“proxy_box.dart”,第 131 行,在 RenderProxyBoxMixin.paint 文件“object.dart”,第 2311 行,在 RenderObject._paintWithContext 文件“object.dart”,第 189 行,在 PaintingContext.paintChild 文件“proxy_box.dart”,第 131 行,在 RenderProxyBoxMixin.paint 文件“object.dart”,第 2311 行,在 RenderObject._paintWithContext 文件“object.dart”,第 140 行,在 PaintingContext._repaintCompositedChild 文件“object.dart”,行 100、在 PaintingContext.repaintCompositedChild 文件“object.dart”中, 第 978 行,在 PipelineOwner.flushPaint 文件“binding.dart”中,第 438 行, 在 RendererBinding.drawFrame 文件“binding.dart”,第 914 行,在 WidgetsBinding.drawFrame 文件“binding.dart”,第 302 行,在 RendererBinding._handlePersistentFrameCallback 文件“binding.dart”, 第 1117 行,在 SchedulerBinding._invokeFrameCallback 文件中 “binding.dart”,第 1055 行,在 SchedulerBinding.handleDrawFrame 文件中 “binding.dart”,第 971 行,在 SchedulerBinding._handleDrawFrame 文件中 “zone.dart”,第 1190 行,在 _rootRun 文件中“zone.dart”,第 1093 行,在 _CustomZone.run 文件“zone.dart”,第 997 行,_CustomZone.runGuarded 文件“hooks.dart”,第 251 行,_invoke 文件“hooks.dart”,第 209 行,_drawFrame
我想这可能与设备类型有关,但我不确定。这是我看到错误的设备之一:
品牌:“三星”,设备:“crownlte”,型号:“SM-N960F”
相关代码:
import 'package:animated_bottom_navigation_bar/animated_bottom_navigation_bar.dart';
AnimationController _animationController;
Animation<double> animation;
@override
void initState() {
_animationController = AnimationController(
duration: Duration(seconds: 1),
vsync: this,
);
CurvedAnimation curve = CurvedAnimation(
parent: _animationController,
curve: Interval(
0.5,
1.0,
curve: Curves.fastOutSlowIn,
),
);
animation = Tween<double>(
begin: 0,
end: 1,
).animate(curve);
WidgetsBinding.instance.addPostFrameCallback(
(_) {
_handleInternetConnection();
Future.delayed(
Duration(seconds: 1),
() {
if (mounted) _animationController.forward();
},
);
},
);
super.initState();
}
...
floatingActionButton: (_currentIndex != 3 && showFAB)
? ScaleTransition(
scale: animation,
child: FloatingActionButton(
elevation: 8,
foregroundColor: Colors.white,
child: Icon(
_currentIndex == 0
? Icons.edit
: Icons.face_retouching_natural,
size: 36,
),
onPressed: () => _currentIndex == 0
? NewStory.show(context, null)
: NewMood.show(context, null),
),
)
: null,
floatingActionButtonLocation:
FloatingActionButtonLocation.centerDocked,
bottomNavigationBar: AnimatedBottomNavigationBar(
icons: allDestinations()
.map((NavbarOption destination) => destination.icon)
.toList(),
activeColor: Colors.white,
splashColor: Theme.of(context).primaryColor,
activeIndex: _currentIndex,
gapLocation: GapLocation.center,
inactiveColor: Colors.white60,
notchAndCornersAnimation: animation,
backgroundColor: Theme.of(context).primaryColor,
notchSmoothness: NotchSmoothness.softEdge,
onTap: (index) => setState(() => _currentIndex = index),
),
),
【问题讨论】:
-
您确定可以使用最新版本的 animated_bottom_navigation_bar (0.3.2) 重现该问题吗?
-
我们能看到浮动操作按钮的代码吗?
-
@Deczaloth 是的,它发生在最后一个版本上,虽然这是一个间歇性问题,但我无法每次都重现它
-
@Apps247 我已经添加了代码
标签: flutter dart widget floating-action-button