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
| import 'dart:async'; | |
| import 'dart:io'; | |
| import 'package:built_collection/built_collection.dart'; | |
| import 'package:chopper/chopper.dart'; | |
| import 'package:flutter_translate/flutter_translate.dart'; | |
| import 'package:get/get.dart' as get_lib; | |
| import 'package:http/io_client.dart' as http; | |
| import '../model/user.dart'; |
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
| import 'package:hive/hive.dart'; | |
| import '../model/local/db_user.dart'; | |
| import '../model/user.dart'; | |
| import 'storage_service.dart'; | |
| /// Implementation of StorageService using Hive Key-Value DB | |
| class StorageServiceImpl implements StorageService { | |
| @override | |
| Future saveUser(User user) async { |
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
| import 'package:hive/hive.dart'; | |
| part 'db_user.g.dart'; | |
| // ignore_for_file: public_member_api_docs | |
| @HiveType(typeId: 1) | |
| class DBUser { | |
| DBUser(this.id, this.name); |
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
| import 'package:built_value/built_value.dart'; | |
| import 'package:built_value/serializer.dart'; | |
| import 'user_with_relations.dart'; | |
| part 'user.g.dart'; | |
| // ignore_for_file: public_member_api_docs | |
| abstract class User implements Built<User, UserBuilder> { |
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
| import 'dart:collection'; | |
| /// Basic Queue (LIFO) | |
| class QueueList<T> { | |
| final ListQueue<T> _list = ListQueue(); | |
| /// Is empty? | |
| bool get isEmpty => _list.isEmpty; | |
| /// Not empty? |
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
| import 'dart:collection'; | |
| /// Basic Stack (FIFO) | |
| class StackList<T> { | |
| final ListQueue<T> _list = ListQueue(); | |
| /// Is empty? | |
| bool get isEmpty => _list.isEmpty; | |
| /// Not empty? |
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
| import 'package:flutter/material.dart'; | |
| /// Dot divider for Calendar | |
| class DotDivider extends StatelessWidget { | |
| /// Constructor | |
| const DotDivider( | |
| {this.height = 1, this.color = Colors.black, this.countCoeff = 3}); | |
| /// Color of divider | |
| final Color color; |
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
| String mimeToExtension(String mime) { | |
| switch (mime.toLowerCase()) { | |
| case 'image/apng': | |
| return 'apng'; | |
| case 'image/bmp': | |
| return 'bmp'; | |
| case 'image/gif': | |
| return 'gif'; | |
| case 'image/x-icon': | |
| return 'ico'; |
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
| /// Implementation of StorageService using Hive Key-Value DB | |
| class StorageServiceImpl implements StorageService { | |
| @override | |
| Future saveUser(User user) async { | |
| final userToSave = DBUser( | |
| user.id, | |
| user.name, | |
| user.avatar); | |
| final usersBox = await Hive.openBox('user'); |
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 StorageService { | |
| /// Save user to D | |
| void saveUser(User user); | |
| /// Get user from DB | |
| Future<DBUser> getUser(); | |
| /// Stop all operations | |
| void stop(); | |
| } |