Code
main.dart
| import 'package:box_decoration/images.dart'; |
| import 'package:flutter/material.dart'; |
| void main() => runApp(MyApp()); |
| class MyApp extends StatelessWidget { |
| @override |
| Widget build(BuildContext context) { |
| return MaterialApp( |
| debugShowCheckedModeBanner: false, |
| title: 'Flutter Demo', |
| theme: ThemeData( |
| primaryColor: Color(0xFF832685), |
| primaryColorLight: Color(0xFFC81379), |
| accentColor: Colors.black, |
| ), |
| home: MyHomePage(), |
| ); |
| } |
| } |
| class MyHomePage extends StatefulWidget { |
| @override |
| _MyHomePageState createState() => _MyHomePageState(); |
| } |
| class _MyHomePageState extends State<MyHomePage> { |
| String title = 'BoxDecoration'; |
| @override |
| Widget build(BuildContext context) { |
| return Scaffold( |
| appBar: AppBar( |
| title: Text(title), |
| centerTitle: true, |
| ), |
| body: Center( |
| child: Container( |
| height: 300, |
| width: 300, |
| decoration: BoxDecoration( |
| color: Colors.orangeAccent, |
| shape: BoxShape.circle, |
| border: Border.all(color: Colors.redAccent, width: 5), |
| image: DecorationImage( |
| image: AssetImage(placeHolder), |
| ) |
| ), |
| ), |
| ) |
| ); |
| } |
| } |
images.dart
const String placeHolder = "assets/images/placeholders.png";
0 Comments
If you have any doubts, please let me know