stack_wallet/lib/widgets/conditional_parent.dart

58 lines
1.3 KiB
Dart
Raw Normal View History

2023-05-26 21:21:16 +00:00
/*
* This file is part of Stack Wallet.
*
* Copyright (c) 2023 Cypher Stack
* All Rights Reserved.
* The code is distributed under GPLv3 license, see LICENSE file for details.
* Generated by Cypher Stack on 2023-05-26
*
*/
import 'package:flutter/material.dart';
class ConditionalParent extends StatelessWidget {
const ConditionalParent({
Key? key,
required this.condition,
required this.builder,
required this.child,
}) : super(key: key);
final bool condition;
final Widget Function(Widget) builder;
final Widget child;
@override
Widget build(BuildContext context) {
if (condition) {
return builder(child);
} else {
return child;
}
}
}
2022-11-09 18:58:38 +00:00
class BranchedParent extends StatelessWidget {
const BranchedParent({
Key? key,
required this.condition,
required this.conditionBranchBuilder,
required this.otherBranchBuilder,
required this.children,
}) : super(key: key);
final bool condition;
final Widget Function(List<Widget>) conditionBranchBuilder;
final Widget Function(List<Widget>) otherBranchBuilder;
final List<Widget> children;
@override
Widget build(BuildContext context) {
if (condition) {
return conditionBranchBuilder(children);
} else {
return otherBranchBuilder(children);
}
}
}