-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
726c5d0
commit 5a81236
Showing
1 changed file
with
26 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} | ||
} |