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.
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.
- shadow_widget
A widget that adds a shadow effect to any Flutter widget.
49Compare - balloon_widget
A simple balloon widget with a nip for the Flutter widget tree.
48Compare - widget_loading
Widget that hides its child and shows a loading animation until data is ready
47Compare - search_app_bar_page
A search page widget built for minimal work and good performance.
54Compare
Works with
Packages commonly used together with nil: ones it builds on, ones built on it, and its own family.