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'; | |
| import 'package:flutter_staggered_animations/flutter_staggered_animations.dart'; | |
| import 'package:smart_link/widgets/bubble.dart'; | |
| class Intro extends StatefulWidget { | |
| const Intro({Key? key}) : super(key: key); | |
| @override | |
| State<Intro> createState() => _IntroState(); | |
| } |
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'; | |
| import 'package:flutter_bloc/flutter_bloc.dart'; | |
| class ServiceSearchDelegate extends SearchDelegate<List<String>> { | |
| @override | |
| List<Widget> buildActions(BuildContext context) { | |
| return [ | |
| IconButton( | |
| icon: Icon(Icons.search), | |
| key: ValueKey('search'), |
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:dio/dio.dart'; | |
| class ElasticRemoteDataSourceImpl { | |
| final Dio dio; | |
| ElasticRemoteDataSourceImpl(this.dio); | |
| Future<List<String>> searchServices(String index, String query) async { | |
| const String ELASTIC_BASE_URL = 'http://localhost:9200/'; //Change this to your publish_address |
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
| Future<void> cacheUser(UserModel userModel) async { | |
| try { | |
| final CacheUserModel cacheUser = CacheUserModel( | |
| userModel.email, | |
| userModel.name, | |
| userModel.phone, | |
| userModel.role, | |
| ); | |
| //CACHE_BOX_NAME is any string key |
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 'cache_user_model.g.dart'; | |
| @HiveType(typeId: 1) | |
| class CacheUserModel extends HiveObject { | |
| @HiveField(0) | |
| final String email; | |
| @HiveField(1) |
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 CacheUserModel { | |
| final String email; | |
| final String name; | |
| final String phone; | |
| final String role; |
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
| Future<String> retrieveUserToken() async { | |
| try { | |
| final secureKey = await secureStorage.read(key: SECURE_STORAGE_KEY); | |
| List<int> encryptionKey = (json.decode(secureKey) as List<dynamic>).cast<int>(); | |
| final encryptedBox = await hive.openBox(BOX_NAME, encryptionKey: encryptionKey); | |
| String token = encryptedBox.get('token'); | |
| encryptedBox.close(); | |
| return token; |
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
| Future<void> saveUserToken(String token) async { | |
| try { | |
| //BOX_NAME is any string key for you box name. | |
| final secureKey = Hive.generateSecureKey(); | |
| final encryptedBox = await Hive.openBox(BOX_NAME, encryptionKey: secureKey); | |
| await encryptedBox.put('token', token); | |
| //SECURE_STORAGE_KEY is any string key. | |
| await secureStorage.write( | |
| key: SECURE_STORAGE_KEY, |
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
| Future<void> saveEventToHive() async { | |
| try { | |
| var box = Hive.openBox('first_box'); | |
| box.put('event', 'Cache User'); | |
| var event = box.get('event') | |
| box.close(); | |
| } on Exception catch (e) { | |
| throw CacheException(message: e.toString()); |
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
| void main() async { | |
| WidgetsFlutterBinding.ensureInitialized(); | |
| await Hive.initFlutter(); | |
| runApp(MyApp()); | |
| } | |
NewerOlder