Share
Sign In
공부 내용
flutter - hive(로컬 저장소 NoSQL)
Y
yeji Kim
👍
참고 자료
dependencies: hive: ^2.2.3 hive_flutter: ^1.1.0 dev_dependencies: build_runner: ^2.4.7 hive_generator: ^2.0.1
await Hive.initFlutter(); void main() async { await Hive.initFlutter(); runApp(const MyApp()); }
await Hive.openBox("openBox"); Hive.openLazyBox("openBox"); Hive.openBox("person"); Box box = Hive.box("person"); box.put("name", "tyger"); box.put("age", 20); box.add("tyger1"); print(box.values); // (tyger1, 20, tyger) print(box.keys); // (0, age, name) print(box.get("name")); // tyger print(box.get("age")); // 20 print(box.get("birthday", defaultValue: 20230101)); // 20230101 Box box = Hive.box("person"); box.deleteAll(["name", "age"]); Box box = Hive.box("person"); box.put("name", "tyger"); print(box.get("name")); // tyger
Box box = Hive.box("person"); box.put("person", { "name": "tyger", "age": 20, }); final person = box.get("person"); print(person); print(person["name"]); // {name: tyger, age: 20} // tyger box.putAll({ "person1": { "name": "tyger1", "age": 30, }, "person2": { "name": "tyger2", "age": 40, }, }); print(box.values); // {name: tyger, age: 20}, {name: tyger1, age: 30}, {name: tyger2, age: 40} List<dynamic> query = box.values.where((e) => e["age"] == 30).toList(); print(query); // [{name: tyger1, age: 30}]
part 'car.g.dart'; @HiveType(typeId: 1) class Car { @HiveField(0) int number; @HiveField(1) Brand type; @HiveField(2) String name; @HiveField(3) List<String> colors; @HiveField(4) bool isRoof; Car({ required this.number, required this.brand, required this.name, required this.colors, required this.isRoof, }); @override String toString() => "Car(number: $number, brand: $brand, name: $name, colors: $colors, isRoof: $isRoof)"; } Hive.registerAdapter(CarAdapter()); Box box = Hive.box("car_factory"); box.addAll(cars); print(box.values);
ValueListenableBuilder<Box>( valueListenable: Hive.box("car_factory").listenable(), builder: (BuildContext context, Box value, Widget? child) { ... }),
Subscribe to '아무튼-작업일지'
Welcome to '아무튼-작업일지'!
By subscribing to my site, you'll be the first to receive notifications and emails about the latest updates, including new posts.
Join SlashPage and subscribe to '아무튼-작업일지'!
Subscribe
👍
Other posts in '공부 내용'See all
yeji Kim
참고 자료 백엔드 AndroidManifest.xml AWS 서버 AWS 서버 구축 Putty 연결 Flutter - 서버 연동 사전 준비 - node.js class ScheduleProvider extends ChangeNotifier Copywith class ScheduleRepository Dio Dismissible
참고 자료 백엔드 AndroidManifest.xml AWS 서버 AWS 서버 구축 Putty 연결 Flutter - 서버 연동 사전 준비 - node.js class ScheduleProvider extends ChangeNotifier Copywith class ScheduleRepository Dio Dismissible
yeji Kim
flutter speech to text
https://www.youtube.com/watch?v=IiYeppojd_Y&list=PLxefhmF0pcPlMKc8tPgYmYXXShh8P_8al&index=9 python model - flutter App To use a deep learning model trained in Python within a Flutter app, you can follow these general steps: Train and Save the Model in Python: Train your speech-to-text model using Python. Save the model to a file format that can be loaded later (e.g., TensorFlow SavedModel, PyTorch model, etc.). Set Up a Backend Server: Set up a backend server using a framework like Flask, Django, or FastAPI. The backend server will load the trained model and provide an API endpoint to handle requests from the Flutter app. The server will process audio files sent from the Flutter app, apply the speech-to-text model, and return the transcriptions. Flutter App: Develop the Flutter app to record audio, send the audio file to the backend server, and display the transcription results. Here is a step-by-step guide: Step 1: Train and Save the Model in Python Assuming you have already trained your model, save it to a file. For example, using TensorFlow: Step 2: Set Up the Backend Server Set up a Flask server as an example: Create a server.py file: Step 3: Develop the Flutter App Add dependencies to pubspec.yaml: Create the Flutter UI to record audio and send it to the backend server:
yeji Kim
Flutter sound
StreamSubscription https://jutole.tistory.com/73 WEbSocketChannel.connect _recorderSubscription _recorder!.startRecorder(toFile: ~, codec: );