feat: update font family references and improve error handling in local storage
This commit is contained in:
@@ -20,22 +20,30 @@ class HiveLocalStorage implements ILocalStorage {
|
||||
Uint8List? bytes,
|
||||
String? collection,
|
||||
}) async {
|
||||
var exist = await Hive.boxExists(boxName);
|
||||
if (!exist || !Hive.isBoxOpen(boxName)) {
|
||||
await Hive.openBox<T>(
|
||||
boxName,
|
||||
encryptionCipher: encryptionCipher,
|
||||
crashRecovery: crashRecovery,
|
||||
);
|
||||
try {
|
||||
var exist = await Hive.boxExists(boxName);
|
||||
if (!exist || !Hive.isBoxOpen(boxName)) {
|
||||
await Hive.openBox<T>(
|
||||
boxName,
|
||||
encryptionCipher: encryptionCipher,
|
||||
crashRecovery: crashRecovery,
|
||||
);
|
||||
}
|
||||
} catch (e) {
|
||||
eLog(e);
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
T? read<T>({required String boxName, required String key}) {
|
||||
try {
|
||||
if (!Hive.isBoxOpen(boxName)) {
|
||||
return null;
|
||||
}
|
||||
Box? box = getBox(boxName);
|
||||
return box?.get(key) as T?;
|
||||
} on Exception catch (e) {
|
||||
} catch (e) {
|
||||
eLog(e);
|
||||
return null;
|
||||
}
|
||||
@@ -44,9 +52,12 @@ class HiveLocalStorage implements ILocalStorage {
|
||||
@override
|
||||
List<T>? readBox<T>({required String boxName}) {
|
||||
try {
|
||||
if (!Hive.isBoxOpen(boxName)) {
|
||||
return null;
|
||||
}
|
||||
Box? box = getBox<T>(boxName);
|
||||
return box?.values.cast<T>().toList();
|
||||
} on Exception catch (e) {
|
||||
} catch (e) {
|
||||
eLog(e);
|
||||
return null;
|
||||
}
|
||||
@@ -54,50 +65,141 @@ class HiveLocalStorage implements ILocalStorage {
|
||||
|
||||
@override
|
||||
Future<void> add<T>({required String boxName, required dynamic value}) async {
|
||||
Box<dynamic>? box = getBox<T>(boxName);
|
||||
await box?.add(value);
|
||||
try {
|
||||
if (!Hive.isBoxOpen(boxName)) {
|
||||
await openBox<T>(boxName);
|
||||
}
|
||||
Box<dynamic>? box = getBox<T>(boxName);
|
||||
await box?.add(value);
|
||||
} catch (e) {
|
||||
eLog(e);
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> addAll<T>({required String boxName, required Iterable values}) async {
|
||||
Box<dynamic>? box = getBox<T>(boxName);
|
||||
await box?.addAll(values);
|
||||
Future<void> addAll<T>({
|
||||
required String boxName,
|
||||
required Iterable values,
|
||||
}) async {
|
||||
try {
|
||||
if (!Hive.isBoxOpen(boxName)) {
|
||||
await openBox<T>(boxName);
|
||||
}
|
||||
Box<dynamic>? box = getBox<T>(boxName);
|
||||
await box?.addAll(values);
|
||||
} catch (e) {
|
||||
eLog(e);
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
|
||||
Box<T>? getBox<T>(String boxName) {
|
||||
final box = Hive.box<T>(boxName);
|
||||
return box;
|
||||
try {
|
||||
if (!Hive.isBoxOpen(boxName)) {
|
||||
return null;
|
||||
}
|
||||
final box = Hive.box<T>(boxName);
|
||||
return box;
|
||||
} catch (e) {
|
||||
eLog(e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> clear(String boxName) async {
|
||||
await Hive.box(boxName).clear();
|
||||
try {
|
||||
if (!Hive.isBoxOpen(boxName)) {
|
||||
return;
|
||||
}
|
||||
await Hive.box(boxName).clear();
|
||||
} catch (e) {
|
||||
eLog(e);
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> close(String boxName) async => await Hive.box(boxName).close();
|
||||
|
||||
@override
|
||||
Future<void> deleteValue<T>({required String boxName, required String key}) async {
|
||||
Box<dynamic>? box = getBox<T>(boxName);
|
||||
await box?.delete(key);
|
||||
Future<void> close(String boxName) async {
|
||||
try {
|
||||
if (!Hive.isBoxOpen(boxName)) {
|
||||
return;
|
||||
}
|
||||
await Hive.box(boxName).close();
|
||||
} catch (e) {
|
||||
eLog(e);
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> save<T>({required String boxName, required String key, required value}) async {
|
||||
Box<dynamic>? box = getBox<T>(boxName);
|
||||
await box?.put(key, value);
|
||||
Future<void> deleteValue<T>({
|
||||
required String boxName,
|
||||
required String key,
|
||||
}) async {
|
||||
try {
|
||||
if (!Hive.isBoxOpen(boxName)) {
|
||||
return;
|
||||
}
|
||||
Box<dynamic>? box = getBox<T>(boxName);
|
||||
await box?.delete(key);
|
||||
} catch (e) {
|
||||
eLog(e);
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> saveAll<T>({required String boxName, required Map entries}) async {
|
||||
Box<dynamic>? box = getBox<T>(boxName);
|
||||
await box?.putAll(entries);
|
||||
Future<void> save<T>({
|
||||
required String boxName,
|
||||
required String key,
|
||||
required value,
|
||||
}) async {
|
||||
try {
|
||||
if (!Hive.isBoxOpen(boxName)) {
|
||||
await openBox<T>(boxName);
|
||||
}
|
||||
Box<dynamic>? box = getBox<T>(boxName);
|
||||
await box?.put(key, value);
|
||||
} catch (e) {
|
||||
eLog(e);
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> saveAt<T>({required String boxName, required int index, required value}) async {
|
||||
Box<dynamic>? box = getBox<T>(boxName);
|
||||
await box?.putAt(index, value);
|
||||
Future<void> saveAll<T>({
|
||||
required String boxName,
|
||||
required Map entries,
|
||||
}) async {
|
||||
try {
|
||||
if (!Hive.isBoxOpen(boxName)) {
|
||||
await openBox<T>(boxName);
|
||||
}
|
||||
Box<dynamic>? box = getBox<T>(boxName);
|
||||
await box?.putAll(entries);
|
||||
} catch (e) {
|
||||
eLog(e);
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> saveAt<T>({
|
||||
required String boxName,
|
||||
required int index,
|
||||
required value,
|
||||
}) async {
|
||||
try {
|
||||
if (!Hive.isBoxOpen(boxName)) {
|
||||
await openBox<T>(boxName);
|
||||
}
|
||||
Box<dynamic>? box = getBox<T>(boxName);
|
||||
await box?.putAt(index, value);
|
||||
} catch (e) {
|
||||
eLog(e);
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,11 +7,10 @@ class DioFormData implements IFormData {
|
||||
final FormData _formData = FormData();
|
||||
|
||||
@override
|
||||
void addFile(String field, Uint8List bytes, String filename) {
|
||||
_formData.files.add(MapEntry(
|
||||
field,
|
||||
MultipartFile.fromBytes(bytes, filename: filename),
|
||||
));
|
||||
Future<void> addFile(String field, Uint8List bytes, String filename) async {
|
||||
_formData.files.add(
|
||||
MapEntry(field, MultipartFile.fromBytes(bytes, filename: filename)),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@@ -5,12 +5,28 @@ class DioRemote implements IHttpClient {
|
||||
String? baseUrl;
|
||||
late Dio dio;
|
||||
AppInterceptor? interceptors;
|
||||
Duration? connectTimeout;
|
||||
Duration? receiveTimeout;
|
||||
Duration? sendTimeout;
|
||||
|
||||
DioRemote({this.baseUrl, this.interceptors});
|
||||
DioRemote({
|
||||
this.baseUrl,
|
||||
this.interceptors,
|
||||
this.connectTimeout,
|
||||
this.receiveTimeout,
|
||||
this.sendTimeout,
|
||||
});
|
||||
|
||||
@override
|
||||
Future<void> init() async {
|
||||
dio = Dio(BaseOptions(baseUrl: baseUrl ?? ''));
|
||||
dio = Dio(
|
||||
BaseOptions(
|
||||
baseUrl: baseUrl ?? '',
|
||||
connectTimeout: connectTimeout ?? const Duration(seconds: 30),
|
||||
receiveTimeout: receiveTimeout ?? const Duration(seconds: 30),
|
||||
sendTimeout: sendTimeout ?? const Duration(seconds: 30),
|
||||
),
|
||||
);
|
||||
if (interceptors != null) {
|
||||
interceptors!.dio = dio;
|
||||
dio.interceptors.add(interceptors!);
|
||||
@@ -84,7 +100,9 @@ class DioRemote implements IHttpClient {
|
||||
|
||||
if (fromJson != null) {
|
||||
final rawData = response.data;
|
||||
final parsedData = rawData is Map<String, dynamic> ? fromJson(rawData) : null;
|
||||
final parsedData = rawData is Map<String, dynamic>
|
||||
? fromJson(rawData)
|
||||
: null;
|
||||
response.data = parsedData;
|
||||
return DioResponse<T>(response);
|
||||
}
|
||||
@@ -136,7 +154,9 @@ class DioRemote implements IHttpClient {
|
||||
);
|
||||
if (fromJson != null) {
|
||||
final rawData = response.data;
|
||||
final parsedData = rawData is Map<String, dynamic> ? fromJson(rawData) : null;
|
||||
final parsedData = rawData is Map<String, dynamic>
|
||||
? fromJson(rawData)
|
||||
: null;
|
||||
response.data = parsedData;
|
||||
return DioResponse<T>(response);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
|
||||
abstract class IFormData{
|
||||
void addFile(String field, Uint8List bytes, String filename);
|
||||
Future<void> addFile(String field, Uint8List bytes, String filename);
|
||||
void addField(String key, String value);
|
||||
}
|
||||
@@ -11,12 +11,11 @@ Future<void> setupAllCoreProvider() async {
|
||||
diCore.registerSingleton<ImagePicker>(ImagePicker());
|
||||
|
||||
//max 500MB Map Cashing
|
||||
// await FMTCObjectBoxBackend().initialise();
|
||||
// await FMTCObjectBoxBackend().initialise();
|
||||
|
||||
await diCore.allReady();
|
||||
}
|
||||
|
||||
|
||||
Future<void> _setupLocalStorage() async {
|
||||
var localStorage = diCore.registerSingleton<HiveLocalStorage>(HiveLocalStorage());
|
||||
await localStorage.init();
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
|
||||
class AppFonts {
|
||||
AppFonts._(); // Private constructor to prevent instantiation
|
||||
import 'fonts.gen.dart';
|
||||
|
||||
// --- Font Families ---
|
||||
static const String yekan = 'yekan';
|
||||
class AppFonts {
|
||||
AppFonts._();
|
||||
|
||||
// --- Font Weights ---
|
||||
static const FontWeight regular = FontWeight.w400;
|
||||
@@ -13,202 +12,199 @@ class AppFonts {
|
||||
static const double _height = 1.20;
|
||||
|
||||
static TextStyle yekan61 = TextStyle(
|
||||
fontFamily: yekan,
|
||||
fontFamily: FontFamily.yekan,
|
||||
fontWeight: regular,
|
||||
fontSize: 61.sp,
|
||||
height: _height,
|
||||
);
|
||||
|
||||
static TextStyle yekan49 = TextStyle(
|
||||
fontFamily: yekan,
|
||||
fontFamily: FontFamily.yekan,
|
||||
fontWeight: regular,
|
||||
fontSize: 48.sp,
|
||||
height: _height,
|
||||
);
|
||||
|
||||
static TextStyle yekan39 = TextStyle(
|
||||
fontFamily: yekan,
|
||||
fontFamily: FontFamily.yekan,
|
||||
fontWeight: regular,
|
||||
fontSize: 39.sp,
|
||||
height: _height,
|
||||
);
|
||||
|
||||
static TextStyle yekan31 = TextStyle(
|
||||
fontFamily: yekan,
|
||||
fontFamily: FontFamily.yekan,
|
||||
fontWeight: regular,
|
||||
fontSize: 31.sp,
|
||||
height: _height,
|
||||
);
|
||||
|
||||
static TextStyle yekan25 = TextStyle(
|
||||
fontFamily: yekan,
|
||||
fontFamily: FontFamily.yekan,
|
||||
fontWeight: regular,
|
||||
fontSize: 25.sp,
|
||||
height: _height,
|
||||
);
|
||||
|
||||
static TextStyle yekan24 = TextStyle(
|
||||
fontFamily: yekan,
|
||||
fontFamily: FontFamily.yekan,
|
||||
fontWeight: regular,
|
||||
fontSize: 24.sp,
|
||||
height: _height,
|
||||
);
|
||||
|
||||
static TextStyle yekan20 = TextStyle(
|
||||
fontFamily: yekan,
|
||||
fontFamily: FontFamily.yekan,
|
||||
fontWeight: regular,
|
||||
fontSize: 20.sp,
|
||||
height: _height,
|
||||
);
|
||||
|
||||
static TextStyle yekan18 = TextStyle(
|
||||
fontFamily: yekan,
|
||||
fontFamily: FontFamily.yekan,
|
||||
fontWeight: regular,
|
||||
fontSize: 18.sp,
|
||||
height: _height,
|
||||
);
|
||||
|
||||
static TextStyle yekan16 = TextStyle(
|
||||
fontFamily: yekan,
|
||||
fontFamily: FontFamily.yekan,
|
||||
fontWeight: regular,
|
||||
fontSize: 16.sp,
|
||||
height: _height,
|
||||
);
|
||||
|
||||
static TextStyle yekan14 = TextStyle(
|
||||
fontFamily: yekan,
|
||||
fontFamily: FontFamily.yekan,
|
||||
fontWeight: regular,
|
||||
fontSize: 13.sp,
|
||||
height: _height,
|
||||
);
|
||||
|
||||
|
||||
|
||||
static TextStyle yekan13 = TextStyle(
|
||||
fontFamily: yekan,
|
||||
fontFamily: FontFamily.yekan,
|
||||
fontWeight: regular,
|
||||
fontSize: 13.sp,
|
||||
height: _height,
|
||||
);
|
||||
|
||||
|
||||
static TextStyle yekan12 = TextStyle(
|
||||
fontFamily: yekan,
|
||||
fontFamily: FontFamily.yekan,
|
||||
fontWeight: regular,
|
||||
fontSize: 12.sp,
|
||||
height: _height,
|
||||
);
|
||||
|
||||
|
||||
static TextStyle yekan10 = TextStyle(
|
||||
static TextStyle yekan10 = TextStyle(
|
||||
// Rounded from 10.24
|
||||
fontFamily: yekan,
|
||||
fontFamily: FontFamily.yekan,
|
||||
fontWeight: regular,
|
||||
fontSize: 10.sp,
|
||||
height: _height,
|
||||
);
|
||||
|
||||
|
||||
static TextStyle yekan8= TextStyle(
|
||||
static TextStyle yekan8 = TextStyle(
|
||||
// Rounded from 10.24
|
||||
fontFamily: yekan,
|
||||
fontFamily: FontFamily.yekan,
|
||||
fontWeight: regular,
|
||||
fontSize: 8.sp,
|
||||
height: _height,
|
||||
);
|
||||
|
||||
static TextStyle yekan61Bold = TextStyle(
|
||||
fontFamily: yekan,
|
||||
static TextStyle yekan61Bold = TextStyle(
|
||||
fontFamily: FontFamily.yekan,
|
||||
fontWeight: bold, // Use bold weight
|
||||
fontSize: 61.sp,
|
||||
height: _height,
|
||||
);
|
||||
|
||||
static TextStyle yekan49Bold = TextStyle(
|
||||
fontFamily: yekan,
|
||||
static TextStyle yekan49Bold = TextStyle(
|
||||
fontFamily: FontFamily.yekan,
|
||||
fontWeight: bold, // Use bold weight
|
||||
fontSize: 48.sp,
|
||||
height: _height,
|
||||
);
|
||||
|
||||
static TextStyle yekan39Bold = TextStyle(
|
||||
fontFamily: yekan,
|
||||
static TextStyle yekan39Bold = TextStyle(
|
||||
fontFamily: FontFamily.yekan,
|
||||
fontWeight: bold, // Use bold weight
|
||||
fontSize: 39.sp,
|
||||
height: _height,
|
||||
);
|
||||
|
||||
static TextStyle yekan31Bold = TextStyle(
|
||||
fontFamily: yekan,
|
||||
static TextStyle yekan31Bold = TextStyle(
|
||||
fontFamily: FontFamily.yekan,
|
||||
fontWeight: bold, // Use bold weight
|
||||
fontSize: 31.sp,
|
||||
height: _height,
|
||||
);
|
||||
|
||||
static TextStyle yekan25Bold = TextStyle(
|
||||
fontFamily: yekan,
|
||||
static TextStyle yekan25Bold = TextStyle(
|
||||
fontFamily: FontFamily.yekan,
|
||||
fontWeight: bold, // Use bold weight
|
||||
fontSize: 25.sp,
|
||||
height: _height,
|
||||
);
|
||||
|
||||
static TextStyle yekan24Bold = TextStyle(
|
||||
fontFamily: yekan,
|
||||
static TextStyle yekan24Bold = TextStyle(
|
||||
fontFamily: FontFamily.yekan,
|
||||
fontWeight: bold, // Use bold weight
|
||||
fontSize: 24.sp,
|
||||
height: _height,
|
||||
);
|
||||
|
||||
static TextStyle yekan20Bold = TextStyle(
|
||||
fontFamily: yekan,
|
||||
static TextStyle yekan20Bold = TextStyle(
|
||||
fontFamily: FontFamily.yekan,
|
||||
fontWeight: bold, // Use bold weight
|
||||
fontSize: 20.sp,
|
||||
height: _height,
|
||||
);
|
||||
|
||||
|
||||
static TextStyle yekan18Bold = TextStyle(
|
||||
fontFamily: yekan,
|
||||
static TextStyle yekan18Bold = TextStyle(
|
||||
fontFamily: FontFamily.yekan,
|
||||
fontWeight: bold, // Use bold weight
|
||||
fontSize: 18.sp,
|
||||
height: _height,
|
||||
);
|
||||
|
||||
|
||||
static TextStyle yekan16Bold = TextStyle(
|
||||
static TextStyle yekan16Bold = TextStyle(
|
||||
// Base size bold
|
||||
fontFamily: yekan,
|
||||
fontFamily: FontFamily.yekan,
|
||||
fontWeight: bold, // Use bold weight
|
||||
fontSize: 16.sp,
|
||||
height: _height,
|
||||
);
|
||||
|
||||
|
||||
static TextStyle yekan14Bold = TextStyle(
|
||||
fontFamily: yekan,
|
||||
static TextStyle yekan14Bold = TextStyle(
|
||||
fontFamily: FontFamily.yekan,
|
||||
fontWeight: bold, // Use bold weight
|
||||
fontSize: 13.sp,
|
||||
height: _height,
|
||||
);
|
||||
|
||||
|
||||
static TextStyle yekan13Bold = TextStyle(
|
||||
fontFamily: yekan,
|
||||
static TextStyle yekan13Bold = TextStyle(
|
||||
fontFamily: FontFamily.yekan,
|
||||
fontWeight: bold, // Use bold weight
|
||||
fontSize: 13.sp,
|
||||
height: _height,
|
||||
);
|
||||
|
||||
static TextStyle yekan12Bold = TextStyle(
|
||||
fontFamily: yekan,
|
||||
static TextStyle yekan12Bold = TextStyle(
|
||||
fontFamily: FontFamily.yekan,
|
||||
fontWeight: bold, // Use bold weight
|
||||
fontSize: 12.sp,
|
||||
height: _height,
|
||||
);
|
||||
|
||||
static TextStyle yekan11Bold = TextStyle(
|
||||
fontFamily: FontFamily.yekan,
|
||||
fontWeight: bold, // Use bold weight
|
||||
fontSize: 12.sp,
|
||||
height: _height,
|
||||
);
|
||||
|
||||
static TextStyle yekan10Bold = TextStyle(
|
||||
fontFamily: yekan,
|
||||
static TextStyle yekan10Bold = TextStyle(
|
||||
fontFamily: FontFamily.yekan,
|
||||
fontWeight: bold, // Use bold weight
|
||||
fontSize: 10.sp,
|
||||
height: _height,
|
||||
|
||||
@@ -1354,7 +1354,7 @@ packages:
|
||||
path: "packages/chicken"
|
||||
relative: true
|
||||
source: path
|
||||
version: "1.3.18"
|
||||
version: "1.3.20"
|
||||
rasadyar_core:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
|
||||
Reference in New Issue
Block a user