Flutter Animated Container, Elevated Button, SizeBox Widget



In this tutorial, you can easily learn about Flutter Animated Container Widget, Elevated Button, and SizeBox Widget.

Elevated Button Widget Example:

 ElevatedButton(
              onPressed: () {
                setState(() {
                  clicked =
                      !clicked; // when user clicked here bool value return false ...
                });
              },
              child: const Text("Click Me")),

When you need free space you can use the height or width property in SizeBox Widget.

SizeBox Widget Example:

 SizedBox(
            height: 10,
          ),

Flutter Animated Container Widget

Flutter Animated Container

Flutter Animated Container widget Source Code:

import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: const MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});
  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  // here already create bool value ... ok
  bool clicked = true;
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: Column(mainAxisAlignment: MainAxisAlignment.center, children: [
          //Hey welcome to my channel ...
          // here already create a scaffold widget .... also center and column ..
          // column widget main Axisalignment CENTER ... ok now start our new topic....
          // Now we create a elevant button then container then Animated container let's started......
          ElevatedButton(
              onPressed: () {
                setState(() {
                  clicked =
                      !clicked; // when user clicked here bool value return false ...
                });
              },
              child: const Text("Click Me")),
          // here need some space ... now we use sizebox widget ...
          SizedBox(
            height: 10,
          ),
          AnimatedContainer(
            // now when user click clickme button then change Container value ... height, width and color ...
            height: ((clicked == false) ? 400 : 200),
            width: ((clicked == false) ? 200 : 400),
            // already workign button next change also color ....
            color: ((clicked == false) ? Colors.amber : Colors.green),
            // it is tool fast if we add animation here that way maybe more amazing ......so
            // animated it .... ok
            duration: const Duration(seconds: 2),
            // you can also add here BOX Decoration widget then watch our BOX decoration widget tutorial ...
          // IF you link this tutorial please SUBSCRIBE .... Thank YOu........Code LInk in the description ...
          )
        ]),
      ),
    );
  }
}
  • How to Conduct YouTube Keyword Research Easily?
    Introduction YouTube is the second largest search engine in the world, making it a valuable platform for content creators and businesses alike. To maximize your visibility and reach on YouTube, it is crucial to conduct proper keyword research. By identifying the right keywords, you can optimize your videos for search and increase your chances of …

    Read more …

  • How to upgrade the Dart SDK version in flutter
    If you’re a Flutter developer, you know how important it is to stay up-to-date with the latest version of the Dart SDK. Upgrading the Dart SDK ensures that you have access to the latest features, bug fixes, and performance improvements. Step 1: Check Your Current Dart SDK Version Before you begin the upgrade process, it’s …

    Read more …

  • Why Do Advertisers Use Testimonials?
    In the ever-competitive business landscape, nurturing strong connections with your customers remains paramount for enhancing your credibility and positioning yourself as an industry authority. Establishing credibility is the bedrock upon which trust is built, ultimately translating into increased sales. To bolster your company’s credibility, integrating testimonial advertising into your marketing strategy is essential. So, what …

    Read more …

  • How To Earn $5 Fast Method!
    Looking to boost your income by $25 in less than an hour? This isn’t the start of a clichéd sales pitch; it’s about discovering several quick and simple ways to earn $5 online within minutes. For instance, you can make five bucks by completing tasks such as taking brief surveys, participating in short website usability …

    Read more …

  • What Does BMF Mean On TikTok? Latest Social Media Acronyms
    In the fast-paced world of social media, acronyms are the language of choice, enabling users to communicate swiftly without the need for lengthy phrases. While classics like LOL and OMG are still in use, the younger generation on TikTok has introduced a new acronym into the mix: BMF. So, what exactly does BMF mean, and …

    Read more …

Leave a Comment