Firebase Firebse断言失败:第380行位置10:';数据!=空'; 导入“包装:颤振/材料.省道”; 导入“package:flatter_myapp/AllWidgets/Divider.dart”; 导入“package:flatter_m
Firebse断言失败:第380行位置10:';数据!=空';Firebase Firebse断言失败:第380行位置10:';数据!=空'; 导入“包装:颤振/材料.省道”; 导入“package:flatter_myapp/AllWidgets/Divider.dart”; 导入“package:flatter_m,firebase,flutter,Firebase,Flutter,Firebse断言失败:第380行位置10:';数据!=空'; 导入“包装:颤振/材料.省道”; 导入“package:flatter_myapp/AllWidgets/Divider.dart”; 导入“package:flatter_myapp/AllWidgets/progressDialog.dart”; 导入“package:flatter_myapp/Assistants/requestAssistant.dart”; 导入“package:flatter_myapp
导入“包装:颤振/材料.省道”;
导入“package:flatter_myapp/AllWidgets/Divider.dart”;
导入“package:flatter_myapp/AllWidgets/progressDialog.dart”;
导入“package:flatter_myapp/Assistants/requestAssistant.dart”;
导入“package:flatter_myapp/DataHandler/appData.dart”;
导入“package:flatter_myapp/Models/address.dart”;
导入“package:flatter_myapp/Models/placePredictions.dart”;
导入“包:flatter_myapp/configMaps.dart”;
导入“包:provider/provider.dart”;
类SearchScreen扩展StatefulWidget{
@凌驾
_SearchScreenState createState()=>\u SearchScreenState();
}
类_SearchScreenState扩展状态
{
TextEditingController pickUpTextEditingController=TextEditingController();
TextEditingController dropOffTextEditingController=TextEditingController();
List placePredictionList=[];
@凌驾
小部件构建(构建上下文)
{
字符串placeAddress=Provider.of(context.pickUpLocation.placeName??”;
pickUpTextEditingController.text=placeAddress;
返回脚手架(
正文:专栏(
儿童:[
容器(
身高:215.0,
装饰:盒子装饰(
颜色:颜色,白色,
boxShadow:[
箱形阴影(
颜色:颜色,黑色,
半径:6.0,
扩展半径:0.5,
偏移量:偏移量(0.7,0.7),
),
],
),
孩子:填充(
填充:仅限边设置(左:25.0,顶部:25.0,底部:20.0),
子:列(
儿童:[
尺寸箱(高度:5.0),
堆叠(
儿童:[
手势检测器(
onTap:()
{
Navigator.pop(上下文);
},
子:图标(
图标。返回箭头
),
),
居中(
子项:文本(“设置下拉”,样式:TextStyle(fontSize:18.0,fontFamily:“品牌粗体”),
)
],
),
尺寸箱(高度:16.0),
划船(
儿童:[
资产(“images/pickicon.png”,高度:16.0,宽度:16.0,),
尺寸标注框(宽度:18.0,),
扩大(
子:容器(
装饰:盒子装饰(
颜色:颜色。灰色[400],
边界半径:边界半径。圆形(5.0),
),
孩子:填充(
填充:所有边缘设置(3.0),
孩子:TextField(
控制器:pickUpTextEditingController,
装饰:输入装饰(
hintText:“收货地点”,
fillColor:Colors.grey[400],
是的,
边框:InputBorder.none,
是的,
contentPadding:仅限边集(左:11.0,顶部:8.0,底部:8.0),
),
),
),
),
),
],
),
尺寸箱(高度:10.0),
划船(
儿童:[
资产(“images/desticon.png”,高度:16.0,宽度:16.0,),
尺寸标注框(宽度:18.0,),
扩大(
子:容器(
装饰:盒子装饰(
颜色:颜色。灰色[400],
边界半径:边界半径。圆形(5.0),
),
孩子:填充(
填充:所有边缘设置(3.0),
孩子:TextField(
一旦更改:(val)
{
findPlace(val);
},
控制器:dropOffTextEditingController,
装饰:输入装饰(
hintText:“去哪里?”,
fillColor:Colors.grey[400],
是的,
边框:InputBorder.none,
是的,
contentPadding:仅限边集(左:11.0,顶部:8.0,底部:8.0),
),
),
),
),
),
],
),
],
),
),
),
//为预测平铺
尺寸箱(高度:10.0,),
(placePredictionList.length>0)
?填充物(
填充:边缘组。对称(垂直:8.0,水平:16.0),
子项:ListView.separated(
填充:所有边缘设置(0.0),
itemBuilder:(上下文,索引)
{
返回PredictionTile(placePredictions:placePredictionList[index],);
},
separatorBuilder:(BuildContext,int index)=>DividerWidget(),
itemCount:placePredictionList.length,
收缩膜:对,
物理:ClampingScrollPhysics(),
),
)
import 'package:flutter/material.dart';
import 'package:flutter_myapp/AllWidgets/Divider.dart';
import 'package:flutter_myapp/AllWidgets/progressDialog.dart';
import 'package:flutter_myapp/Assistants/requestAssistant.dart';
import 'package:flutter_myapp/DataHandler/appData.dart';
import 'package:flutter_myapp/Models/address.dart';
import 'package:flutter_myapp/Models/placePredictions.dart';
import 'package:flutter_myapp/configMaps.dart';
import 'package:provider/provider.dart';
class SearchScreen extends StatefulWidget {
@override
_SearchScreenState createState() => _SearchScreenState();
}
class _SearchScreenState extends State<SearchScreen>
{
TextEditingController pickUpTextEditingController = TextEditingController();
TextEditingController dropOffTextEditingController = TextEditingController();
List<PlacePredictions> placePredictionList = [];
@override
Widget build(BuildContext context)
{
String placeAddress = Provider.of<AppData>(context).pickUpLocation.placeName ?? "";
pickUpTextEditingController.text = placeAddress;
return Scaffold(
body: Column(
children: [
Container(
height: 215.0,
decoration: BoxDecoration(
color: Colors.white,
boxShadow: [
BoxShadow(
color: Colors.black,
blurRadius: 6.0,
spreadRadius: 0.5,
offset: Offset(0.7, 0.7),
),
],
),
child: Padding(
padding: EdgeInsets.only(left: 25.0, top: 25.0, bottom: 20.0),
child: Column(
children: [
SizedBox(height: 5.0),
Stack(
children: [
GestureDetector(
onTap:()
{
Navigator.pop(context);
},
child: Icon(
Icons.arrow_back
),
),
Center(
child: Text("Set Drop Off", style: TextStyle(fontSize: 18.0, fontFamily: "Brand Bold"),),
)
],
),
SizedBox(height: 16.0),
Row(
children: [
Image.asset("images/pickicon.png", height: 16.0, width: 16.0,),
SizedBox(width: 18.0,),
Expanded(
child: Container(
decoration: BoxDecoration(
color: Colors.grey[400],
borderRadius: BorderRadius.circular(5.0),
),
child: Padding(
padding: EdgeInsets.all(3.0),
child: TextField(
controller: pickUpTextEditingController,
decoration: InputDecoration(
hintText: "PickUp Location",
fillColor: Colors.grey[400],
filled: true,
border: InputBorder.none,
isDense: true,
contentPadding: EdgeInsets.only(left: 11.0, top: 8.0, bottom: 8.0),
),
),
),
),
),
],
),
SizedBox(height: 10.0),
Row(
children: [
Image.asset("images/desticon.png", height: 16.0, width: 16.0,),
SizedBox(width: 18.0,),
Expanded(
child: Container(
decoration: BoxDecoration(
color: Colors.grey[400],
borderRadius: BorderRadius.circular(5.0),
),
child: Padding(
padding: EdgeInsets.all(3.0),
child: TextField(
onChanged: (val)
{
findPlace(val);
},
controller: dropOffTextEditingController,
decoration: InputDecoration(
hintText: "Where to? ",
fillColor: Colors.grey[400],
filled: true,
border: InputBorder.none,
isDense: true,
contentPadding: EdgeInsets.only(left: 11.0, top: 8.0, bottom: 8.0),
),
),
),
),
),
],
),
],
),
),
),
//tile for predictions
SizedBox(height: 10.0,),
(placePredictionList.length > 0)
?Padding(
padding: EdgeInsets.symmetric(vertical: 8.0, horizontal: 16.0),
child: ListView.separated(
padding: EdgeInsets.all(0.0),
itemBuilder: (context, index)
{
return PredictionTile(placePredictions: placePredictionList[index],);
},
separatorBuilder: (BuildContext context, int index) => DividerWidget(),
itemCount: placePredictionList.length,
shrinkWrap: true,
physics: ClampingScrollPhysics(),
),
)
:Container(),
],
),
);
}
void findPlace(String placeName) async
{
if(placeName.length > 1)
{
String autoCompleteUrl = "https://maps.googleapis.com/maps/api/place/autocomplete/json?input=$placeName&key=$mapKey&sessiontoken=1234567890&components=country:us";
var res = await RequestAssistant.getRequest(autoCompleteUrl);
if(res == "failed")
{
return;
}
//print("Places Predictions Response :: ");
//print(res);
if(res["status"] == "OK")
{
var predictions = res["predictions"];
var placeList = (predictions as List).map((e) => PlacePredictions.fromJson(e)).toList();
setState(() {
placePredictionList = placeList;
});
}
}
}
}
class PredictionTile extends StatelessWidget
{
final PlacePredictions placePredictions;
PredictionTile({Key key,this.placePredictions}) : super(key: key);
@override
Widget build(BuildContext context)
{
return FlatButton(
padding: EdgeInsets.all(0.0),
onPressed: ()
{
getPlaceAddressDetails(placePredictions.place_id, context);
},
child: Container(
child: Column(
children: [
SizedBox(width: 10.0,),
Row(
children: [
Icon(Icons.add_location),
SizedBox(width: 14.0,),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(height: 8.0,),
Text(placePredictions.main_text, overflow: TextOverflow.ellipsis, style: TextStyle(fontSize: 16.0),),
SizedBox(height: 2.0,),
Text(placePredictions.secondary_text, overflow: TextOverflow.ellipsis, style: TextStyle(fontSize: 12.0, color: Colors.grey),),
SizedBox(height: 8.0,),
],
),
),
],
),
SizedBox(width: 10.0,),
],
),
),
);
}
void getPlaceAddressDetails(String placeId, context) async
{
showDialog(
context: context,
builder: (BuildContext context) => ProgressDialog(message: "Setting Drop off, Please wait....",),
);
String placeDetailsUrl = "https://maps.googleapis.com/maps/api/place/details/json?place_id=$placeId&key=$mapKey";
var res = await RequestAssistant.getRequest(placeDetailsUrl);
Navigator.pop(context);
if(res == "failed")
{
return;
}
if(res["status"] == "OK")
{
Address address = Address();
address.placeName = res["result"]["name"];
address.placeId = placeId;
address.latitude = res["result"]["geometry"]["location"]["lat"];
address.longitude = res["result"]["geometry"]["location"]["lng"];
Provider.of<AppData>(context, listen: false).updateDropOffLocationAddress(address);
print("This is Drop Off Location :: ");
print(address.placeName);
Navigator.pop(context, "obtainDirection");
}
}
}
Text(placePredictions.main_text, overflow: TextOverflow.ellipsis, style: TextStyle(fontSize: 16.0),),
Text(placePredictions.secondary_text, overflow: TextOverflow.ellipsis, style: TextStyle(fontSize: 12.0, color: Colors.grey),),
Text(placePredictions.main_text ?? 'n/a', overflow: TextOverflow.ellipsis, style: TextStyle(fontSize: 16.0),),
Text(placePredictions.secondary_text ?? 'n/a', overflow: TextOverflow.ellipsis, style: TextStyle(fontSize: 12.0, color: Colors.grey),),