-
Notifications
You must be signed in to change notification settings - Fork 26.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Document scale parameter for Image and RawImage #148623
Comments
@mmcdon20 |
@darshankawar I have already provided runnable code samples. See the section titled "Code Sample". Each of those is a complete program. |
Hi, I tried to reproduce your issue and I wasn't able to do so with your sample code, the images were the same size no matter what scale. However I did manage to reproduce it with the following example where the issue can easily be seen, maybe that helps :) import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({super.key});
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
double _scale = .5;
void _changeScale() {
setState(() {
_scale = _scale == 0.5 ? 2 : .5;
});
}
static const url =
'https://upload.wikimedia.org/wikipedia/en/b/b7/Google1998.png';
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: Scaffold(
body: SingleChildScrollView(
child: Column(
children: <Widget>[
Text(_scale.toString()),
Image.network(url, scale: _scale),
const SizedBox(
height: 100,
),
Transform.scale(scale: _scale, child: Image.network(url))
],
),
),
floatingActionButton: FloatingActionButton(
onPressed: _changeScale,
child: const Icon(Icons.edit),
),
),
);
}
}
|
Thanks for the code @christophsj That's what I was looking for, runnable code. stable, master flutter doctor -v
|
This is working as intended and documented on other parts of the API:
We should also include this note in the other Image constructors (and RawImage). |
Steps to reproduce
If you set the
scale
parameter on anImage
orRawImage
to2
the image gets smaller, if you set it to.5
the image gets larger. This is the opposite effect that I was expecting, it is also opposite toTransform.scale()
which works the way I expect.Expected results
I expected the
scale
parameter inImage
andRawImage
to have the same effect as thescale
parameter inTransform.scale()
.Actual results
The
scale
parameter inImage
andRawImage
have the opposite effect as thescale
parameter inTransform.scale()
.Code sample
EDIT: Combined code into a single demo
Screenshots or Video
No response
Logs
No response
Flutter Doctor output
Doctor output
The text was updated successfully, but these errors were encountered: