1+
2+ import 'dart:convert' ;
3+ import 'dart:io' ;
4+ import 'dart:ui' ;
5+
6+ import 'package:flutter/material.dart' ;
7+
8+ import 'editor.dart' ;
9+ import 'modules_manager.dart' ;
10+
11+ /* Class for storing project information */
12+ class CCSolution {
13+ final String name, desc, author, identifier, slnPath, slnFolderPath;
14+ late Image image;
15+ Map <String , String > folders = {};
16+ List <CCProject > projects = [];
17+
18+ static const decoder = JsonDecoder ();
19+
20+ CCSolution (this .name, this .desc, this .author, this .identifier, this .slnPath,
21+ this .slnFolderPath);
22+
23+ static Future <CCSolution ?> loadFromFile (String filepath) async {
24+ var file = File (filepath);
25+ if (await file.exists ()) {
26+ String input = await file.readAsString ();
27+ var obj = decoder.convert (input);
28+ try {
29+ var result = CCSolution (obj["name" ], obj["description" ] ?? "" ,
30+ obj["author" ], obj["identifier" ], filepath, file.parent.path);
31+
32+ /// Add the solution project folders
33+ var folders = (obj["folders" ] as Map );
34+ for (var key in folders.keys) {
35+ result.folders[key] = folders[key];
36+ }
37+ return result;
38+ } on Exception catch (e) {
39+ debugPrint ("Error: error parsing solution: $filepath #${e .toString ()}" );
40+ return null ;
41+ }
42+ } else {
43+ debugPrint ("Error: project can't be found: $filepath " );
44+ return null ;
45+ }
46+ }
47+ }
48+
49+ class CCProject {
50+ final String name, desc, author, identifier, slnPath, slnFolderPath, projPath;
51+ CCProject (this .name, this .desc, this .author, this .identifier, this .slnPath,
52+ this .slnFolderPath, this .projPath);
53+ }
0 commit comments