(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)

Prac_8(AMP)

LSA10