To import ZetaSpacing into a Dart file:
import 'package:zeta_flutter/zeta_flutter.dart';
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(...);
}
}
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 provides four options for spacing
square - applies inset to all 4 sides equally.squish - applies inset to top and bottom only.inline - applies inset to start and end only.inlineStart - applies inset to start only. For LTR locales this is the left, for RTL locales this is the right.inlineEnd - applies inset to end only. For LTR locales this is the right, for RTL locales this is the left.stack - applies inset to bottom only.These spacings should be applied with the following doubles:
x0 - 0x1 - 4 - also xxsx2 - 8 - also xsx3 - 12 - also sx4 - 16 - also bx5 - 20x6 - 24 - also mx7 - 28x8 - 32 - also lx9 - 36x10 - 40x11 - 44x12 - 48x13 - 52x14 - 58x16 - 64 - also xlx20 - 80 - also xxlx24 - 96 - also xxxlSpacing components can be used in multiple ways:
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.
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.
Container(
padding: Dimensions.x1.square,
margin: Dimensions.x10.squish,
child: Text('Example'),
),
Container(
padding: Dimensions.x1.stack,
margin: Dimensions.x10.inline,
child: Text('Example'),
),
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),