Reputation: 3767
Let say I want a container with this style -> rounded shape and with border.
Should I create a theme for Container? Or should I create my custom widget/component?
My main concern here is not to repeat everything so I'm thinking about this 2 possibilities.
Which one more recommended?
Kind Regards
And why people down voted my question. I really don't know :(
Upvotes: 3
Views: 5214
Reputation: 29438
You have to create your widget, which extend Widget
It can be StatelessWidget
class MyWidget extends StatelessWidget {
Widget build(BuildContext context) {
//... return your container here
}
or StatefulWidget
class MyWidget extends StatefulWidget {
MyWidget(this.child);
final Widget child;
@override
State<StatefulWidget> createState() => _MyWidgetState();
}
class _MyWidgetState extends State<MyWidget> {
@override
Widget build(BuildContext context) {
return Container(child: widget.child, ...)
//... return your container here
}
Upvotes: 6