SlideShare a Scribd company logo
1 of 13
DecoratedBoxTransition Widget – Definition,
Properties & How to Use It?
DecoratedBox Widget in Material Design paints a decoration onto
another box like a Container Widget that is a child of DecoratedBox.
Just like a DecoratedBox Widget Flutter has a new widget called
DecoratedBoxTransition Widget that is used for animating different
properties of its Decoration.
What is DecoratedBoxTransition Widget?
DecoratedBoxTransition Widget is an animated version of
a DecoratedBox that animates the different properties of
its Decoration.
Default Constructor for it will have a below code snippet.
In the above Constructor, all fields marked with required must not be
empty, so decoration and position must not be null in our constructor.
To implement the above widget or looking to build an outstanding
mobile business application, consult and hire best Flutter developers
from Flutter Agency.
const DecoratedBoxTransition(
{Key? key,
required Animation decoration,
DecorationPosition position = DecorationPosition.background,
required Widget child}
)
Properties:
Key: It controls how one widget replaces another widget in the tree.
A key is an identifier for Flutter Widgets, Elements,
and SemanticsNodes. A new widget will only be used to update an
existing element if its key is the same as the key of the current widget
associated with the element.
Animation<Decoration> Decoration: This attribute is used to
Animation of the decoration to paint. It can be created using a
DecorationTween interpolating typically between two BoxDecoration.
DecorationPosition Position: This attribute is used to define whether
to paint the box decoration behind or in front of the child.
Widget Child: The widget below this widget in the tree. It will have only
a one-child widget. To allocate multiple children users are requested to
use Row Widget or Column Widget and Wrap all the children into Row
Widget or Column Widget.
How to use DecoratedBoxTransition Widget?
The following code snippet tells us how to implement
DecoratedBoxTransition Widget in Flutter.
import 'package:flutter/material.dart';
class DecoratedBoxTransitionWidget extends StatefulWidget {
@override
_DecoratedBoxTransitionWidgetState createState() =>
_DecoratedBoxTransitionWidgetState();
}
class _DecoratedBoxTransitionWidgetState
extends State with TickerProviderStateMixin {
late AnimationController _controller;
bool _first = true;
final DecorationTween decorationTween = DecorationTween(
begin: BoxDecoration(
color: const Color(0xFFFFFFFF),
border: Border.all(
color: const Color(0xFF000000),
style: BorderStyle.solid,
width: 4.0,
),
borderRadius: BorderRadius.zero,
shape: BoxShape.rectangle,
boxShadow: const [
BoxShadow(
color: Color(0x66000000),
blurRadius: 10.0,
spreadRadius: 4.0,
)
],
),
end: BoxDecoration(
color: const Color(0xFF000000),
border: Border.all(
color: const Color(0xFF202020),
style: BorderStyle.solid,
width: 1.0,
),
borderRadius: BorderRadius.circular(10.0),
shape: BoxShape.rectangle,
// No shadow.
),
);
@override
initState() {
_controller = AnimationController(
vsync: this,
duration: const Duration(seconds: 1),
);
super.initState();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text("DecoratedBoxTransition Examole"),
),
body: Center(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
DecoratedBoxTransition(
position: DecorationPosition.background,
decoration: decorationTween.animate(_controller),
child: Container(
width: 200,
height: 200,
padding: const EdgeInsets.all(20),
child: const FlutterLogo(),
),
),
const SizedBox(
height: 20,
),
ElevatedButton(
onPressed: () {
if (_first) {
_controller.forward();
} else {
_controller.reverse();
}
_first = !_first;
},
child: const Text(
"Click Me!",
),
)
],
),
),
);
}
}
Output Result
Conclusion
In this article, we have been through What
is DecoratedBoxTransition Widget in Flutter along with how to
implement it in a Flutter.
Hire a Flutter app development company for end-to-end solution in
Flutter mobile app development. Moreover, we are constantly
uploading stuffs about Flutter widgets, Flutter updates, Solutions,
etc. So, keep vising our portal and keep learning!!!
Source: https://flutteragency.com/decoratedboxtransition-
widget/

