Created
November 28, 2023 02:47
-
-
Save MelbourneDeveloper/e411288a95c34ddfd636a751dc20fb45 to your computer and use it in GitHub Desktop.
Spacer as Named Constant
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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