I have a map in the form of an Image which is scrollable horizontally, and custom Painter which seems to only take the space of the screen currently being displayed and scrolls across the image instead of staying in it's place.
As it can be seen the image stayed in its place and was scrolled over, while the customPainter
(reddish ball) was dragged. I tried using a singleScrollChildView
but it doesn't work because I have the size of the CustomPainter
as infinite
which doesn't allow it. The reason I want it to be scrollable is that I want to use the it as a way of drawing on the map.
A sample code of the last attempt can be seen below:
@override
Widget build(BuildContext context) {
return Scaffold(
resizeToAvoidBottomInset:
false, //helps change the gadegst to fit in case other widgets appear
backgroundColor: Colors.white,
body: FutureBuilder(
future: _mainService.getOrCreateUser(theemail: userEmail),
builder: (context, snapshot) {
switch (snapshot.connectionState) {
case ConnectionState.done:
return Padding(
padding: const EdgeInsets.only(top: 8.0),
child: Stack(
children: <Widget>[
SingleChildScrollView(
scrollDirection: Axis.horizontal,
//scroll widget
child: Padding(
padding: const EdgeInsets.only(top: 40.0),
child: SizedBox(
height: MediaQuery.of(context).size.height * 1,
child: Image.asset(
//loads an image on to the app
'images/map.png',
fit: BoxFit.cover,
),
),
),
),
SingleChildScrollView(
scrollDirection: Axis.vertical,
child: SizedBox(
width: MediaQuery.of(context).size.width * 0.95,
height: MediaQuery.of(context).size.height * 0.14,
child: buildFloatingSearchBar(context),
),
),
IgnorePointer(
ignoring: true,
child: SizedBox(
height: MediaQuery.of(context).size.height * 1,
child: CustomPaint(
willChange: true,
size: Size.infinite,
//MediaQuery.of(context).size,
painter: LocationCircles(),
),
),
),
],
),
);
default:
return spinkit2;
}
},
),