More Related Content

Similar to DecoratedBoxTransition Widget – Definition, Properties & How to Use It.pptx

CSE-4078 - Lecture - Week 3sasdgaga.pptx
CSE-4078 - Lecture - Week 3sasdgaga.pptxCSE-4078 - Lecture - Week 3sasdgaga.pptx
CSE-4078 - Lecture - Week 3sasdgaga.pptx
zaidAhmad84
 
Windows Programming with AWT
Windows Programming with AWTWindows Programming with AWT
Windows Programming with AWT
backdoor
 
FlutterArchitecture FlutterArchitecture.ppt
FlutterArchitecture FlutterArchitecture.pptFlutterArchitecture FlutterArchitecture.ppt
FlutterArchitecture FlutterArchitecture.ppt
KevinNemo
 
On the tomcat drive in folder cosc210 you will find file named Paint.docx
On the tomcat drive in folder cosc210 you will find file named Paint.docxOn the tomcat drive in folder cosc210 you will find file named Paint.docx
On the tomcat drive in folder cosc210 you will find file named Paint.docx
dunhamadell
 
Implement a Javascript application that allows the user to enter strin.docx
Implement a Javascript application that allows the user to enter strin.docxImplement a Javascript application that allows the user to enter strin.docx
Implement a Javascript application that allows the user to enter strin.docx
mckerliejonelle
 

Similar to DecoratedBoxTransition Widget – Definition, Properties & How to Use It.pptx (20)

Abstract Window Toolkit
Abstract Window ToolkitAbstract Window Toolkit
Abstract Window Toolkit
 
Inside Flutter: Widgets, Elements, and RenderObjects
Inside Flutter: Widgets, Elements, and RenderObjectsInside Flutter: Widgets, Elements, and RenderObjects
Inside Flutter: Widgets, Elements, and RenderObjects
 
CSE-4078 - Lecture - Week 3sasdgaga.pptx
CSE-4078 - Lecture - Week 3sasdgaga.pptxCSE-4078 - Lecture - Week 3sasdgaga.pptx
CSE-4078 - Lecture - Week 3sasdgaga.pptx
 
flutteragency-com-handling-events-and-user-input-in-flutter-.pdf
flutteragency-com-handling-events-and-user-input-in-flutter-.pdfflutteragency-com-handling-events-and-user-input-in-flutter-.pdf
flutteragency-com-handling-events-and-user-input-in-flutter-.pdf
 
Mobile Application Development class 006
Mobile Application Development class 006Mobile Application Development class 006
Mobile Application Development class 006
 
Developer Student Clubs NUK - Flutter for Beginners
Developer Student Clubs NUK - Flutter for BeginnersDeveloper Student Clubs NUK - Flutter for Beginners
Developer Student Clubs NUK - Flutter for Beginners
 
Keynote + Next Gen UIs.pptx
Keynote + Next Gen UIs.pptxKeynote + Next Gen UIs.pptx
Keynote + Next Gen UIs.pptx
 
Flutter State Management Using GetX.pdf
Flutter State Management Using GetX.pdfFlutter State Management Using GetX.pdf
Flutter State Management Using GetX.pdf
 
Hats tutorial custom widget
Hats tutorial   custom widgetHats tutorial   custom widget
Hats tutorial custom widget
 
Advance JFACE
Advance JFACEAdvance JFACE
Advance JFACE
 
Mobile Application Development class 004
Mobile Application Development class 004Mobile Application Development class 004
Mobile Application Development class 004
 
Windows Programming with AWT
Windows Programming with AWTWindows Programming with AWT
Windows Programming with AWT
 
React new features and intro to Hooks
React new features and intro to HooksReact new features and intro to Hooks
React new features and intro to Hooks
 
GWT training session 2
GWT training session 2GWT training session 2
GWT training session 2
 
Statefull Widget.pdf
Statefull Widget.pdfStatefull Widget.pdf
Statefull Widget.pdf
 
FlutterArchitecture FlutterArchitecture.ppt
FlutterArchitecture FlutterArchitecture.pptFlutterArchitecture FlutterArchitecture.ppt
FlutterArchitecture FlutterArchitecture.ppt
 
On the tomcat drive in folder cosc210 you will find file named Paint.docx
On the tomcat drive in folder cosc210 you will find file named Paint.docxOn the tomcat drive in folder cosc210 you will find file named Paint.docx
On the tomcat drive in folder cosc210 you will find file named Paint.docx
 
Documentation For Tab Setup
Documentation For Tab SetupDocumentation For Tab Setup
Documentation For Tab Setup
 
Implement a Javascript application that allows the user to enter strin.docx
Implement a Javascript application that allows the user to enter strin.docxImplement a Javascript application that allows the user to enter strin.docx
Implement a Javascript application that allows the user to enter strin.docx
 
Supercharge Flutter declarative UI with code generation
Supercharge Flutter declarative UI with code generationSupercharge Flutter declarative UI with code generation
Supercharge Flutter declarative UI with code generation
 

More from Flutter Agency

More from Flutter Agency (20)

Key Steps To Follow For Google Play Store Closed Testing
Key Steps To Follow For Google Play Store Closed TestingKey Steps To Follow For Google Play Store Closed Testing
Key Steps To Follow For Google Play Store Closed Testing
 
Flutter for Web App Development: Exploring the Possibilities
Flutter for Web App Development: Exploring the PossibilitiesFlutter for Web App Development: Exploring the Possibilities
Flutter for Web App Development: Exploring the Possibilities
 
Use Of AI in Custom Application Development | Quick Guide
Use Of AI in Custom Application Development | Quick GuideUse Of AI in Custom Application Development | Quick Guide
Use Of AI in Custom Application Development | Quick Guide
 
Navigation in flutter – how to add stack, tab, and drawer navigators to your ...
Navigation in flutter – how to add stack, tab, and drawer navigators to your ...Navigation in flutter – how to add stack, tab, and drawer navigators to your ...
Navigation in flutter – how to add stack, tab, and drawer navigators to your ...
 
Use Firebase to Host Your Flutter App on the Web
Use Firebase to Host Your Flutter App on the WebUse Firebase to Host Your Flutter App on the Web
Use Firebase to Host Your Flutter App on the Web
 
Authentication Made Simple - Exploring QR Auto Login in Flutter.pdf
Authentication Made Simple - Exploring QR Auto Login in Flutter.pdfAuthentication Made Simple - Exploring QR Auto Login in Flutter.pdf
Authentication Made Simple - Exploring QR Auto Login in Flutter.pdf
 
User Enhancement With Animated Flutter Drawer
User Enhancement With Animated Flutter DrawerUser Enhancement With Animated Flutter Drawer
User Enhancement With Animated Flutter Drawer
 
Unit Testing in Flutter - From Workflow Essentials to Complex Scenarios
Unit Testing in Flutter - From Workflow Essentials to Complex ScenariosUnit Testing in Flutter - From Workflow Essentials to Complex Scenarios
Unit Testing in Flutter - From Workflow Essentials to Complex Scenarios
 
Form Validation in Flutter with Laravel Form Validation Syntax
Form Validation in Flutter with Laravel Form Validation SyntaxForm Validation in Flutter with Laravel Form Validation Syntax
Form Validation in Flutter with Laravel Form Validation Syntax
 
How to Create Custom Shaders in Flutter?
How to Create Custom Shaders in Flutter?How to Create Custom Shaders in Flutter?
How to Create Custom Shaders in Flutter?
 
Benefits Of Hiring Flutter App Developers For Success
Benefits Of Hiring Flutter App Developers For SuccessBenefits Of Hiring Flutter App Developers For Success
Benefits Of Hiring Flutter App Developers For Success
 
Guide to Fix Dropdown Button Not Switching Selected Item | Flutter
Guide to Fix Dropdown Button Not Switching Selected Item | FlutterGuide to Fix Dropdown Button Not Switching Selected Item | Flutter
Guide to Fix Dropdown Button Not Switching Selected Item | Flutter
 
