我正在使用使用scrollable_bottom_sheet 0.2.1
包中的ScrollableBottomSheet
的应用程序。它有一些TextField
,但是在打开键盘时出现此错误:
═╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
The following ArgumentError was thrown building LayoutBuilder:
Invalid argument(s): 706.1236363636364
The relevant error-causing widget was:
ScrollableBottomSheet
lib/main.dart:47
When the exception was thrown, this was the stack:
#0 double.clamp (dart:core-patch/double.dart:183:7)
#1 _ScrollableBottomSheetState.build.<anonymous closure>
package:scrollable_bottom_sheet/scrollable_bottom_sheet.dart:244
#2 _LayoutBuilderElement._layout.<anonymous closure>
package:flutter/…/widgets/layout_builder.dart:121
#3 BuildOwner.buildScope
package:flutter/…/widgets/framework.dart:2620
#4 _LayoutBuilderElement._layout
package:flutter/…/widgets/layout_builder.dart:117
#5 RenderObject.invokeLayoutCallback.<anonymous closure>
package:flutter/…/rendering/object.dart:1868
#6 PipelineOwner._enableMutationsToDirtySubtrees
package:flutter/…/rendering/object.dart:920
#7 RenderObject.invokeLayoutCallback
package:flutter/…/rendering/object.dart:1868
#8 RenderConstrainedLayoutBuilder.rebuildIfNecessary
package:flutter/…/widgets/layout_builder.dart:226
#9 _RenderLayoutBuilder.performLayout
package:flutter/…/widgets/layout_builder.dart:299
#10 RenderObject.layout
package:flutter/…/rendering/object.dart:1769
#11 RenderProxyBoxMixin.performLayout
package:flutter/…/rendering/proxy_box.dart:115
#12 RenderObject.layout
package:flutter/…/rendering/object.dart:1769
#13 RenderProxyBoxMixin.performLayout
package:flutter/…/rendering/proxy_box.dart:115
#14 RenderObject.layout
package:flutter/…/rendering/object.dart:1769
#15 RenderProxyBoxMixin.performLayout
package:flutter/…/rendering/proxy_box.dart:115
#16 _RenderCustomClip.performLayout
package:flutter/…/rendering/proxy_box.dart:1269
#17 RenderObject.layout
package:flutter/…/rendering/object.dart:1769
#18 RenderProxyBoxMixin.performLayout
package:flutter/…/rendering/proxy_box.dart:115
#19 RenderObject.layout
package:flutter/…/rendering/object.dart:1769
#20 RenderProxyBoxMixin.performLayout
package:flutter/…/rendering/proxy_box.dart:115
#21 RenderObject.layout
package:flutter/…/rendering/object.dart:1769
#22 RenderPositionedBox.performLayout
package:flutter/…/rendering/shifted_box.dart:396
#23 RenderObject.layout
package:flutter/…/rendering/object.dart:1769
#24 RenderStack.performLayout
package:flutter/…/rendering/stack.dart:560
#25 RenderObject.layout
package:flutter/…/rendering/object.dart:1769
#26 MultiChildLayoutDelegate.layoutChild
package:flutter/…/rendering/custom_layout.dart:173
#27 _ScaffoldLayout.performLayout
package:flutter/…/material/scaffold.dart:520
#28 MultiChildLayoutDelegate._callPerformLayout
package:flutter/…/rendering/custom_layout.dart:242
#29 RenderCustomMultiChildLayoutBox.performLayout
package:flutter/…/rendering/custom_layout.dart:401
#30 RenderObject._layoutWithoutResize
package:flutter/…/rendering/object.dart:1632
#31 PipelineOwner.flushLayout
package:flutter/…/rendering/object.dart:889
#32 RendererBinding.drawFrame
package:flutter/…/rendering/binding.dart:404
#33 WidgetsBinding.drawFrame
package:flutter/…/widgets/binding.dart:867
#34 RendererBinding._handlePersistentFrameCallback
package:flutter/…/rendering/binding.dart:286
#35 SchedulerBinding._invokeFrameCallback
package:flutter/…/scheduler/binding.dart:1115
#36 SchedulerBinding.handleDrawFrame
package:flutter/…/scheduler/binding.dart:1054
#37 SchedulerBinding._handleDrawFrame
package:flutter/…/scheduler/binding.dart:970
#41 _invoke (dart:ui/hooks.dart:253:10)
#42 _drawFrame (dart:ui/hooks.dart:211:3)
(elided 3 frames from dart:async)
════════════════════════════════════════════════════════════════════════════════════════════════════
这是我正在使用的代码:
class ContactsButton extends StatelessWidget {
@override
Widget build(BuildContext context) {
return FlatButton(
color: Colors.white,
child: Text('Contacts'),
onPressed: () {
showBottomSheet(
context: context,
clipBehavior: Clip.antiAlias,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.only(
topRight: Radius.circular(10),
topLeft: Radius.circular(10),
),
),
builder: (BuildContext context) {
return ScrollableBottomSheet(
halfHeight: MediaQuery.of(context).size.height * 0.93,
minimumHeight: MediaQuery.of(context).size.height * 0.93,
child: TabbedSheet(),
);
},
);
},
);
}
}
class TabbedSheet extends StatefulWidget {
const TabbedSheet({Key key}) : super(key: key);
@override
_TabbedSheetState createState() => _TabbedSheetState();
}
class _TabbedSheetState extends State<TabbedSheet>
with SingleTickerProviderStateMixin {
final List<Tab> myTabs = <Tab>[
Tab(text: ''),
Tab(text: ''),
];
TabController _tabController;
@override
void initState() {
super.initState();
_tabController = TabController(vsync: this, length: myTabs.length);
}
@override
void dispose() {
_tabController.dispose();
super.dispose();
}
void tabChangedCallback() {
_tabController.animateTo(_tabController.index == 0 ? 1 : 0);
setState(() {});
}
@override
Widget build(BuildContext context) {
int reduceHeight = _tabController.index == 0 ? 20 : 56;
return Container(
color: DeliveroLightPurple,
child: Column(
children: [
HeaderCard(
tabController: _tabController,
tabChangedCallback: tabChangedCallback,
),
Container(
height: MediaQuery.of(context).size.height * 0.93 - reduceHeight,
child: TabBarView(
physics: NeverScrollableScrollPhysics(),
controller: _tabController,
children: [
StorageUpload(tabChangedCallback: tabChangedCallback),
ContactsPage()
],
),
),
],
),
);
}
}
我不明白为什么会出现此错误。任何帮助都会很棒。谢谢!