Skip to content

Commit 83a695e

Browse files
author
DominicGBauer
committed
chore: add example changes
1 parent 9f3f7dc commit 83a695e

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

example/custom_functions_example.dart

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
1+
import 'dart:async';
12
import 'dart:io';
23
import 'dart:isolate';
34

5+
import 'package:sqlite3/common.dart';
46
import 'package:sqlite_async/sqlite_async.dart';
5-
import 'package:sqlite3/sqlite3.dart' as sqlite;
67

78
/// Since the functions need to be created on every SQLite connection,
89
/// we do this in a SqliteOpenFactory.
910
class TestOpenFactory extends DefaultSqliteOpenFactory {
1011
TestOpenFactory({required super.path, super.sqliteOptions});
1112

1213
@override
13-
sqlite.Database open(SqliteOpenOptions options) {
14-
final db = super.open(options);
14+
FutureOr<CommonDatabase> open(SqliteOpenOptions options) async {
15+
final db = await super.open(options);
1516

1617
db.createFunction(
1718
functionName: 'sleep',
18-
argumentCount: const sqlite.AllowedArgumentCount(1),
19+
argumentCount: const AllowedArgumentCount(1),
1920
function: (args) {
2021
final millis = args[0] as int;
2122
sleep(Duration(milliseconds: millis));
@@ -25,7 +26,7 @@ class TestOpenFactory extends DefaultSqliteOpenFactory {
2526

2627
db.createFunction(
2728
functionName: 'isolate_name',
28-
argumentCount: const sqlite.AllowedArgumentCount(0),
29+
argumentCount: const AllowedArgumentCount(0),
2930
function: (args) {
3031
return Isolate.current.debugName;
3132
},

example/linux_cli_example.dart

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1+
import 'dart:async';
12
import 'dart:ffi';
23

4+
import 'package:sqlite3/common.dart';
35
import 'package:sqlite_async/sqlite_async.dart';
46
import 'package:sqlite3/open.dart' as sqlite_open;
5-
import 'package:sqlite3/sqlite3.dart' as sqlite;
67

78
const defaultSqlitePath = 'libsqlite3.so.0';
89

@@ -16,7 +17,7 @@ class TestOpenFactory extends DefaultSqliteOpenFactory {
1617
this.sqlitePath = defaultSqlitePath});
1718

1819
@override
19-
sqlite.Database open(SqliteOpenOptions options) {
20+
FutureOr<CommonDatabase> open(SqliteOpenOptions options) async {
2021
// For details, see:
2122
// https://pub.dev/packages/sqlite3#manually-providing-sqlite3-libraries
2223
sqlite_open.open.overrideFor(sqlite_open.OperatingSystem.linux, () {

0 commit comments

Comments
 (0)