\documentclass{article}

%Generate text
\usepackage{blindtext}


\usepackage{changepage}
%\qed

\usepackage{amsmath}
\usepackage{amssymb}

%Show the labels
\usepackage[right]{showlabels}


%Numbering of examples.
\newcounter{ExampleNo}[section]

%Add example numbering (by section)
%Indent and decrease font.
%Add square to end of example.

%Argumentos: title and ref
\newenvironment{Example}[2]
{
%start with empty line to force line break
%empty line much better that \\ or \newline

   \vspace{10pt}
   \stepcounter{ExampleNo}
   \underline{\textbf{Example \thesection.\theExampleNo:}}
   \label{Example:#2} 
   \textit{#1}.
   
   \vspace{5pt}
   \begin{adjustwidth}{20pt}{0pt}
      \begin{small}
}
{ 
       \end{small}
       
       \hfill$\blacksquare$
   \end{adjustwidth}
   
   
   \vspace{10pt}
}

\begin{document}

\section{Introduction}

\blindtext
\begin{Example}{A Pythagorean Triangle}{pythagoras1}
   \blindtext
\end{Example}
\blindtext

\section{Geometria Esférica}

\blindtext
\begin{Example}{Another Pythagorean Triangle}{pythagoras2}
   See Example \ref{Example:pythagoras1} page \pageref{Example:pythagoras1}.
   
   
   \blindtext
\end{Example}
\blindtext

\end{document}
