I was making 2 scene with google Maps and drawing polyline on the map, the apps have no problem running and everything working fine, however on the debug there is this big stack of error in debug which I have no idea what it meant, can anyone tell me what is this ? It is kind of concerning for me
Below is the error on the debug,
════════ Exception caught by rendering library ═════════════════════════════════
Failed to rasterize a picture: unable to create render target at specified size.
The callstack when the image was created was:
#0 new Image._.<anonymous closure> (dart:ui/painting.dart:1670:32)
#1 new Image._ (dart:ui/painting.dart:1672:6)
#2 Scene.toImageSync (dart:ui/compositing.dart:34:18)
#3 OffsetLayer.toImageSync
layer.dart:1497
#4 _RenderSnapshotWidget._paintAndDetachToImage
snapshot_widget.dart:315
#5 _RenderSnapshotWidget.paint
snapshot_widget.dart:345
#6 RenderObject._paintWithContext
object.dart:2853
#7 PaintingContext.paintChild
object.dart:253
#8 RenderProxyBoxMixin.paint
#9 _ZoomEnterTransitionPainter.paint
page_transitions_theme.dart:866
#10 _RenderSnapshotWidget.paint
snapshot_widget.dart:335
#11 RenderObject._paintWithContext
object.dart:2853
#12 PaintingContext.paintChild
object.dart:253
#13 RenderProxyBoxMixin.paint
proxy_box.dart:144
#14 _ZoomExitTransitionPainter.paint
page_transitions_theme.dart:938
#15 _RenderSnapshotWidget.paint
snapshot_widget.dart:335
#16 RenderObject._paintWithContext
object.dart:2853
#17 PaintingContext.paintChild
object.dart:253
#18 RenderProxyBoxMixin.paint
proxy_box.dart:144
#19 _ZoomEnterTransitionPainter.paint
page_transitions_theme.dart:866
#20 _RenderSnapshotWidget.paint
snapshot_widget.dart:335
#21 RenderObject._paintWithContext
object.dart:2853
#22 PaintingContext.paintChild
object.dart:253
#23 RenderProxyBoxMixin.paint
proxy_box.dart:144
#24 RenderObject._paintWithContext
object.dart:2853
#25 PaintingContext._repaintCompositedChild
object.dart:169
#26 PaintingContext.repaintCompositedChild
object.dart:112
#27 PipelineOwner.flushPaint
object.dart:1137
#28 RendererBinding.drawFrame
binding.dart:518
#29 WidgetsBinding.drawFrame
binding.dart:865
#30 RendererBinding._handlePersistentFrameCallback
binding.dart:381
#31 SchedulerBinding._invokeFrameCallback
binding.dart:1289
#32 SchedulerBinding.handleDrawFrame
binding.dart:1218
#33 SchedulerBinding._handleDrawFrame
binding.dart:1076
#34 _invoke (dart:ui/hooks.dart:145:13)
#35 PlatformDispatcher._drawFrame (dart:ui/platform_dispatcher.dart:338:5)
#36 _drawFrame (dart:ui/hooks.dart:112:31)
The relevant error-causing widget was
MaterialApp
Edit: Here's the packages and code of the scene that triggered the error in the debug, for extra information, the error did not triggered consistently. I have no idea what trigered it, the materialapp exist on the home page. I use navigator function to switch scene
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter_polyline_points/flutter_polyline_points.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart';
import 'package:google_maps_in_flutter/location_service.dart';
import 'package:geolocator/geolocator.dart';
import 'package:label_marker/label_marker.dart';
StreamSubscription<Position>? userStreamlocation;
Position? streamResult;
class navScreen extends StatefulWidget
{
final String userOrigin;
final String userGoal;
navScreen({Key? mykey, required this.userOrigin, required this.userGoal});
@override
State<navScreen> createState ()=>nav_Screen(userOrigin: userOrigin, userGoal: userGoal);
}
class geostracking
{
Future<Position> determineLocation() async {
bool serviceEnabled;
LocationPermission permission;
serviceEnabled = await Geolocator.isLocationServiceEnabled();
if (!serviceEnabled) {
return Future.error('Location Service are Disabled');
}
permission = await Geolocator.checkPermission();
if (permission == LocationPermission.denied) {
permission = await Geolocator.requestPermission();
if (permission == LocationPermission.denied) {
return Future.error('Location Permission Denied');
}
}
if (permission == LocationPermission.deniedForever) {
return Future.error('Permission Denied Forever');
}
Position position = await Geolocator.getCurrentPosition();
print(position);
return position;
}
Position? listenToLocation()
{
Position? userposition;
final LocationSettings _locationSettings = LocationSettings(accuracy: LocationAccuracy.high,distanceFilter: 100);
userStreamlocation = Geolocator.getPositionStream(locationSettings: _locationSettings).listen(
(userposition) {
print(userposition == null ? 'Unknown' : '${userposition.latitude.toString()}, ${userposition.longitude.toString()}');
setState(){
streamResult=userposition;
}
});
return userposition;
}
}
class nav_Screen extends State<navScreen>
{
StreamSubscription<Position>? streamPosition;
@override
void dispose()
{
super.dispose();
streamPosition?.cancel();
}
late GoogleMapController mapController;
final String userOrigin;
final String userGoal;
nav_Screen({required this.userOrigin,required this.userGoal, });
final LatLng _kGooglePlex = LatLng(baseLat, baseLong);
Set<Marker> _markers = Set<Marker>();
Set<Polyline> _navPolylines =Set<Polyline>();
int _polylineIdCounter=0;
int markerNumber=1;
int _markerIDCounter = 1;
void _setMarker(String ID, var Place) {
String markerLabel;
if(markerNumber==1)
{
markerLabel = 'Start';
}
else
{
markerLabel = "Destination";
}
setState(() {
_markers.addLabelMarker(LabelMarker(
backgroundColor: Color.fromARGB(255, 0, 8, 255),
label: markerLabel,
markerId: MarkerId(ID),
position: LatLng(Place['geometry']['location']['lat'],
Place['geometry']['location']['lng']),)
);
_markerIDCounter++;
markerNumber++;
});
}
void _setPolylines(List<PointLatLng> points) {
final String _navPolylinesID = 'polyline_$_polylineIdCounter';
//print('Check : '+points.toString());
_navPolylines.add(
Polyline(
polylineId: PolylineId(_navPolylinesID),
width: 5,
color: Color.fromARGB(255, 56, 12, 255),
startCap: Cap.roundCap,
endCap: Cap.buttCap,
visible: true,
points: points
.map((point) => LatLng(point.latitude, point.longitude)).toList(),
)
);_polylineIdCounter++;
}
void _onMapCreated(GoogleMapController controller) async {
mapController = controller;
var direction = await LocationService().getDirectionNoWP(userOrigin, userGoal);
print(_polylineIdCounter);
_setPolylines(direction['polyline_decoded']);
String OplaceID = await LocationService().getPlaceID(userOrigin);
var Oplace = await LocationService().getPlace(userOrigin);
_setMarker(OplaceID, Oplace);
String DplaceID = await LocationService().getPlaceID(userGoal);
var Dplace = await LocationService().getPlace(userGoal);
_setMarker(DplaceID, Dplace);
setState(() {});
}
@override
Widget build(BuildContext context)
{
return Scaffold(
appBar: AppBar(title: Text('Test')),
body: Column
(children: [
Expanded(
child:
GoogleMap(
mapType: MapType.normal,
initialCameraPosition: CameraPosition(target: _kGooglePlex,zoom: 10),
markers: _markers,
polylines: _navPolylines,
onMapCreated: _onMapCreated,
)
),
]),
floatingActionButton: Container(alignment: Alignment.bottomCenter,
child: FloatingActionButton(onPressed: ()async{
geostracking().listenToLocation();
},
child: Icon(Icons.navigation),),
),
);
}
}
Here's a snip of the main page code and it's packages
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart';
import 'package:google_maps_in_flutter/current_location.dart';
import 'package:google_maps_in_flutter/customer_profile.dart';
import 'package:google_maps_in_flutter/location_service.dart';
import 'package:flutter_polyline_points/flutter_polyline_points.dart';
import 'package:geolocator/geolocator.dart';
import 'package:label_marker/label_marker.dart';
void main() => runApp(MyApp());
StreamSubscription<Position>? userStreamlocation;
Position? streamResult;
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Google Map Test',
home: GMap(),
//routes: ,
);
}
}
class GMap extends StatefulWidget {
@override
State<GMap> createState() => GMapState();
}
class requestTemplateConverter{
class GMapState extends State<GMap> {