Skip to content
pubscout

nil

1.1.1, released 6 years ago by an unverified publisher

A simple widget to add in the widget tree when you want to show nothing.

WASM-ready
$ flutter pub add nil
Source repository

What it does

Provides a minimal Nil widget that can be used when you need to display nothing conditionally in the widget tree. Unlike `SizedBox`, it does not create a RenderObject, resulting in better performance.

AI-written summary of version 1.1.1, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You need to conditionally return nothing in a widget build method where returning null is not allowed
  • You want a lighter alternative to `const SizedBox()` to avoid creating unneeded RenderObjects

Skip it when

  • You are using widgets that accept multiple children like Rows or Columns

Strengths

  • Better performance than `SizedBox()` because it creates no RenderObject
  • Comes with a convenient `nil` constant

Weaknesses

  • Can cause unexpected results if used inside multi-child widgets like Rows or Columns

Setup

Kind
Flutter widgets
Effort
Low
Code generation
No
Direct dependencies
0
import 'package:nil/nil.dart';

return Builder(
  builder: (_) {
    if (condition) {
      return const MyWidget();
    } else {
      return nil;
    }
  },
);

Alternatives

Packages that do the same job and could replace nil.

Works with

Packages commonly used together with nil: ones it builds on, ones built on it, and its own family.