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 3 : 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 3 : @override 25 : Widget build(BuildContext context) { 26 18 : fnItem(int index) => children[index] is Function ? children[index]() : children[index]; 27 24 : fnList(List<dynamic> scope) => scope.map((e) => e is List ? fnList(e).cast<Widget>().toList() : fnItem(e)); 28 3 : return Padding( 29 9 : padding: EdgeInsets.only(left: padding, right: padding), 30 9 : child: strategy.length > 1 31 3 : ? RowWidget( 32 3 : indent: padding, 33 3 : maxWidth: width ?? ThemeHelper.getWidth(context, 2), 34 9 : chunk: List.generate(crossAxisCount, (_) => null), 35 12 : children: fnList(strategy).cast<List<Widget>>().toList(), 36 : ) 37 0 : : Column( 38 0 : children: fnList(strategy.first).cast<Widget>().toList(), 39 : ), 40 : ); 41 : } 42 : }