sleek_spacing 0.1.1

  • Readme
  • Changelog
  • Example
  • Installing
  • 64

Uniformize your margins, paddings and gaps.

Install #

Add the dependency to your pubspec.yaml :

dependencies:
    sleek_spacing: <version>

Quick start #

 SleekColumn(
    padding: SleekInsets.medium(),
    spaceBetween: SleekSpace.normal,
    children: <Widget>[
        Widget(),
        SleekGap.small(),
        Widget(),
        SleekGap.big(),
        Widget(),
    ],
)

Usage #

Defining global spacing #

SleekSpacing(
    data: SleekSpacingData(normal: 12),
    child: <your app>,
)
SleekSpacing(
    data: SleekSpacingData(
      extraSmall: 2.0,
      small: 6.0,
      normal: 12.0,
      medium: 24.0,
      big: 48.0,
      extraBig: 96.0,
    ),
    child: <your app>,
)

Updating global spacing #

Spacing values can be updated from wherever in the tree. This may be usefull to be responsive : adapting margins and gaps when MediaQuery.size changes for example.

SleekSpacing.update(context, SleekSpacingData(normal: 24));

Accessing spaces #

final spacing = SleekSpacing.of(context);
return SizedBox(width: spacing.small);

Widgets #

Gap

You can add an horizontal or vertical gap between other widgets.

Column(
  children: <Widget>[
    Text('Hello'),
    SleekGap.vertical(SleekSpace.small);
    Text('World'),
  ],
),
Row(
  children: <Widget>[
    Text('Hello'),
    SleekGap.horizontal(SleekSpace.small);
    Text('World'),
  ],
),

If your gap is in a SleekColumn, SleekRow or SleekWrap, it can deduce the current axis and makes its needed declaration more concise.

SleekColumn(
  children: <Widget>[
    Text('Hello'),
    SleekGap.small();
    Text('World'),
  ],
),
SleekRow(
  children: <Widget>[
    Text('Hello'),
    SleekGap.small();
    Text('World'),
  ],
),

Padding

SleekPadding(
  vertical: SleekSpace.small,
  left: SleekSpace.medium,
  child: <child>
)
SleekPadding.small(
  child: <child>
)
SleekPadding.small(
  sides: SleekSides.notRight, // All but right
  child: <child>
)
SleekPadding.small(
  sides: SleekSides.vertical + SleekSides.left, // All but right
  child: <child>
)
SleekPadding.small(
  sides: SleekSides.all - SleekSides.bottom, // All but bottom
  child: <child>
)

Column

A SleekColumn is like a Column with padding and spaceBetween additional properties.

 SleekColumn(
    padding: SleekInsets.medium(),
    spaceBetween: SleekSpace.normal,
    children: <children>,
)

Row

A SleekRow is like a Row with padding and spaceBetween additional properties.

 SleekRow(
    padding: SleekInsets.medium(),
    spaceBetween: SleekSpace.normal,
    children: <children>,
)

Wrap

A SleekWrap is like a Wrap with a padding additional property.

 SleekWrap(
    padding: SleekInsets.medium(),
    spacing: SleekSpace.normal,
    runSpacing: SleekSpace.normal,
    children: <children>,
)

[0.1.1] - 2020/03/25 #

  • Updated documentation.

[0.1.0] - 2020/03/25 #

  • Initial version.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:sleek_spacing/sleek_spacing.dart';

import 'home.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return SleekSpacing(
      data: SleekSpacingData(normal: 10),
      child: MaterialApp(
        title: 'Flutter Demo',
        theme: ThemeData(
          primarySwatch: Colors.blue,
        ),
        home: HomePage(),
      ),
    );
  }
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  sleek_spacing: ^0.1.1

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:sleek_spacing/sleek_spacing.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
35
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
83
Overall:
Weighted score of the above. [more]
64
Learn more about scoring.

We analyzed this package on Jun 3, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.2
  • pana: 0.13.8-dev
  • Flutter: 1.17.1

Health suggestions

Fix lib/src/spacing_data.freezed.dart. (-0.50 points)

Analysis of lib/src/spacing_data.freezed.dart reported 1 hint:

line 15 col 21: The declaration '_' isn't referenced.

Maintenance suggestions

The package description is too short. (-17 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.6.0 <3.0.0
flutter 0.0.0
freezed_annotation ^0.7.1 0.7.1 0.11.0-dev
provider ^4.0.4 4.1.2
Transitive dependencies
collection 1.14.12
json_annotation 3.0.1
meta 1.1.8
nested 0.0.4
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
build_runner any
flutter_test
freezed ^0.10.4
json_serializable ^3.2.0