Use const on Widgets
sandrocsimas opened this issue · comments
Sandro Simas commented
In Flutter it is recommended to use const constructors whenever possible.
In the padding extensions, for example, it is not used.
Padding paddingSymmetric(
{double vertical = 0.0, double horizontal = 0.0, Key? key}) =>
Padding(
key: key,
padding: EdgeInsets.symmetric(
vertical: vertical,
horizontal: horizontal,
),
child: this,
);
This could be:
Padding paddingSymmetric(
{double vertical = 0.0, double horizontal = 0.0, Key? key}) =>
Padding(
key: key,
padding: const EdgeInsets.symmetric(
vertical: vertical,
horizontal: horizontal,
),
child: this,
);
Sandro Simas commented
Never mind, this is actually not possible.
The following error happens: In a const constructor, a value of type 'Null' can't be assigned to the field 'left', which has type 'double'.
Jayesh Pansheriya commented
its not relevant, and not possible, so i close this issue, Thank you @sandrocsimas