Untitled

mail@pastecode.io avatar
unknown
plain_text
6 months ago
963 B
2
Indexable
Never
import 'dart:convert';

import 'package:old_barrel/constant/api_strings.dart';
import 'package:old_barrel/custom_widgets/app_prefrence.dart';
import '../custom_widgets/commom_indicator.dart';
import '../models/login_model.dart';
import 'package:dio/dio.dart';

class LoginImpl {
  final Dio _dio = Dio();

  Future<LoginModel?> LoginFun({
    String? mobileno,
    String? otp,
  }) async {
    try {
      showLoadingIndicator();
      _dio.options.headers['content-Type'] = 'multipart/form-data';
      var data = FormData.fromMap({
        "mobileno": mobileno,
        "user_given_otp": otp,
      });
/*      showLoadingIndicator();*/
      final Response response = await _dio.post(
        '${ApiStrings.login}',
        data: data,
      );
      print("login response  ${response.data}");

      AppPreference.set('login', true);

      return LoginModel.fromJson(json.decode(response.data));
    } catch (e) {
      print("-----------${e}");
    }
  }
}
Leave a Comment