ZetaSpacing Usage

To import ZetaSpacing into a Dart file:

import 'package:zeta_flutter/zeta_flutter.dart';

Example

import 'package:zeta_flutter/zeta_flutter.dart';

class ZetaSpacingExample extends StatelessWidget{
  const ZetaSpacingExample({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return ZetaSpacing(...);
  }
}

Setup

To ensure all components work as intended, applications should have ZetaTheme.zeta applied at their top level; typically within MaterialApp or wrapping its equivalent:

import 'package:flutter/material.dart';
import 'package:zeta_flutter/src/theme/theme.dart';

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      theme: ZetaTheme.zeta,
      builder: (context, child) => ...,
    );
  }
}

or

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:zeta_flutter/src/theme/theme.dart';

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return Theme(
      data: ZetaTheme.zeta,
      child: CupertinoApp(
        builder: (context, child) => ...,
      ),
    );
  }
}

ZetaSpacing

ZetaSpacing provides four options for spacing

These spacings should be applied with the following doubles:

Spacing components can be used in multiple ways:

ZetaSpacing() widget with named constructors.

const ZetaSpacing.square(
   Text('Example'),
   size: Dimensions.x1,
),
const ZetaSpacing.squish(
  Text('Example'),
  size: Dimensions.x1,
),
const ZetaSpacing.stack(
  Text('Example'),
  size: Dimensions.x1,
)
const ZetaSpacing.inline(
  Text('Example'),
  size: Dimensions.x1,
)

This is the preferred way to use ZetaSpacing. Having a const, named constructor makes the intuitive and efficient.


ZetaSpacing() widget.

const ZetaSpacing(
  Text('Example'),
  size: Dimensions.x1,
  type: ZetaSpacingType.square,
),
const ZetaSpacing(
  Text('Example'),
  size: Dimensions.x1,
  type: ZetaSpacingType.squish,
),
const ZetaSpacing(
  Text('Example'),
  size: Dimensions.x1,
  type: ZetaSpacingType.stack,
),
const ZetaSpacing(
  Text('Example'),
  size: Dimensions.x1,
  type: ZetaSpacingType.inline,
),

This method is less intuitive than using the named constructor, although it does still provide a const constructor for efficiency.


SpacingSize extension on double.

Container(
  padding: Dimensions.x1.square,
  margin: Dimensions.x10.squish,
  child: Text('Example'),
),
Container(
  padding: Dimensions.x1.stack,
  margin: Dimensions.x10.inline,
  child: Text('Example'),
),


SpacingWidget extension on Widget.

Text('Example').square(Dimensions.x1),
Text('Example').squish(Dimensions.x1),
Text('Example').stack(Dimensions.x1),
Text('Example').inline(Dimensions.x1),
Text('Example').inlineStart(Dimensions.x1),
Text('Example').inlineEnd(Dimensions.x1),