Shows username on listtile
This commit is contained in:
@@ -9,6 +9,8 @@ import '../models/checklist.dart';
|
||||
import '../models/listitem.dart';
|
||||
import 'package:provider/provider.dart' as provider;
|
||||
|
||||
import '../models/profile.dart';
|
||||
|
||||
class DbHelper {
|
||||
static const checkedItemsTableName = 'checkedItems';
|
||||
static const checklistsTableName = 'checklists';
|
||||
@@ -76,6 +78,22 @@ class DbHelper {
|
||||
return itemIdList;
|
||||
}
|
||||
|
||||
static Future<List<Profile>> fetchProfiles() async {
|
||||
List<Profile> profiles = [];
|
||||
final res = await _client
|
||||
.from(profilesTableName)
|
||||
.select<List<Map<String, dynamic>>>();
|
||||
for (final element in res) {
|
||||
profiles.add(Profile(
|
||||
id: element['id'],
|
||||
username: element['username'],
|
||||
language: element['language'] ?? '',
|
||||
bio: element['bio'] ?? '',
|
||||
));
|
||||
}
|
||||
return profiles;
|
||||
}
|
||||
|
||||
static Future<void> insertCheckedEntry(int checklistId, int itemId) async {
|
||||
final ownerId = _client.auth.currentSession!.user.id;
|
||||
await _client.from(checkedItemsTableName).insert({
|
||||
|
||||
18
lib/services/profile_provider.dart
Normal file
18
lib/services/profile_provider.dart
Normal file
@@ -0,0 +1,18 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../models/profile.dart';
|
||||
|
||||
class ProfileProvider extends ChangeNotifier {
|
||||
List<Profile> _profiles = [];
|
||||
|
||||
void updateProfiles(List<Profile> profiles, {bool silent = false}) {
|
||||
_profiles = profiles;
|
||||
if (!silent) notifyListeners();
|
||||
}
|
||||
|
||||
Profile? getProfileById(String id) {
|
||||
if (_profiles.isEmpty) return null;
|
||||
final profile = _profiles.where((element) => element.id == id).first;
|
||||
return profile;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user