Bacancy Technology
Bacancy Technology represents the connected world, offering innovative and customer-centric information technology experiences, enabling Enterprises, Associates and the Society to Rise™.
12+
Countries where we have happy customers
1050+
Agile enabled employees
06
World wide offices
12+
Years of Experience
05
Agile Coaches
14
Certified Scrum Masters
1000+
Clients projects
1458
Happy customers
Artificial Intelligence
Machine Learning
Salesforce
Microsoft
SAP
May 31, 2023
To crop the image, we will use two widgets,
first, we will use AspectRatio Widget.
Now, after we have defined the desired size, we can use the “decoration” property of the container and give it a BoxDecoration.
Now apply your image to “image”
Note – you can use fit as per your need,
Here i don’t want to compromise with the image width so i have used “fit : BoxFit.fitWidth”
image: DecorationImage( fit: BoxFit.fitWidth, alignment: FractionalOffset.topCenter, image: NetworkImage('https://pixabay.com/photos/crimson-rosella-parrot-bird-animal-7947000/'), )
So our complete code with aspect ratio would be,
AspectRatio( aspectRatio: 487 / 451, child: Container( decoration: const BoxDecoration( image: DecorationImage( fit: BoxFit.fitWidth, alignment: FractionalOffset.topCenter, image: NetworkImage('https://pixabay.com/photos/crimson-rosella-parrot-bird-animal-7947000/'), ) ), ), ),