Skip to content

Instantly share code, notes, and snippets.

@MelbourneDeveloper
Created November 28, 2023 02:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MelbourneDeveloper/e411288a95c34ddfd636a751dc20fb45 to your computer and use it in GitHub Desktop.
Save MelbourneDeveloper/e411288a95c34ddfd636a751dc20fb45 to your computer and use it in GitHub Desktop.
Spacer as Named Constant
import 'package:flutter/material.dart';
void main() => runApp(const MyApp());
// Declares the SizedBox as a named constant
const SizedBox mySpacer = SizedBox(height: 20);
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) => const MaterialApp(
debugShowCheckedModeBanner: false,
home: Scaffold(
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text('Item 1'),
mySpacer, // Using the spacer
Text('Item 2'),
mySpacer, // Using the spacer again
Text('Item 3'),
],
),
),
),
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment