Open In App

Placeholder Flutter

Last Updated : 08 Jun, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

Placeholder is a popular, inbuilt widget of the Flutter framework that creates an empty canvas/container on the screen to put content into, just like its name implies. It is analogous to both the placeholder attribute and the <div> tag of HTML. Almost all Flutter developers have reported using it at some point or another during their coding process. It serves as a foundational building block during the application development process within tight deadlines in the widget tree.

Technical Description of Flutter's Placeholder Widget

The Placeholder Widget is an inbuilt widget offered by the Flutter framework. It is used during the development process to create an empty container to showcase where the content (other widgets) will later go in, in order to indicate that the user interface is not yet complete. Thus, this is a useful feature beneficial for any developer to show their current work status/progress to their team lead when they have not yet completed developing the application.

Constructor of Placeholder

Placeholder Placeholder({
Key? key,
Color color = const Color(0xFF455A64),
double strokeWidth = 2.0,
double fallbackWidth = 400.0,
double fallbackHeight = 400.0,
Widget? child,
})

Inbuilt Properties of the Placeholder Widget

Property

Description

child

Fixes the child widget of the Placeholder widget. Generally used to denote the widget/collection of widgets, if any, present inside the Placeholder widget

color

Provides the color drawing of the placeholder box and its strokes

fallBackHeight

Provides the height of the placeholder box when it is in unbounded height constraints

fallBackWidth

Provides the width of the placeholder box when it is in unbounded width constraints

key

Controls how one widget replaces another

strokeWidth

Provides the width of the strokes across the placeholder box

Code to use the placeholder widget in Flutter:

Having a simple placeholder is fairly easy to build as per the steps given on the Placeholder Widget's Flutter Official Documentation.

Dart
Placeholder(
          strokeWidth: 1.0,
          color: Colors.indigoAccent,
          child: Container(
              padding: const EdgeInsets.all(20),
              child: const Text(
                "This is a placeholder",
                style: TextStyle(fontWeight: FontWeight.bold),
              )),
        ),


For integration with the main code, the Placeholder widget code snippet needs to be added to the Scaffold. Here, a very basic Scaffold Design is taken for simplicity, with the maximum focus on the Placeholder Widget.

Dart
Scaffold(
  appBar: AppBar(
    title: const Text('Flutter Placeholder Widget Demo'),
    backgroundColor: Colors.green,
    foregroundColor: Colors.white,
  ),
  body: Center(
    child: Placeholder(
      strokeWidth: 1.0,
      color: Colors.indigoAccent,
      child: Container(
        padding: const EdgeInsets.all(20),
        child: const Text(
          "This is a placeholder",
          style: TextStyle(fontWeight: FontWeight.bold),
        ),
      ),
    ),
  ),
);

The Flutter Placeholder has a very basic styling in this code, using a few of its inbuilt properties: strokeWidth, color, and child, as it will soon be replaced with the desired widget, thus serving as a placeholder for the time being.

Complete Source Code

main.dart:

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

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'GeeksforGeeks Localization',
      debugShowCheckedModeBanner: false,
      home: HomeScreen(),
    );
  }
}

class HomeScreen extends StatefulWidget {
  const HomeScreen({super.key});

  @override
  State<HomeScreen> createState() => _HomeScreenState();
}

class _HomeScreenState extends State<HomeScreen> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Flutter Placeholder Widget Demo'),
        backgroundColor: Colors.green,
        foregroundColor: Colors.white,
      ),
      body: Center(
        child: Placeholder(
          strokeWidth: 1.0,
          color: Colors.indigoAccent,
          child: Container(
            padding: const EdgeInsets.all(20),
            child: const Text(
              "This is a placeholder",
              style: TextStyle(fontWeight: FontWeight.bold),
            ),
          ),
        ),
      ),
    );
  }
}

Output:

Placeholder_Flutter



Article Tags :

Similar Reads