jayeshpansheriya / awesome_extensions

An extension to the widget that helps to reduce the boilerplate and adds some helpful methods. and you can make responsive design.

Home Page:https://pub.dev/packages/awesome_extensions

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Use const on Widgets

sandrocsimas opened this issue · comments

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,
      );

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'.

its not relevant, and not possible, so i close this issue, Thank you @sandrocsimas