Added ContentProvider
This commit is contained in:
27
lib/services/content_provider.dart
Normal file
27
lib/services/content_provider.dart
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
import 'dart:convert';
|
||||||
|
|
||||||
|
import 'package:flutter/services.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 = {};
|
||||||
|
|
||||||
|
static List<dynamic> get experience => _content['experience'];
|
||||||
|
|
||||||
|
static List<Map<String, dynamic>> get education => _content['education'];
|
||||||
|
|
||||||
|
static List<Map<String, dynamic>> get skills => _content['skills'];
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user