46 lines
1.1 KiB
Dart
46 lines
1.1 KiB
Dart
import 'dart:convert';
|
|
|
|
import 'package:flutter/services.dart';
|
|
import 'package:resume/constants.dart';
|
|
|
|
class ContentProvider {
|
|
ContentProvider._();
|
|
|
|
static const String _jsonPath = 'assets/content.json';
|
|
|
|
static Future<bool> init() async {
|
|
try {
|
|
String file = await rootBundle.loadString(_jsonPath);
|
|
_content = json.decode(file);
|
|
} catch (e) {
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
static Map<String, dynamic> _content = {
|
|
'experience': <List<dynamic>>[],
|
|
'education': <List<dynamic>>[],
|
|
'skills': <List<dynamic>>[],
|
|
'text': <String>[],
|
|
'general_skills': <List<dynamic>>[],
|
|
};
|
|
|
|
static T getContent<T>(ContentType contentType) {
|
|
switch (contentType) {
|
|
case ContentType.experience:
|
|
return _content['experience'] as T;
|
|
case ContentType.education:
|
|
return _content['education'] as T;
|
|
case ContentType.skills:
|
|
return _content['skills'] as T;
|
|
case ContentType.text:
|
|
return _content['text'] as T;
|
|
case ContentType.generalSkills:
|
|
return _content['general_skills'] as T;
|
|
default:
|
|
return [] as T;
|
|
}
|
|
}
|
|
}
|