Refractor

Same code of widget in different widget can be shorten by making new widget by refractor 

example

Container(
margin: EdgeInsets.all(15),
decoration: BoxDecoration(
color: Color(0xFF1d1f33),
borderRadius: BorderRadius.circular(12),

this above code is used multiple times in different widget so we use refractor

then by refractor we can name new widget replacing this above code

example  --  ReusableCard(),

by Refracting, this code made by android studio

Key is an identifier for Widgets, Elements and SemanticsNodes.

class ReusableCard extends StatelessWidget {
const ReusableCard({
Key key,
}) : super(key: key);

@override
Widget build(BuildContext context) {
return Container(
margin: EdgeInsets.all(15),
decoration: BoxDecoration(
color: Color(0xFF1d1f33),
borderRadius: BorderRadius.circular(12),
),
);
}
}





Comments