Skip to content

Commit

Permalink
✨Introduce new features.
Browse files Browse the repository at this point in the history
  • Loading branch information
JarodJeffery committed Sep 22, 2024
1 parent b895330 commit 74274bb
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
7 changes: 7 additions & 0 deletions beakpeek/lib/Controller/DB/life_list_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -302,4 +302,11 @@ class LifeListProvider {
},
).toList();
}

Future<List<Map<String, Object?>>> getBirdInByID(int id) async {
final db = await instance.database;
final List<Map<String, Object?>> birdMap =
await db.query('allBirds', where: 'id = ?', whereArgs: [id]);
return birdMap;
}
}
7 changes: 7 additions & 0 deletions beakpeek/lib/Model/bird_page_functions.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// api_service.dart

import 'dart:convert';
import 'package:beakpeek/Controller/DB/life_list_provider.dart';
import 'package:http/http.dart' as http;

class ApiService {
Expand All @@ -14,6 +15,7 @@ class ApiService {
);

if (response.statusCode == 200) {
print(json.decode(response.body));
return json.decode(response.body);
} else {
// Handle the error
Expand All @@ -22,4 +24,9 @@ class ApiService {
return null;
}
}

Future<List<Map<String, Object?>>> fetchBirdInfoOffline(
LifeListProvider lifeList, int id) async {
return await lifeList.getBirdInByID(id);
}
}
1 change: 1 addition & 0 deletions beakpeek/lib/View/Bird/bird_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class _BirdPageState extends State<BirdPage> {
super.initState();
birdFuture =
ApiService().fetchBirdInfo(widget.commonGroup, widget.commonSpecies);
ApiService().fetchBirdInfoOffline(lifeList, widget.id);
}

void addToLifeList() {
Expand Down

0 comments on commit 74274bb

Please sign in to comment.