bible_core 0.1.0
bible_core: ^0.1.0 copied to clipboard
Core Bible controller, parsing, sources, and offline cache.
example/lib/main.dart
import 'package:flutter/material.dart';
import 'package:bible_core/bible_core.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({super.key});
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
late final BibleController controller;
@override
void initState() {
super.initState();
controller = BibleController(
sources: {
'it': 'https://api.getbible.net/v2/riveduta.json',
'ar': 'https://firebasestorage.googleapis.com/v0/b/milano-af4f2.appspot.com/o/Arabic%20Bible.json?alt=media&token=70aa1327-857e-4ed8-b823-4060c0db97bb',
},
initialLanguage: 'ar',
);
controller.loadBible();
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(title: const Text('bible_core example')),
body: AnimatedBuilder(
animation: controller,
builder: (context, _) {
if (controller.loading) {
return const Center(child: CircularProgressIndicator());
}
if (controller.hasError || controller.books.isEmpty) {
return const Center(child: Text('Error loading'));
}
final book = controller.books.first;
final verses = controller.chapterVerses(book, 1);
return ListView.builder(
itemCount: verses.length,
itemBuilder: (context, index) {
final v = verses[index];
return ListTile(
title: Text(v.text),
leading: Text('${v.verse}'),
);
},
);
},
),
),
);
}
}