为什么我单击返回屏幕时出现renderflex底部错误



如何解决此问题?

问题是RenderFlex底部溢出了49个像素。当我单击代码中名为"navigator_before"的图标按钮时,就会出现这种情况。

为什么会出现错误?我该怎么修?

// This is Second Page
class SearchOnScreen extends StatelessWidget {
const SearchOnScreen ({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return DefaultLayout(
child: SafeArea(
top: true,
bottom: false,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 0.0),
child: Column(
children: [
Hero(
tag: 'Searching',
child: Material(
type: MaterialType.transparency,
child: CupertinoSearchTextField(
autofocus: true,
prefixIcon: IconButton( // <---------------------------- button
icon: Icon(Icons.navigate_before,
size: 30.0,),
onPressed: (){
Navigator.pop(context);
},
),
suffixInsets: EdgeInsets.only(right: 20),
prefixInsets: EdgeInsets.only(left: 10),
padding: EdgeInsets.only(left: 5,top: 15, bottom: 15),
decoration: BoxDecoration(
border: Border(bottom: BorderSide(width: 0.5, color: Color(0xff868686)))
),
),
),
),
],
),
),
),
);
}
}
// This is first Page
...
child: Column(
children: [
const SizedBox(height: 250.0,),
InkWell(
splashColor: Colors.transparent, // 누르고있을 때, 물결효과 제거하기,
highlightColor: Colors.transparent, // 누르고있을 때, 물결효과 제거하기,
onTap: (){
Navigator.of(context).push(
MaterialPageRoute(
builder: (BuildContext context){
return SearchOnScreen();
}
),
);
},
child: IgnorePointer(
child: Hero(
tag: 'Searching',
child: MainSearchTextFormField()),
),
),
]
)

我试图将前缀封装在Column中。但是错误也发生了。所以我去掉了柱子。

尝试将Column封装在SingleChildScrollView小部件中。这可能会解决您的问题。它将允许页面在页面导航动画发生时滚动。

然后,如果您不希望用户手动滚动此列,请将SingleChildScrollViewphysics属性设置为const NeverScrollableScrollPhysics()

最新更新