android – The best way to Resize Picture in Flutter?

Only a small tip: I might recommend together with the code snippet to indicate precisely the way you attempt to re-size, so others can clarify why the error occurs within the first place and make it easier to do it the best way you already began doing 🙏
There are a number of methods to do it in Flutter and it isn’t tremendous clear which precisely you may want (static sizes, dynamic becoming, resizing that means compression or and so forth). I assume we discuss picture resizing to the static measurement for its additional rendering.
Certainly one of them is solely utilizing a ConstrainedBox
as a mum or dad widget on the Picture
.
For instance ⬇️, simply use the trail to your individual asset as an alternative of belongings/vancouver.jpg
after which tweak maxHeight
and maxWidth
if the sizes are static.
import 'bundle:flutter/materials.dart';
void important() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({tremendous.key});
// This widget is the foundation of your software.
@override
Widget construct(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colours.deepPurple),
useMaterial3: true,
),
house: const MyHomePage(),
);
}
}
class MyHomePage extends StatelessWidget {
const MyHomePage({tremendous.key});
@override
Widget construct(BuildContext context) {
return Scaffold(
physique: Middle(
youngster: ConstrainedBox(
constraints: const BoxConstraints(maxHeight: 200.0, maxWidth: 200.0),
youngster: Picture.asset("belongings/vancouver.jpg"),
),
),
);
}
}
Hope it really works for you!
Credit: www.ismmailgsm.com