Resize An Image
Step 1:
The first step is to create a new folder and name it "assets" at the root of the Flutter project directory as shown in the image. Now add the image inside the newly created assets directory.
Step 2:
The image added inside the assets/images folder won't be accessible until we list it in the assets section of our pubspec.yaml file. In step 2, list the image file under the assets section of pubspec.yaml as shown below
flutter:
assets:
- assets/images/
import 'package:flutter/material.dart'; void main() { runApp(new MyApp()); } class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return new MaterialApp( debugShowCheckedModeBanner: false, title: 'Transform', home: new MyHomePage(), ); } } class MyHomePage extends StatefulWidget { _MyHomePageState createState() => _MyHomePageState(); } class _MyHomePageState extends State<MyHomePage> with SingleTickerProviderStateMixin { Animation<double> _animation; AnimationController _animationController; @override void initState() { super.initState(); _animationController = AnimationController( vsync: this, duration: Duration( seconds: 2)); _animation = Tween<double>(begin: 1.0, end: 3.5).animate( _animationController); _animation.addListener(() { setState(() {}); }); _animation.addStatusListener((status) { if (status == AnimationStatus.completed) { _animationController .reverse(); } }); } @override Widget build(BuildContext context) { return Scaffold( backgroundColor: Colors.black, appBar: AppBar( backgroundColor: Colors.red[800], centerTitle: true, title: Text('Resize Image'), ), body: Center( child: GestureDetector( onTap: () { _animationController .forward(); }, child: Image.asset( 'assets/images/img2.jpg', height: 250.0 * _animation.value, width: 150.0 * _animation.value, )), ), ); } }