(PRAC-7)Designing the mobile app to implement the animation.

#Practical 7.dart

import 'package:flutter/material.dart';

import 'package:myapp/animedemo.dart';


void main()

{

  runApp(

    MaterialApp(

      home: Animedemo(),

    ),

  );

}

#animedemo.dart

import 'package:flutter/material.dart';

class Animedemo extends StatefulWidget {

  State<Animedemo> createState(){

    return _AnimedemoState();

  }

}


class _AnimedemoState extends State<Animedemo>{

  double _margin = 0;

  double _width = 200;

  Color _color = Colors.greenAccent;

  @override

  Widget build(context){

    return Scaffold(

      body: Center(

        child: AnimatedContainer(

          margin: EdgeInsets.all(_margin),

          duration: Duration(seconds: 1),

          width: _width,

          color: _color,

          child: Column(

            crossAxisAlignment: CrossAxisAlignment.center,

            children: [

              ElevatedButton(

                onPressed: () {

                setState(() {

                  _margin = 50;

                });

              },

               child: Text ('Animate margin'),

               ),

               SizedBox(

                height: 15,

               ),

            ElevatedButton(

              onPressed: (){

              setState(

                () {

                _color = Colors.yellowAccent;

              },

              );

            }, child: Text('Animate Color'),

            ),

            SizedBox(

              height: 15,

            ),

            ElevatedButton(

              onPressed: (){

              setState(

                () {

                _width = 400;

              },

              );

            }, child: Text('Animate Width'),

            ),

            ],

          )

        )

         )

    );

  }

}

Comments

Popular posts from this blog

python(BI)

(PP-7)Create a class called Numbers, which has a single class attribute called MULTIPLIER, and a constructor which takes the parameters x and y (these should all be numbers). i. Write a method called add which returns the sum of the attributes x and y. ii. Write a class method called multiply, which takes a single number parameter a and returns the product of a and MULTIPLIER. iii. Write a static method called subtract, which takes two number parameters, b and c, and returns b - c. iv. Write a method called value which returns a tuple containing the values of x and y. Make this method into a property, and write a setter and a deleter for manipulating the values of x and y.