My problem should be simple, but i'm stuck: i need to display the image of a map with a marker over it (that's why i'm using a stack) and this image can be zoomed and panned. The only problem is, when i open the app the image is totally zoomed in, and i have to zoom out manually. I tried reading the docs and googling but i only found libraries which don't suit my needs or don't work as expected.
So, the question is simple: how can i see the fully zoomed out image from the beginning?
Here's the code.
return Container(
height: 350,
child: InteractiveViewer(
// TODO the image is automatically zoomed in!
minScale: .1,
maxScale: 1,
constrained: false,
child: Stack(children: [
Image.asset(itinerary.mapImage, fit: BoxFit.fitWidth),
icon(...),
])
)
)
You need to use a TransformationController to control InteractiveViewer. Here is the code:
TransformationController _controller;
@override
void initState() {
_controller = TransformationController();
_controller.value = Matrix4.identity() * 0.5;
super.initState();
}
@override
void dispose() {
_controller.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Container(
height: 350,
child: InteractiveViewer(
transformationController: _controller,
minScale: .1,
maxScale: 1,
onInteractionEnd: (s) {
print(_controller.value);
},
constrained: false,
child: Stack(
children: [
Image.asset(
"assets/Big.Buck.Bunny.-.Landscape.png",
fit: BoxFit.fitWidth,
),
],
),
),
),
);
}
Please note that you may need to adjust initial scale value(the one multiplying with Matrix4) to get your desired output.
Controller Advice bean not instantiated at proper order in Spring Boot 2.4
What should I enter to the connection string to connect my NodeJS application to a MongoDB server?
Unable to use Computed Property Values with Dots - Unable to Set as String - JS
I have used paypal-rest-sdk in my code the payment using paypal login working smoothly but now I want to pay using credit card and debit card without login to paypal
I'm trying to extract the string "No disponble" of this product, but im getting "none" or attribute text dont exists:
Hello I'm a beginner and I'm trying to manipulate the DOM by moving existing divsHow to make "for" loops on "
Have multiple datatables on same page, and every table have different API's for fetching the dataIf one of the API is not returning the data, both the tables data is not displaying in the UI and getting error in console like