问题描述
错误仅在 IOS 中,相同的代码在 Android 上运行流畅:
======== Exception caught by gesture library =======================================================
The following assertion was thrown while routing a pointer event:
RenderBox was not laid out: RenderUiKitView#ceff7 NEEDS-LAYOUT NEEDS-PAINT
'package:Flutter/src/rendering/Box.dart':
Failed assertion: line 1940 pos 12: 'hasSize'
代码:
import 'package:Flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:zippy_rider/states/map_state.dart';
class Testing extends StatefulWidget {
@override
_TestingState createState() => _TestingState();
}
class _TestingState extends State<Testing> {
@override
Widget build(BuildContext context) {
final mapState = Provider.of<MapState>(context);
return Scaffold(
body: Stack(
children: [
Positioned(
top: 50.0,right: 17.0,left: 12.0,child: Visibility(
visible: true,//mapState.stackElementsVisibility,child: Container(
height: 55.0,width: double.infinity,decoration: Boxdecoration(
borderRadius: BorderRadius.circular(3.0),color: Colors.white,BoxShadow: [
BoxShadow(
color: Colors.grey,offset: Offset(1.0,1.0),blurRadius: 5.0,spreadRadius: 2.0)
],),child: TextField(
cursorColor: Colors.black,controller: mapState.sourceController,onChanged: (bool) {
mapState.suggestions(bool);
},onEditingComplete: () {
mapState.clearSuggestion();
},decoration: Inputdecoration(
icon: Container(
child: Icon(Icons.location_on),margin: EdgeInsets.only(
left: 8.0,top: 0.5,bottom: 5),width: 5.0,height: 13,suffix: IconButton(
icon: Icon(
Icons.clear,size: 15.0,onpressed: () {
mapState.sourceController.clear();
mapState.clearfields();
mapState.clearSuggestion();
}),hintText: "pick up",border: InputBorder.none,contentPadding: EdgeInsets.only(
left: 6.0,top: 8.0,right: 6.0),)),Positioned(
left: 12,right: 17,top: 100,child: Column(
children: [
SizedBox(
height:200.0,child: Scrollbar(
thickness: 10.0,radius: Radius.circular(10.0),isAlwaysShown: true,child: ListView.builder(
itemCount: mapState.suggestion.length,padding: EdgeInsets.all(0.0),itemBuilder: (context,index) {
if (mapState.suggestion.isNotEmpty) {
return Card(
margin: EdgeInsets.only(bottom: 1.0),child: ListTile(
title: Text(
mapState.suggestion[index],style: TextStyle(color: Colors.black),onTap: () {
//mapState.suggestion.clear();
mapState.clearfields();
print(
'SUGGESTION: ${mapState.suggestion}');
mapState.clearSuggestion();
print(
'SUGGESTION: ${mapState.suggestion}');
},);
} else {
return Center(
child: Container(
child: CircularProgressIndicator(),);
}
},],);
}
}
它与其他问题的不同之处: RenderUiKitView
我已经尝试过的:
https://flutteragency.com/how-to-solve-render-box-was-not-laid-out-in-flutter/
https://github.com/flutter/flutter/issues/47235
为什么不在 Github 上创建问题?:不知道这个问题是否可以重现。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)