12 Straightforward Steps to Build Your Video On-Demand App in 2024
12 Straightforward Steps to Build Your Video On-Demand App in 202412 Straightforward Steps to Build Your Video On-Demand App in 2024
12 Straightforward Steps to Build Your Video On-Demand App in 2024
 
Flutter's Advantages For Custom Application Development Services
Flutter's Advantages For Custom Application Development ServicesFlutter's Advantages For Custom Application Development Services
Flutter's Advantages For Custom Application Development Services
 
Hire Flutter Developers to Build Cross-Platform App Services - Stonesmentor
Hire Flutter Developers to Build Cross-Platform App Services - StonesmentorHire Flutter Developers to Build Cross-Platform App Services - Stonesmentor
Hire Flutter Developers to Build Cross-Platform App Services - Stonesmentor
 
A Guide For Recovering Your Failing App Project | Flutter Agency
A Guide For Recovering Your Failing App Project | Flutter AgencyA Guide For Recovering Your Failing App Project | Flutter Agency
A Guide For Recovering Your Failing App Project | Flutter Agency
 
Healthcare App-Development Company Fllutter Agency
Healthcare App-Development Company Fllutter AgencyHealthcare App-Development Company Fllutter Agency
Healthcare App-Development Company Fllutter Agency
 
Is Flutter Good for Web Development? | Flutter Agency
Is Flutter Good for Web Development? | Flutter AgencyIs Flutter Good for Web Development? | Flutter Agency
Is Flutter Good for Web Development? | Flutter Agency
 
Choosing App Development: Native, Hybrid, or Flutter Explained
Choosing App Development: Native, Hybrid, or Flutter ExplainedChoosing App Development: Native, Hybrid, or Flutter Explained
Choosing App Development: Native, Hybrid, or Flutter Explained
 
The Role of Digital Transformation in Healthcare - Flutter Agency.pdf
The Role of Digital Transformation in Healthcare - Flutter Agency.pdfThe Role of Digital Transformation in Healthcare - Flutter Agency.pdf
The Role of Digital Transformation in Healthcare - Flutter Agency.pdf
 

Recently uploaded

Jax, FL Admin Community Group 05.14.2024 Combined Deck
Jax, FL Admin Community Group 05.14.2024 Combined DeckJax, FL Admin Community Group 05.14.2024 Combined Deck
Jax, FL Admin Community Group 05.14.2024 Combined Deck
Marc Lester
 

Recently uploaded (20)

Salesforce Introduced Zero Copy Partner Network to Simplify the Process of In...
Salesforce Introduced Zero Copy Partner Network to Simplify the Process of In...Salesforce Introduced Zero Copy Partner Network to Simplify the Process of In...
Salesforce Introduced Zero Copy Partner Network to Simplify the Process of In...
 
What is a Recruitment Management Software?
What is a Recruitment Management Software?What is a Recruitment Management Software?
What is a Recruitment Management Software?
 
Optimizing Operations by Aligning Resources with Strategic Objectives Using O...
Optimizing Operations by Aligning Resources with Strategic Objectives Using O...Optimizing Operations by Aligning Resources with Strategic Objectives Using O...
Optimizing Operations by Aligning Resources with Strategic Objectives Using O...
 
BusinessGPT - Security and Governance for Generative AI
BusinessGPT  - Security and Governance for Generative AIBusinessGPT  - Security and Governance for Generative AI
BusinessGPT - Security and Governance for Generative AI
 
Anypoint Code Builder - Munich MuleSoft Meetup - 16th May 2024
Anypoint Code Builder - Munich MuleSoft Meetup - 16th May 2024Anypoint Code Builder - Munich MuleSoft Meetup - 16th May 2024
Anypoint Code Builder - Munich MuleSoft Meetup - 16th May 2024
 
