Line data Source code
1 : // Copyright 2023 The terCAD team. All rights reserved. 2 : // Use of this source code is governed by a CC BY-NC-ND 4.0 license that can be found in the LICENSE file. 3 : 4 : import 'package:app_finance/_configs/theme_helper.dart'; 5 : import 'package:app_finance/design/wrapper/row_widget.dart'; 6 : import 'package:flutter/material.dart'; 7 : 8 : class GridLayer extends StatelessWidget { 9 : final double padding; 10 : final double? width; 11 : final int crossAxisCount; 12 : final List<dynamic> children; 13 : final List<dynamic> strategy; 14 : 15 1 : const GridLayer({ 16 : super.key, 17 : required this.padding, 18 : required this.crossAxisCount, 19 : required this.children, 20 : required this.strategy, 21 : this.width, 22 : }); 23 : 24 1 : @override 25 : Widget build(BuildContext context) { 26 6 : fnItem(int index) => children[index] is Function ? children[index]() : children[index]; 27 8 : fnList(List<dynamic> scope) => scope.map((e) => e is List ? fnList(e).cast<Widget>().toList() : fnItem(e)); 28 1 : return Padding( 29 3 : padding: EdgeInsets.only(left: padding, right: padding), 30 3 : child: strategy.length > 1 31 1 : ? RowWidget( 32 1 : indent: padding, 33 1 : maxWidth: width ?? ThemeHelper.getWidth(context, 2), 34 3 : chunk: List.generate(crossAxisCount, (_) => null), 35 4 : children: fnList(strategy).cast<List<Widget>>().toList(), 36 : ) 37 0 : : Column( 38 0 : children: fnList(strategy.first).cast<Widget>().toList(), 39 : ), 40 : ); 41 : } 42 : }