Skip to content

Instantly share code, notes, and snippets.

@sixtusagbo
Created August 3, 2024 07:09
Show Gist options
  • Save sixtusagbo/3c623c06887a59bf607d1ca3672e3c37 to your computer and use it in GitHub Desktop.
Save sixtusagbo/3c623c06887a59bf607d1ca3672e3c37 to your computer and use it in GitHub Desktop.
Using extension types to implement 4-point grid system in flutter
// This code was borrowed from here: https://x.com/mkobuolys/status/1819377685639950585
const _multiplier = 4.0;
extension type DesignSystemSpace._(double spacing) implements double {
DesignSystemSpace(double token) : spacing = token * _multiplier;
}
final space = DesignSystemSpace(4); // 16
final padding = EdgeInsets.all(DesignSystemSpace(4)); // EdgeInsets.all(16.0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment