我使用Flutter,Firebase和谷歌API创建一个超级克隆,这是我的主页,我使用谷歌MapAPI渲染谷歌Map
它工作,但在控制台,它渲染的语气是这样的:I/BufferQueueProducer( 4851): [SurfaceTexture-0-4851-0](this:0x79990db000,id:0,api:1,p:471,c:-1) queueBuffer: slot 0 is dropped, handle=0x79c7c5ec00
这是MainPage.dart
的代码:
import 'dart:async';
import 'package:firebase_database/firebase_database.dart';
import 'package:flutter/material.dart';
import 'package:flutter_polyline_points/flutter_polyline_points.dart';
import 'package:geolocator/geolocator.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart';
import 'package:provider/provider.dart';
import 'package:uber_clone/BrandColors.dart';
import 'package:uber_clone/DataModels/DirectionDetail.dart';
import 'package:uber_clone/GlobalVariables.dart';
import 'package:uber_clone/Helpers/HelperMethods.dart';
import 'package:uber_clone/Providers/AppData.dart';
import 'package:uber_clone/Screens/SearchPage.dart';
import 'package:uber_clone/Widgets/CustomedBackButton.dart';
import 'package:uber_clone/Widgets/DrawerListItem.dart';
import 'package:uber_clone/Widgets/TaxiButton.dart';
class MainPage extends StatefulWidget {
static const String id = 'main';
@override
_MainPageState createState() => _MainPageState();
}
class _MainPageState extends State<MainPage> with TickerProviderStateMixin {
GlobalKey<ScaffoldState> scaffoldKey = new GlobalKey<ScaffoldState>();
Completer<GoogleMapController> _controller = Completer();
GoogleMapController mapController;
Position currentPosition;
double rideDetailSheetHeight = 0;
double searchSheetHeight = 300;
double requestRideSheetHeight = 0;
double mapPaddingBottom = 300;
List<LatLng> polylineCoordinates = [];
Set<Polyline> _polylines = {};
Set<Marker> _Markers = {};
Set<Circle> _Circles = {};
DirectionDetail tripDirectionDetails;
AnimationController controller;
@override
void initState() {
controller = AnimationController(
vsync: this,
duration: const Duration(seconds: 5),
);
controller.repeat(reverse: true);
super.initState();
print('int the init');
HelperMethods.getCurrentUserInfo();
}
@override
void dispose() {
controller.dispose();
super.dispose();
}
void setupPositionLocator() async {
Position position = await Geolocator.getCurrentPosition(
desiredAccuracy: LocationAccuracy.high);
currentPosition = position;
LatLng pos = LatLng(position.latitude, position.longitude);
CameraPosition cp = new CameraPosition(target: pos, zoom: 14);
mapController.animateCamera(CameraUpdate.newCameraPosition(cp));
String address =
await HelperMethods.findCordinateAddress(position, context);
}
Future<void> getDirection() async {
// logic here is not important
}
void showDetailSheet() async {
// logic here is not important
}
void createRideRequest() {
// logic here is not important
}
void backToSeach() {
// logic here is not important
}
void cancelRideRequest() {
logic here is not important
}
@override
Widget build(BuildContext context) {
return Scaffold(
key: scaffoldKey,
drawer: Container(
width: 250,
color: Colors.white,
child: Drawer(
child: ListView(
padding: EdgeInsets.all(0),
children: <Widget>[
Container(
color: Colors.white,
height: 160,
child: DrawerHeader(
decoration: BoxDecoration(color: Colors.white),
child: Row(
children: <Widget>[
Image.asset(
'images/user_icon.png',
height: 60,
width: 60,
),
SizedBox(
width: 15,
),
Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
currentUserInfo.fullName,
style: TextStyle(
fontSize: 20, fontFamily: 'Brand-Bold'),
),
SizedBox(
height: 5,
),
Text('View Profile')
],
)
],
),
)),
SizedBox(
height: 10,
),
DrawerListItem(
icon: Icons.card_giftcard,
title: currentUserInfo.phone,
),
DrawerListItem(
icon: Icons.card_giftcard,
title: 'Free Rides',
),
DrawerListItem(
icon: Icons.credit_card,
title: 'Payments',
),
DrawerListItem(icon: Icons.history, title: 'Ride History'),
DrawerListItem(
icon: Icons.contact_support,
title: 'Support',
),
DrawerListItem(
icon: Icons.info,
title: 'About',
)
],
),
),
),
body: Stack(
children: <Widget>[
GoogleMap(
padding: EdgeInsets.only(bottom: mapPaddingBottom),
mapType: MapType.normal,
myLocationButtonEnabled: true,
initialCameraPosition: googlePlex,
myLocationEnabled: true,
zoomGesturesEnabled: true,
zoomControlsEnabled: true,
markers: _Markers,
circles: _Circles,
polylines: _polylines,
onMapCreated: (GoogleMapController controller) async {
_controller.complete(controller);
mapController = controller;
setupPositionLocator();
},
),
/// Open Drawer Button
Positioned(
top: 60,
left: 20,
child: GestureDetector(
onTap: () {
scaffoldKey.currentState.openDrawer();
},
child: Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(20),
boxShadow: [
BoxShadow(
color: Colors.black26,
blurRadius: 5.0,
spreadRadius: 0.5,
offset: Offset(0.7, 0.7))
]),
child: CircleAvatar(
backgroundColor: Colors.white,
radius: 20,
child: Icon(Icons.menu),
),
),
),
),
/// Menu Sheet
Positioned(
left: 0,
right: 0,
bottom: 0,
child: AnimatedSize(
vsync: this,
duration: new Duration(milliseconds: 150),
child: Container(
height: searchSheetHeight,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.only(
topRight: Radius.circular(15),
topLeft: Radius.circular(15)),
boxShadow: [
BoxShadow(
color: Colors.black26,
blurRadius: 15.0,
spreadRadius: 0.5,
offset: Offset(0.7, 0.7))
]),
child: Padding(
padding: EdgeInsets.symmetric(horizontal: 24, vertical: 18),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
SizedBox(
height: 5,
),
Text(
'Nice to meet you!',
style: TextStyle(fontSize: 10),
),
Text(
'Where are you going?',
style:
TextStyle(fontSize: 18, fontFamily: 'Brand-Bold'),
),
SizedBox(
height: 20,
),
GestureDetector(
onTap: () async {
var response = await Navigator.push(
context,
MaterialPageRoute(
builder: (context) => SearchPage()));
if (response == 'getDirection') {
await getDirection();
showDetailSheet();
}
},
child: Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(10.0),
boxShadow: [
BoxShadow(
color: Colors.black26,
blurRadius: 5.0,
spreadRadius: 0.2,
offset: Offset(0.4, 0.4))
]),
child: Padding(
padding: EdgeInsets.all(12.0),
child: Row(
children: <Widget>[
Icon(
Icons.search,
color: Colors.blueAccent,
),
SizedBox(
width: 10,
),
Text('Search Destination')
],
),
),
),
),
SizedBox(
height: 10,
),
Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(10.0),
boxShadow: [
BoxShadow(
color: Colors.black26,
blurRadius: 5.0,
spreadRadius: 0.2,
offset: Offset(0.4, 0.4))
]),
child: Padding(
padding: EdgeInsets.all(12.0),
child: Row(
children: <Widget>[
Icon(
Icons.home,
color: BrandColors.colorDimText,
),
SizedBox(
width: 10,
),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text((Provider.of<AppData>(context)
.pickupAddress !=
null)
? Provider.of<AppData>(context)
.pickupAddress
.placeName
: 'Add Home'),
SizedBox(
height: 3,
),
Text(
'Your residential address',
style: TextStyle(
fontSize: 11,
color: BrandColors.colorDimText),
)
],
)
],
),
),
),
SizedBox(
height: 10,
),
Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(10.0),
boxShadow: [
BoxShadow(
color: Colors.black26,
blurRadius: 5.0,
spreadRadius: 0.2,
offset: Offset(0.4, 0.4))
]),
child: Padding(
padding: EdgeInsets.all(12.0),
child: Row(
children: <Widget>[
Icon(
Icons.work,
color: BrandColors.colorDimText,
),
SizedBox(
width: 10,
),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text('Add Work'),
SizedBox(
height: 3,
),
Text(
'Your office address',
style: TextStyle(
fontSize: 11,
color: BrandColors.colorDimText),
)
],
)
],
),
),
)
],
),
),
),
),
),
/// RideDetail Sheet
Positioned(
left: 0,
right: 0,
bottom: 0,
child: AnimatedSize(
vsync: this,
duration: new Duration(milliseconds: 150),
child: Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(15),
topRight: Radius.circular(15)),
boxShadow: [
BoxShadow(
color: Colors.black26,
blurRadius: 15.0,
spreadRadius: 0.5,
offset: Offset(0.7, 0.7))
]),
height: rideDetailSheetHeight,
child: Column(
children: <Widget>[
Container(
child: Padding(
padding: EdgeInsets.symmetric(horizontal: 16),
child: Row(
children: <Widget>[
Image.asset(
'images/taxi.png',
height: 70,
width: 70,
),
SizedBox(
width: 16,
),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
'Taxi',
style: TextStyle(
fontSize: 18, fontFamily: 'Brand-Bold'),
),
Text(
(tripDirectionDetails != null)
? tripDirectionDetails.distanceText
: '',
style: TextStyle(
fontSize: 16,
color: BrandColors.colorTextLight),
)
],
),
Expanded(child: Container()),
Text(
(tripDirectionDetails != null)
? '\$${HelperMethods.estimateFares(tripDirectionDetails)}'
: '',
style: TextStyle(
fontSize: 18, fontFamily: 'Brand-Bold'),
)
],
),
),
),
SizedBox(
height: 22,
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0),
child: Row(
children: <Widget>[
Icon(
Icons.monetization_on,
size: 18,
color: BrandColors.colorTextLight,
),
SizedBox(
width: 16,
),
Text('Cash'),
SizedBox(
width: 5,
),
Icon(
Icons.keyboard_arrow_down,
color: BrandColors.colorTextLight,
size: 16,
)
],
),
),
SizedBox(
height: 22,
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 12.0),
child: TaxiButton(
title: 'REQUEST CAB',
color: BrandColors.colorAccent,
onPressed: () => createRideRequest()),
),
SizedBox(
height: 22,
),
CustomedBackButton(
onTap: () => backToSeach(), text: 'back to search')
],
),
),
)),
/// Request Cab Sheet
Positioned(
left: 0,
right: 0,
bottom: 0,
child: AnimatedSize(
vsync: this,
duration: new Duration(milliseconds: 150),
child: Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(15),
topRight: Radius.circular(15)),
boxShadow: [
BoxShadow(
color: Colors.black26,
blurRadius: 15.0,
spreadRadius: 0.5,
offset: Offset(0.7, 0.7))
]),
height: requestRideSheetHeight,
child: Container(
child: Padding(
padding: const EdgeInsets.all(12.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Padding(
padding: const EdgeInsets.symmetric(
horizontal: 12, vertical: 8),
child: LinearProgressIndicator(
value: controller.value,
valueColor: new AlwaysStoppedAnimation<Color>(
BrandColors.colorTextSemiLight),
backgroundColor: Colors.black12,
),
),
Text(
'Requesting a Ride ...',
style: TextStyle(
fontSize: 22,
fontFamily: 'Brand-Bold',
color: BrandColors.colorTextLight),
),
SizedBox(
height: 22,
),
CustomedBackButton(
onTap: () => cancelRideRequest(),
text: 'cancel ride')
],
),
),
),
)))
],
),
);
}
}
之后,控制台看起来像这样:
请帮我处理一下,非常感谢,祝你愉快
更新:Flutter版本
1条答案
按热度按时间lfapxunr1#
这是一个open issue,没有已知的解决方法来禁用来自谷歌Map的日志。这些是可以用
I/
前缀标识的信息日志。隐藏日志的解决方法是按照here步骤过滤所有I/BufferQueueProducer
日志。