Flutter RenderBox未布局:RenderUiKitView#ceff7需要-布局需要-绘制
错误仅在IOS中出现,相同的代码在Android上运行顺畅:Flutter RenderBox未布局:RenderUiKitView#ceff7需要-布局需要-绘制,flutter,dart,flutter-layout,flutter-ios,Flutter,Dart,Flutter Layout,Flutter Ios,错误仅在IOS中出现,相同的代码在Android上运行顺畅: ======== Exception caught by gesture library ======================================================= The following assertion was thrown while routing a pointer event: RenderBox was not laid out: RenderUiKitView#ceff7 NE
======== 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'
代码:
导入“包装:颤振/材料.省道”;
导入“包:provider/provider.dart”;
导入“package:zippy_-rider/states/map_-state.dart”;
类测试扩展了StatefulWidget{
@凌驾
_TestingState createState();
}
类_TestingState扩展状态{
@凌驾
小部件构建(构建上下文){
final mapState=Provider.of(上下文);
返回脚手架(
主体:堆栈(
儿童:[
定位(
排名:50.0,
右图:17.0,
左:12.0,
孩子:可见度(
可见:true,//mapState.stackElementsVisibility,
子:容器(
身高:55.0,
宽度:double.infinity,
装饰:盒子装饰(
边界半径:边界半径。圆形(3.0),
颜色:颜色,白色,
boxShadow:[
箱形阴影(
颜色:颜色。灰色,
偏移量:偏移量(1.0,1.0),
半径:5.0,
扩展半径:2.0)
],
),
孩子:TextField(
光标颜色:颜色。黑色,
控制器:mapState.sourceController,
一旦更改:(bool){
mapState.建议(bool);
},
onEditingComplete:(){
mapState.clearSuggestion();
},
装饰:输入装饰(
图标:容器(
子项:图标(图标位置打开),
页边距:仅限边距(
左:8.0,顶部:0.5,底部:5),
宽度:5.0,
身高:13,
),
后缀:IconButton(
图标:图标(
图标。清除,
尺寸:15.0,
),
已按下:(){
mapState.sourceController.clear();
mapState.clearfields();
mapState.clearSuggestion();
}),
hintText:“拾取”,
边框:InputBorder.none,
contentPadding:仅限EdgeInsets(
左:6.0,上:8.0,右:6.0),
),
),
),
)),
定位(
左:12,,
右:17,
前100名,
子:列(
儿童:[
大小盒子(
高度:200.0,
子:滚动条(
厚度:10.0,
半径:半径。圆形(10.0),
伊莎韦肖恩:没错,
子项:ListView.builder(
itemCount:mapState.suggestion.length,
填充:所有边缘设置(0.0),
itemBuilder:(上下文,索引){
if(mapState.suggestion.isNotEmpty){
回程卡(
边距:仅限边缘组(底部:1.0),
孩子:ListTile(
标题:正文(
mapState.建议[索引],
样式:TextStyle(颜色:Colors.black),
),
onTap:(){
//mapState.suggestion.clear();
mapState.clearfields();
印刷品(
'建议:${mapState.SUGGESTION}';
mapState.clearSuggestion();
印刷品(
'建议:${mapState.SUGGESTION}';
},
),
);
}否则{
返回中心(
子:容器(
子对象:CircularProgressIndicator(),
),
);
}
},
),
),
),
],
)),
],
),
);
}
}
它与其他问题有何不同:
RenderUiKitView
我已经尝试过的:为什么不在Github上创建问题?:不知道此问题是否可复制
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(),
),
);
}
},
),
),
),
],
)),
],
),
);
}
}