はじめに
The following assertion was thrown during layout:
A RenderFlex overflowed by 16 pixels on the bottom.
よくあるエラーに遭遇し、「SingleChildScrollView
で囲むの忘れてた〜」くらいの気持ちで👇のように修正
@override
Widget build(BuildContext context) {
final UserProvider userProvider = Provider.of<UserProvider>(context);
SizeConfig().init(context);
return SingleChildScrollView(
child: Scaffold(
appBar: AppBar(
title: Text(
'投稿',
style: Theme.of(context).textTheme.headline6,
),
backgroundColor: primaryColor,
),
body: Container(
padding: EdgeInsets.symmetric(
vertical: SizeConfig.blockSizeVertical! * 5,
horizontal: SizeConfig.blockSizeHorizontal! * 5,
),
child: Form(
// 以下つづく
高さが無限と言われた
The following assertion was thrown during performLayout():
RenderCustomMultiChildLayoutBox object was given an infinite size during layout.
This probably means that it is a render object that tries to be as big as possible, but it was put inside another render object that allows its children to pick their own size.
The nearest ancestor providing an unbounded height constraint is: _RenderSingleChildViewport#1d861 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
The constraints that applied to the RenderCustomMultiChildLayoutBox were: BoxConstraints(w=375.0, 0.0<=h<=Infinity)
The exact size it was given was: Size(375.0, Infinity)
See https://flutter.dev/docs/development/ui/layout/box-constraints for more information.
The relevant error-causing widget was
Scaffold
lib/…/post/post_screen.dart:60
When the exception was thrown, this was the stack
════════ Exception caught by rendering library ═════════════════════════════════
RenderPhysicalModel object was given an infinite size during layout.
The relevant error-causing widget was
Scaffold
lib/…/post/post_screen.dart:60
════════════════════════════════════════════════════════════════════════════════
こんな感じで長文のエラーメッセージをいただきました。。。
ScaffoldにSingleChildScrollViewはダメ
めっちゃ盛大に勘違いしてました。。
SingleChildScrollView
をScaffold
にやっているではありませんか
👇のように修正
@override
Widget build(BuildContext context) {
final UserProvider userProvider = Provider.of<UserProvider>(context);
SizeConfig().init(context);
return Scaffold(
appBar: AppBar(
title: Text(
'投稿',
style: Theme.of(context).textTheme.headline6,
),
backgroundColor: primaryColor,
),
// Scaffoldではなくbodyの中のContainerにSingleChildScrollViewを適応
body: SingleChildScrollView(
child: Container(
padding: EdgeInsets.symmetric(
vertical: SizeConfig.blockSizeVertical! * 5,
horizontal: SizeConfig.blockSizeHorizontal! * 5,
),
child: Form(
key: _form,
child: Column(
children: <Widget>[
// 以下つづく
勘違いしないように気をつけましょう!
Scaffold
は高さInfinityです