A package to provide distance between items in a Column, Row, ListView
Features
By using this dependency you can provide spacing between items.
instead of using SizedBox() individually.
Getting started
import this
import 'package:with_space_between/with_space_between.dart';
Usage
You can use package by calling
.withSpaceBetween(width: space5)
in Column, Row or ListView Angle Brackets
Example Code
import 'package:flutter/material.dart';
import 'package:with_space_between/with_space_between.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
useMaterial3: true,
),
home: const MyHomePage(),
);
}
}
class MyHomePage extends StatelessWidget {
const MyHomePage({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.white,
appBar: AppBar(
title: Text("Space Between"),
),
body: Padding(
padding: const EdgeInsets.all(20.0),
child: Row(
children: [
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(
"With Package",
style: TextStyle(fontSize: 20),
),
Container(
padding: EdgeInsets.symmetric(horizontal: 15, vertical: 15),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(15),
color: Colors.purple),
child: Text(
"Example",
style: TextStyle(fontSize: 12, color: Colors.white),
),
),
Container(
padding: EdgeInsets.symmetric(horizontal: 15, vertical: 15),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(15),
color: Colors.purple),
child: Text(
"Example",
style: TextStyle(fontSize: 12, color: Colors.white),
),
),
Container(
padding: EdgeInsets.symmetric(horizontal: 15, vertical: 15),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(15),
color: Colors.purple),
child: Text(
"Example",
style: TextStyle(fontSize: 12, color: Colors.white),
),
),
].withSpaceBetween(height: 15),
),
),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(
"Without Package",
style: TextStyle(fontSize: 20),
),
Container(
padding: EdgeInsets.symmetric(horizontal: 15, vertical: 15),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(15),
color: Colors.purple),
child: Text(
"Example",
style: TextStyle(fontSize: 12, color: Colors.white),
),
),
Container(
padding: EdgeInsets.symmetric(horizontal: 15, vertical: 15),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(15),
color: Colors.purple),
child: Text(
"Example",
style: TextStyle(fontSize: 12, color: Colors.white),
),
),
Container(
padding: EdgeInsets.symmetric(horizontal: 15, vertical: 15),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(15),
color: Colors.purple),
child: Text(
"Example",
style: TextStyle(fontSize: 12, color: Colors.white),
),
),
],
),
),
].withSpaceBetween(width: 15),
),
),
);
}
}