Spacer Widget

Project Preview

  • Interested in seeing the live demo? Click here to explore.
  • Want to view the source code? Visit the project on GitHub.

Code Snippet

import 'package:flutter/material.dart';

class SpacerWidget extends StatelessWidget {
  const SpacerWidget({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text("Spacer Widget"),
      ),
      body: Column(
        children: [
          Container(
            color: Colors.orangeAccent,
            height: 100,
          ),
          const Spacer(
            flex: 1,
          ),
          Container(
            color: Colors.orangeAccent,
            height: 100,
          ),
          const Spacer(
            flex: 2,
          ),
          Container(
            color: Colors.orangeAccent,
            height: 100,
          ),
        ],
      ),
    );
  }
}