You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Le fichier qui corrige le problème de non recopie du fichier bible.db est le suivant :
bibleDbProvider.dart
import 'dart:io';
import 'package:path/path.dart';
import 'package:sqflite/sqflite.dart';
import 'package:flutter/services.dart';
import 'package:path_provider/path_provider.dart';
class BibleDbSqfProvider {
static final _databaseName = "bible.db";
// make this a singleton class
BibleDbSqfProvider._privateConstructor();
static final BibleDbSqfProvider instance = BibleDbSqfProvider._privateConstructor();
Database? db;
Future ensureDatabase() async {
if (db == null) {
var databasesPath = await getApplicationDocumentsDirectory();
var path = join(databasesPath.path, databaseName);
// Check if the database exists
if (FileSystemEntity.typeSync(path) == FileSystemEntityType.notFound){
// Should happen only the first time you launch your application
print("Creating new copy from asset");
// Make sure the parent directory exists
try {
await Directory(dirname(path)).create(recursive: true);
} catch () {}
// Copy from asset
ByteData data = await rootBundle.load(join("assets/", _databaseName));
List bytes =
data.buffer.asUint8List(data.offsetInBytes, data.lengthInBytes);
// Write and flush the bytes written
await File(path).writeAsBytes(bytes, flush: true);
} else {}
print('SQLite3.open Bible db');
this.db = await databaseFactory.openDatabase(path);
print('Bible db = ${this.db.hashCode}');
}
}
Sur Android et Windows l'IHM n'apparait pas. Le correctif est le suivant :
Dans le fichier main.dart il faut rajouter MaterialApp comme ci après
void main() {
runApp(MaterialApp(
home: MyApp(storage: ChapterStorage('assets/bible/gn1.txt'))));
// Initialize FFI
sqfliteFfiInit();
// Change the default factory
databaseFactory = databaseFactoryFfi;
// Initialize database
ensureDatabase();
}
Cordialement.
Merci pour votre travail sur AELF.
Alain CRESSOT
The text was updated successfully, but these errors were encountered:
Le fichier qui corrige le problème de non recopie du fichier bible.db est le suivant :
bibleDbProvider.dart
import 'dart:io';
import 'package:path/path.dart';
import 'package:sqflite/sqflite.dart';
import 'package:flutter/services.dart';
import 'package:path_provider/path_provider.dart';
class BibleDbSqfProvider {
static final _databaseName = "bible.db";
// make this a singleton class
BibleDbSqfProvider._privateConstructor();
static final BibleDbSqfProvider instance = BibleDbSqfProvider._privateConstructor();
Database? db;
Future ensureDatabase() async {
if (db == null) {
var databasesPath = await getApplicationDocumentsDirectory();
var path = join(databasesPath.path, databaseName);
// Check if the database exists
if (FileSystemEntity.typeSync(path) == FileSystemEntityType.notFound){
// Should happen only the first time you launch your application
print("Creating new copy from asset");
// Make sure the parent directory exists
try {
await Directory(dirname(path)).create(recursive: true);
} catch () {}
// Copy from asset
ByteData data = await rootBundle.load(join("assets/", _databaseName));
List bytes =
data.buffer.asUint8List(data.offsetInBytes, data.lengthInBytes);
// Write and flush the bytes written
await File(path).writeAsBytes(bytes, flush: true);
} else {}
print('SQLite3.open Bible db');
this.db = await databaseFactory.openDatabase(path);
print('Bible db = ${this.db.hashCode}');
}
}
Database? getDatabase() {
assert(this.db != null);
return db;
}
}
Sur Android et Windows l'IHM n'apparait pas. Le correctif est le suivant :
Dans le fichier main.dart il faut rajouter MaterialApp comme ci après
void main() {
runApp(MaterialApp(
home: MyApp(storage: ChapterStorage('assets/bible/gn1.txt'))));
// Initialize FFI
sqfliteFfiInit();
// Change the default factory
databaseFactory = databaseFactoryFfi;
// Initialize database
ensureDatabase();
}
Cordialement.
Merci pour votre travail sur AELF.
Alain CRESSOT
The text was updated successfully, but these errors were encountered: