This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| test('Cache Model & Encryption', () async { | |
| final model = ItemModel(id: 1345); | |
| final crypto = EncrypData(); | |
| final directory = await getApplicationDocumentsDirectory(); | |
| await Directory('${directory.path}').create(); | |
| await Directory('${directory.path}/vb2').create(); | |
| final path = '${directory.path}/vb2/${model.title}.json'; | |
| final file = File(path); | |
| final modelValuesWithCrypto = crypto.crypteFile(model.toString()); | |
| await file.writeAsString(modelValuesWithCrypto); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class EncrypData implements IEncrypData { | |
| late final Key key; | |
| late final IV iv; | |
| final String _privateKey = 'privateKey'; | |
| final String _privateINV = 'privateINV'; | |
| EncrypData() { | |
| key = Key.fromUtf8(dotenv.env[_privateKey] ?? ''); | |
| iv = IV.fromUtf8(utf8.decode((dotenv.env[_privateINV] ?? '').codeUnits)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| test('Cache Model In File', () async { | |
| final model = ItemModel(id: 1345); | |
| final directory = await getApplicationDocumentsDirectory(); | |
| await Directory('${directory.path}').create(); | |
| await Directory('${directory.path}/vb2').create(); | |
| final path = '${directory.path}/vb2/${model.title}.jso'; | |
| final file = File(path); | |
| final fileWithData = await file.writeAsString(model.toString()); | |
| expect(await fileWithData.exists(), true); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| test('Fetch Pdf And Cache', () async { | |
| final response = await manager.downloadFileSimple('http://www.africau.edu/images/default/sample.pdf', null); | |
| final directory = await getApplicationDocumentsDirectory(); | |
| await Directory('${directory.path}').create(); | |
| await Directory('${directory.path}/vb2').create(); | |
| final path = '${directory.path}/vb2/1.pdf'; | |
| final file = File(path); | |
| final fileWithData = await file.writeAsBytes(response.data!); | |
| expect(await fileWithData.exists(), true); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| abstract class IHomeService { | |
| final INetworkManager manager; | |
| IHomeService(this.manager); | |
| Future<List<ItemModel>> fetchItem(); | |
| Future<Uint8List?> downloadFile(String url, ProgressCallback callback); | |
| } | |
| enum _HomeServicePath { CACHE } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class LocaleManager { | |
| static final LocaleManager _instance = LocaleManager._init(); | |
| SharedPreferences? _preferences; | |
| static LocaleManager get instance => _instance; | |
| /// [SharedPreferences] init constructor. | |
| LocaleManager._init() { | |
| SharedPreferences.getInstance().then((value) { | |
| _preferences = value; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| extension StringExtension on String { | |
| bool validateMinLenght([double value = 6]) { | |
| return this.length > value; | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| extension ListViewExtension on ListView { | |
| Widget onLazyLoads(Future<void> Function() onPagingLoad, {Widget? itemLoadWidget}) { | |
| final delegate = childrenDelegate as SliverChildBuilderDelegate; | |
| final itemCount = delegate.childCount ?? 0; | |
| return NotificationListener<ScrollNotification>( | |
| onNotification: (ScrollNotification notification) { | |
| if (notification.metrics.pixels == notification.metrics.maxScrollExtent) { | |
| onPagingLoad(); | |
| } | |
| return true; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| enum NetworkPath { LOGIN, BUILD_HOME } | |
| extension NetworkPath on NetworkRoutes { | |
| String get rawValue { | |
| switch (this) { | |
| case NetworkRoutes.LOGIN: | |
| return 'login'; | |
| case NetworkRoutes.BUILD_HOME: | |
| return 'house'; | |
| default: |