How do I store my default padding in Theme.of() in Flutter?

Viewed 2084

As far as I understand I'm supposed to access my style constants in flutter via Theme.of(). In Android I would have stored them in dimens.xml. None of the entries in ThemeData look to me like they are about padding amounts and it also seems impossible to add new ones. Where should I store the my constants for padding amounts?

2 Answers

Create a contants.dart file and store the default padding there

const kDefaultPadding = EdgeInsets.all(16);

I made a util function to keep paddings etc consistent

const kDefaultSpacingFactor = 8;
// this function will simple take a value and multiply with the constant scaling
// factor, to keep paddings etc consistent
double spacingFactor(double multiplier) {
  return multiplier * kDefaultSpacingFactor;
}
Related