// ignore_for_file: use_build_context_synchronously

import 'package:byod/models/address_user.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter_bloc/flutter_bloc.dart';

import '../api/api.dart';
import 'branch_list.dart';

class AddressUser extends Cubit<Address> {
  AddressUser()
      : super(
          Address(
            id: '',
            label: '',
            address: '',
            locationDetail: '',
            lat: '',
            long: '',
            recepientName: '',
            recepientPhone: '',
            notes: '',
          ),
        );
  void getAddressUser(BuildContext context,
      {bool isGetBranchList = false, isCallDeliveryCharge = true}) async {
    var resultAddress =
        await Api.getAddress(isCallDeliveryCharge: isCallDeliveryCharge);
    if (isGetBranchList) {
      context.read<BranchList>().getBranchList();
    }
    emit(resultAddress);
  }
}
