Get Box Collider size and center according to child colliders

I have a parent gameobject which has multiple child gameobjects with box colliders.
I want to make a box collider on my parent gameobject according to the child gameobject colliders.
Meaning the new box collider should cover all the child colliders and its bounds should be on the corner of the child colliders as well.

I have already gotten the size of my collider according to positions of my child colliders,
I just cant calculate the center value of the collider.

Here is my code till yet:

public List<BoxCollider> childColliders = new List<BoxCollider>();

    public Vector2 maxXpos;
    public Vector2 minXpos;
    public Vector2 maxYpos;
    public Vector2 minYpos;

    public float xDistance, yDistance;

    public void OnEnable()
    {
        xDistance = Vector3.Distance(maxXpos, minXpos);
        yDistance = Vector3.Distance(maxYpos, minYpos);

        GetComponent<BoxCollider>().size = new Vector3(xDistance, yDistance, 5);
    }

I have attached an image of what I am achieving right now.

((maxXpos + minXpos)/2f)-transform.position;
Edited because i forgot things.
Note that your logic probably would break if your child colliders are rotated in any way.

What would be the proper way of doing then ?

You would need to get all the corners of the child colliders and calculate the min/max/bounds from all these points.
But perhaps this is what you’re doing already.