If you want to decorate your flutter app you need a box decoration widget.
Box Decoration Widget using you can easily create box and box borders.
Container(
height: 300,
width: 400,
decoration: BoxDecoration(
border: Border.all(width: 15, color: Colors.green),
),
child: Center(
child: Text(
"BoxDecoration Example",
style: TextStyle(fontWeight: FontWeight.bold),
)),
)
Box decoration widget using create box border and border-radius.
Container(
height: 300,
width: 400,
decoration: BoxDecoration(
border: Border.all(width: 15, color: Colors.green),
borderRadius: BorderRadius.circular(50),
),
child: Center(
child: Text(
"BoxDecoration Example",
style: TextStyle(fontWeight: FontWeight.bold),
)),
)
Box Decoration Widget add Box Shadow:
Container(
height: 300,
width: 400,
decoration: BoxDecoration(
border: Border.all(width: 15, color: Colors.green),
borderRadius: BorderRadius.circular(50),
boxShadow: [
BoxShadow(color: Colors.grey, offset: Offset(12.0, 12.0))
],
),
child: Center(
child: Text(
"BoxDecoration Example",
style: TextStyle(fontWeight: FontWeight.bold),
)),
)
Box Decoration widget add gradient:
Container(
height: 300,
width: 400,
decoration: BoxDecoration(
border: Border.all(width: 15, color: Colors.green),
borderRadius: BorderRadius.circular(50),
boxShadow: [
BoxShadow(color: Colors.grey, offset: Offset(12.0, 12.0))
],
gradient: LinearGradient(
colors: [Colors.amber, Colors.green],
),
),
child: Center(
child: Text(
"BoxDecoration Example",
style: TextStyle(fontWeight: FontWeight.bold),
)),
)
Box Decoration widget add an image:
Container(
height: 300,
width: 400,
decoration: BoxDecoration(
border: Border.all(width: 15, color: Colors.green),
borderRadius: BorderRadius.circular(50),
boxShadow: [
BoxShadow(color: Colors.grey, offset: Offset(12.0, 12.0))
],
image: DecorationImage(
image: NetworkImage(
"https://cdn.pixabay.com/photo/2022/07/13/19/19/blue-eryngo-7319904__340.jpg"),
fit: BoxFit.cover)),
child: Center(
child: Text(
"BoxDecoration Example",
style: TextStyle(fontWeight: FontWeight.bold),
)),
)
Flutter Box Decoration Widget Advanced Tutorial
Full project 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> {
dynamic drodownvalues = "Menu one";
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Column(mainAxisAlignment: MainAxisAlignment.center, children: [
//here already create a scaffold ...
// In this tutorial You can learn about Box Decoration...
// let's Started .....
Container(
//here already create a container now create a box decoration..
height: 300,
width: 400,
// now we create a border ...
decoration: BoxDecoration(
// if you chanage width our border width will changed also you can change any color
border: Border.all(width: 15, color: Colors.green
//now create a border radious ....
),
// already all border circle 10%
borderRadius: BorderRadius.circular(50),
//Now Create a Box Shadow ...
boxShadow: [
BoxShadow(color: Colors.grey, offset: Offset(12.0, 12.0))
],
// Now Create a Gradient Color
gradient: LinearGradient(
colors: [Colors.amber, Colors.green],
// wow this is working great ... please like and subscribe our channel..
// Now we add a image in our Box Decoration
),
image: DecorationImage(
image: NetworkImage(
"https://cdn.pixabay.com/photo/2022/07/13/19/19/blue-eryngo-7319904__340.jpg"),
fit: BoxFit.cover)),
// Thanks for watching this tutorial ... code link in the description...
child: Center(
child: Text(
"BoxDecoration Example",
style: TextStyle(fontWeight: FontWeight.bold),
)),
)
]),
),
);
}
}
- You must complete the advertising ID | Google Play IssueTo solve the “You must complete the advertising ID declaration” problem when releasing an app that targets Android 13, you need to do the following: It’s important to note that you must provide a privacy policy URL even if your app does not use the advertising ID. This is because all apps that target Android …
- You Have Created too many pages recently. Please try again later. Facebook Page Problem?You Have Created too many pages recently. Please try again later. How solve this problem? When you want to create a page for business this message shows. you can’t create a new page for business. Maybe, this is one kind of Facebook bug. Until a Facebook developer can’t solves this bug you can’t create for …
- Will ChatGPT Replace Data Analysts? Future of AI Data AnalysisLearn about the future of AI-driven data analysis, human-AI collaboration, and the importance of adapting to technological advancements.
- Will AI Replace Programmers? Unveiling the Future LandscapeIn our ever-evolving world, programming stands as a transformative force, continually reshaping our reality. Amidst this evolution, the emergence of artificial intelligence (AI) raises a pertinent question: Will AI replace programmers in the times ahead? The realm of programming is undergoing a profound metamorphosis, all thanks to the ascent of AI. With AI’s rapid advancements, …
- Why is Bitcoin more popular than other cryptocurrencies?Cryptocurrencies have taken the financial world by storm, but one name towers above the rest: Bitcoin. In recent years, Bitcoin has garnered widespread attention and popularity, surpassing its competitors in the digital currency realm. This article delves into the reasons behind Bitcoin’s unparalleled success and explores why it outshines other cryptocurrencies. Bitcoin’s Pioneering Role in …