^Clinic ^%[+27788225528*Abortion Pills For Sale In soweto
^Clinic ^%[+27788225528*Abortion Pills For Sale In soweto^Clinic ^%[+27788225528*Abortion Pills For Sale In soweto
^Clinic ^%[+27788225528*Abortion Pills For Sale In soweto
 
Community is Just as Important as Code by Andrea Goulet
Community is Just as Important as Code by Andrea GouletCommunity is Just as Important as Code by Andrea Goulet
Community is Just as Important as Code by Andrea Goulet
 
^Clinic ^%[+27788225528*Abortion Pills For Sale In birch acres
^Clinic ^%[+27788225528*Abortion Pills For Sale In birch acres^Clinic ^%[+27788225528*Abortion Pills For Sale In birch acres
^Clinic ^%[+27788225528*Abortion Pills For Sale In birch acres
 
From Theory to Practice: Utilizing SpiraPlan's REST API
From Theory to Practice: Utilizing SpiraPlan's REST APIFrom Theory to Practice: Utilizing SpiraPlan's REST API
From Theory to Practice: Utilizing SpiraPlan's REST API
 
Automate your OpenSIPS config tests - OpenSIPS Summit 2024
Automate your OpenSIPS config tests - OpenSIPS Summit 2024Automate your OpenSIPS config tests - OpenSIPS Summit 2024
Automate your OpenSIPS config tests - OpenSIPS Summit 2024
 
Abortion Clinic In Polokwane ](+27832195400*)[ 🏥 Safe Abortion Pills in Polok...
Abortion Clinic In Polokwane ](+27832195400*)[ 🏥 Safe Abortion Pills in Polok...Abortion Clinic In Polokwane ](+27832195400*)[ 🏥 Safe Abortion Pills in Polok...
Abortion Clinic In Polokwane ](+27832195400*)[ 🏥 Safe Abortion Pills in Polok...
 
Weeding your micro service landscape.pdf
Weeding your micro service landscape.pdfWeeding your micro service landscape.pdf
Weeding your micro service landscape.pdf
 
how-to-download-files-safely-from-the-internet.pdf
how-to-download-files-safely-from-the-internet.pdfhow-to-download-files-safely-from-the-internet.pdf
how-to-download-files-safely-from-the-internet.pdf
 
Abortion Clinic In Springs ](+27832195400*)[ 🏥 Safe Abortion Pills in Springs...
Abortion Clinic In Springs ](+27832195400*)[ 🏥 Safe Abortion Pills in Springs...Abortion Clinic In Springs ](+27832195400*)[ 🏥 Safe Abortion Pills in Springs...
Abortion Clinic In Springs ](+27832195400*)[ 🏥 Safe Abortion Pills in Springs...
 
Effective Strategies for Wix's Scaling challenges - GeeCon
Effective Strategies for Wix's Scaling challenges - GeeConEffective Strategies for Wix's Scaling challenges - GeeCon
Effective Strategies for Wix's Scaling challenges - GeeCon
 
Jax, FL Admin Community Group 05.14.2024 Combined Deck
Jax, FL Admin Community Group 05.14.2024 Combined DeckJax, FL Admin Community Group 05.14.2024 Combined Deck
Jax, FL Admin Community Group 05.14.2024 Combined Deck
 
Modern binary build systems - PyCon 2024
Modern binary build systems - PyCon 2024Modern binary build systems - PyCon 2024
Modern binary build systems - PyCon 2024
 
The Evolution of Web App Testing_ An Ultimate Guide to Future Trends.pdf
The Evolution of Web App Testing_ An Ultimate Guide to Future Trends.pdfThe Evolution of Web App Testing_ An Ultimate Guide to Future Trends.pdf
The Evolution of Web App Testing_ An Ultimate Guide to Future Trends.pdf
 
Workshop: Enabling GenAI Breakthroughs with Knowledge Graphs - GraphSummit Milan
Workshop: Enabling GenAI Breakthroughs with Knowledge Graphs - GraphSummit MilanWorkshop: Enabling GenAI Breakthroughs with Knowledge Graphs - GraphSummit Milan
Workshop: Enabling GenAI Breakthroughs with Knowledge Graphs - GraphSummit Milan
 
Spring into AI presented by Dan Vega 5/14
Spring into AI presented by Dan Vega 5/14Spring into AI presented by Dan Vega 5/14
Spring into AI presented by Dan Vega 5/14
 

DecoratedBoxTransition Widget – Definition, Properties & How to Use It.pptx

  • 1.
  • 2. DecoratedBoxTransition Widget – Definition, Properties & How to Use It? DecoratedBox Widget in Material Design paints a decoration onto another box like a Container Widget that is a child of DecoratedBox. Just like a DecoratedBox Widget Flutter has a new widget called DecoratedBoxTransition Widget that is used for animating different properties of its Decoration.
  • 3. What is DecoratedBoxTransition Widget? DecoratedBoxTransition Widget is an animated version of a DecoratedBox that animates the different properties of its Decoration. Default Constructor for it will have a below code snippet.
  • 4. In the above Constructor, all fields marked with required must not be empty, so decoration and position must not be null in our constructor. To implement the above widget or looking to build an outstanding mobile business application, consult and hire best Flutter developers from Flutter Agency. const DecoratedBoxTransition( {Key? key, required Animation decoration, DecorationPosition position = DecorationPosition.background, required Widget child} )
  • 5. Properties: Key: It controls how one widget replaces another widget in the tree. A key is an identifier for Flutter Widgets, Elements, and SemanticsNodes. A new widget will only be used to update an existing element if its key is the same as the key of the current widget associated with the element. Animation<Decoration> Decoration: This attribute is used to Animation of the decoration to paint. It can be created using a DecorationTween interpolating typically between two BoxDecoration.
  • 6. DecorationPosition Position: This attribute is used to define whether to paint the box decoration behind or in front of the child. Widget Child: The widget below this widget in the tree. It will have only a one-child widget. To allocate multiple children users are requested to use Row Widget or Column Widget and Wrap all the children into Row Widget or Column Widget.
  • 7. How to use DecoratedBoxTransition Widget? The following code snippet tells us how to implement DecoratedBoxTransition Widget in Flutter. import 'package:flutter/material.dart'; class DecoratedBoxTransitionWidget extends StatefulWidget { @override _DecoratedBoxTransitionWidgetState createState() => _DecoratedBoxTransitionWidgetState(); } class _DecoratedBoxTransitionWidgetState extends State with TickerProviderStateMixin {
  • 8. late AnimationController _controller; bool _first = true; final DecorationTween decorationTween = DecorationTween( begin: BoxDecoration( color: const Color(0xFFFFFFFF), border: Border.all( color: const Color(0xFF000000), style: BorderStyle.solid, width: 4.0, ), borderRadius: BorderRadius.zero, shape: BoxShape.rectangle, boxShadow: const [ BoxShadow( color: Color(0x66000000), blurRadius: 10.0, spreadRadius: 4.0, ) ], ),
  • 9. end: BoxDecoration( color: const Color(0xFF000000), border: Border.all( color: const Color(0xFF202020), style: BorderStyle.solid, width: 1.0, ), borderRadius: BorderRadius.circular(10.0), shape: BoxShape.rectangle, // No shadow. ), ); @override initState() { _controller = AnimationController( vsync: this, duration: const Duration(seconds: 1), ); super.initState(); }
  • 10. @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: const Text("DecoratedBoxTransition Examole"), ), body: Center( child: Column( mainAxisSize: MainAxisSize.min, children: [ DecoratedBoxTransition( position: DecorationPosition.background, decoration: decorationTween.animate(_controller), child: Container( width: 200, height: 200, padding: const EdgeInsets.all(20), child: const FlutterLogo(), ), ),
  • 11. const SizedBox( height: 20, ), ElevatedButton( onPressed: () { if (_first) { _controller.forward(); } else { _controller.reverse(); } _first = !_first; }, child: const Text( "Click Me!", ), ) ], ), ), ); } }
  • 13. Conclusion In this article, we have been through What is DecoratedBoxTransition Widget in Flutter along with how to implement it in a Flutter. Hire a Flutter app development company for end-to-end solution in Flutter mobile app development. Moreover, we are constantly uploading stuffs about Flutter widgets, Flutter updates, Solutions, etc. So, keep vising our portal and keep learning!!! Source: https://flutteragency.com/decoratedboxtransition- widget/