Here, I make the flags slightly larger, and create \Worldflag
macro which sets the flag's upper extent to a height of \ht\strutbox
above the baseline.
\documentclass{article}
\usepackage[a4paper,margin=0.1cm]{geometry}
\usepackage{tabularray}
\usepackage{worldflags}
\usepackage{stackengine}
\flagsdefault[width=1.9\baselineskip]
\newcommand\Worldflag[1]{\belowbaseline[-\ht\strutbox]{\worldflag{#1}}}
\begin{document}
\begin{longtblr}{ colspec = {|X|X|},hlines}
First variable \newline Second variable & \Worldflag{FR} \\
First variable & \Worldflag{BR} \\
First variable \newline Second variable & \Worldflag{CH} \\
\end{longtblr}
\end{document}
ADDENDUM
The OP asks how to achieve a similar effect when the flags are made smaller?
Here, I make the flags smaller, add a vertical buffer above and below each flag, via \addstackgap[.6\ht\strutbox]{...}
and also adjust the vertical shift of the \belowbaseline
. While the particular values can be adjusted, I recommend that the stackgap minus the belowbaseline shift add up to \ht\strutbox
.
\documentclass{article}
\usepackage[a4paper,margin=0.1cm]{geometry}
\usepackage{tabularray}
\usepackage{worldflags}
\usepackage{stackengine}
\flagsdefault[width=1\baselineskip]
\newcommand\Worldflag[1]{\addstackgap[.6\ht\strutbox]{%
\belowbaseline[-0.4\ht\strutbox]{\worldflag{#1}}}}
\begin{document}
\begin{longtblr}{ colspec = {|X|X|},hlines}
First variable \newline Second variable & \Worldflag{FR} \\
First variable & \Worldflag{BR} \\
First variable \newline Second variable & \Worldflag{CH} \\
\end{longtblr}
\end{document}