There is this rule called as Fajan's rule which states that with increasing size of the anion and with decreasing size of the cation ionic character of the compound decreases while the covalent character increases.
Here, since the cation is same in both the compounds, the size of the anion decides the nature of the compound. Size of chlorine being greater than fluorine, AlCl3 is covalent while AlF3 is ionic.