12345678910111213141516171819202122232425262728293031323334 |
- import 'unit.dart';
- class LayoutSection {
- String _key = '';
- List<LayoutUnit>? _layouts;
- String get key => _key;
- List<LayoutUnit> get layouts => _layouts ?? const [];
- LayoutSection();
- factory LayoutSection.fromJson(Map<String, dynamic> map) {
- final instance = LayoutSection();
- instance._key = map['n'] ?? '';
- instance._loadLayoutUnits(map['Layouts']);
- return instance;
- }
- void _loadLayoutUnits(dynamic data) {
- final List<LayoutUnit> arr = [];
- if (data != null && data is List) {
- final List<dynamic> jArr = data;
- for (final item in jArr) {
- arr.add(LayoutUnit.fromJson(item));
- }
- }
- if (arr.isEmpty) {
- throw ArgumentError(
- "Layout configuration error: Layout element not found.");
- }
- _layouts = arr;
- }
- }
|