Need help for using moor in a Dart command-line app on linux #1334
-
Hi! I am a novice programmer without experience in Dart, Flutter or moor, which is definitely not the most promising background to start a project using these components. To slowly work my way up, my idea is to first create a command-line app with Dart and moor that i could eventually turn into a mobile app using flutter. Thank you - Matthias |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi Matthias, I can assure you that moor works perfectly fine without Flutter :) The "Getting started" section just puts an emphasis on Flutter because that will be relevant for the majority of users. The getting started page suggests adding two Flutter-only libraries, This is an adapted snippet from the getting started section that doesn't depend on any Flutter libraries, I hope it works for you: import 'package:moor/ffi.dart';
import 'package:moor/moor.dart';
import 'dart:io';
QueryExecutor _openConnection() {
return VmDatabase(File('/tmp/my_app.db'));
}
@UseMoor(tables: [Todos, Categories])
class MyDatabase extends _$MyDatabase {
// we tell the database where to store the data with this constructor
MyDatabase() : super(_openConnection());
@override
int get schemaVersion => 1;
} |
Beta Was this translation helpful? Give feedback.
Hi Matthias,
I can assure you that moor works perfectly fine without Flutter :) The "Getting started" section just puts an emphasis on Flutter because that will be relevant for the majority of users.
The getting started page suggests adding two Flutter-only libraries,
sqlite3_flutter_libs
andpath_provider
. The former is to include a compiled sqlite3 binary with your app, which only really makes sense for Flutter. The later is about picking a right path for a database on each platform.If you're on a Debian-based distro, you can just install
libsqlite3-dev
and ignoresqlite3_flutter_libs
(pretty much every distro has a package for sqlite3, you're looking for a package containinglibsqlite…