Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions lib/repository/conversation.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import 'package:dart_openai/dart_openai.dart';
import 'package:path/path.dart';
import 'package:sqflite/sqflite.dart';
import 'package:sqflite_common_ffi/sqflite_ffi.dart';
import 'package:platform/platform.dart';

class Conversation {
String name;
Expand Down Expand Up @@ -82,6 +84,12 @@ class ConversationRepository {

Future<Database> _getDb() async {
if (_database == null) {
const Platform platform = LocalPlatform();
if (platform.isWindows || platform.isLinux || platform.isMacOS) {
// Initialize FFI
sqfliteFfiInit();
databaseFactory = databaseFactoryFfi;
}
final String path = join(await getDatabasesPath(), 'chatgpt.db');
_database = await openDatabase(path, version: 1,
onCreate: (Database db, int version) async {
Expand Down
24 changes: 24 additions & 0 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -645,6 +645,22 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.4.5"
sqflite_common_ffi:
dependency: "direct main"
description:
name: sqflite_common_ffi
sha256: f86de82d37403af491b21920a696b19f01465b596f545d1acd4d29a0a72418ad
url: "https://pub.dev"
source: hosted
version: "2.2.5"
sqlite3:
dependency: transitive
description:
name: sqlite3
sha256: f7511ddd6a2dda8ded9d849f8a925bb6020e0faa59db2443debc18d484e59401
url: "https://pub.dev"
source: hosted
version: "2.0.0"
stack_trace:
dependency: transitive
description:
Expand Down Expand Up @@ -829,6 +845,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.1.0"
web:
dependency: transitive
description:
name: web
sha256: dc8ccd225a2005c1be616fe02951e2e342092edf968cf0844220383757ef8f10
url: "https://pub.dev"
source: hosted
version: "0.1.4-beta"
win32:
dependency: transitive
description:
Expand Down
1 change: 1 addition & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ dependencies:
flex_color_scheme: ^7.0.5
get_storage: ^2.1.1
dart_openai: ^1.9.92
sqflite_common_ffi: ^2.2.5

dev_dependencies:
flutter_test:
Expand Down
5 changes: 5 additions & 0 deletions windows/runner/flutter_window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ bool FlutterWindow::OnCreate() {
this->Show();
});

// Flutter can complete the first frame before the "show window" callback is
// registered. The following call ensures a frame is pending to ensure the
// window is shown. It is a no-op if the first frame hasn't completed yet.
flutter_controller_->ForceRedraw();

return true;
}

Expand Down