mobileapplicationPassvault/lib/api_provider/user_details_provider.dart

44 lines
1.2 KiB
Dart
Raw Normal View History

2024-04-12 05:23:32 +00:00
// ignore_for_file: non_constantidentifier_names
import 'package:dio/dio.dart';
import 'package:flutter/material.dart';
import 'package:flutter_passvault/constant/constantfile.dart';
import 'package:flutter_passvault/modelclasses/loginuserdata_model.dart';
import 'package:flutter_passvault/view_pages/shared_preferance.dart';
class LoginuserProvider extends ChangeNotifier {
final dio = Dio();
Loginusermodel? _serverResponse;
bool isLoading = false;
Loginusermodel? get message => _serverResponse;
Future<void> GetUsrResponse() async {
final dio = Dio();
String? authToken = await CustomSharedPreferences.getCustomValue();
dio.options.headers['Authorization'] = 'Bearer $authToken';
try {
final response = await dio.post(
"${ApiConstants.newKonectarurl}/details",
);
if (response.statusCode == 200) {
print('successful_user_Response() : ${response.data}');
_serverResponse = Loginusermodel.fromJson(response.data);
print('user_details_Response() : $_serverResponse');
notifyListeners();
} else {
print('Failed : ${response.statusCode}');
}
} catch (error) {
print('Failed : $error');
}
}
}