Skip to content

Instantly share code, notes, and snippets.

@ltOgt
ltOgt / conditional_parent_widget.dart
Created June 29, 2020 14:50
Flutter Widget to conditionally wrap a subtree with a parent without breaking the code tree
import 'package:flutter/widgets.dart';
/// Conditionally wrap a subtree with a parent widget without breaking the code tree.
///
/// [condition]: the condition depending on which the subtree [child] is wrapped with the parent.
/// [child]: The subtree that should always be build.
/// [conditionalBuilder]: builds the parent with the subtree [child].
///
/// ___________
/// Usage: