Skip to content

Commit

Permalink
Admin repository initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Nailsonseat committed Feb 10, 2024
1 parent 726c5d0 commit 5a81236
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions frontend/lib/repositories/adminRepository.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import 'package:dio/dio.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:logger/logger.dart';
import '../models/admin.dart';

final adminRepositoryProvider = Provider<AdminRepository>((_) => AdminRepository());

class AdminRepository {
final _client = Dio(
BaseOptions(
baseUrl: 'http://10.0.2.2:3000',
),
);

final Logger _logger = Logger();

Future<Admin?> getAdminById(String id) async {
try {
final response = await _client.get('/admin/$id');
return Admin.fromJson(response.data);
} catch (e) {
_logger.e(e);
return null;
}
}
}

0 comments on commit 5a81236

Please sign in to comment.