Table des matières
Le Tutoriel de Flutter Alignment
View more Tutorials:


Alignment est utilisé pour définir la manière d'aligner la position d'un widget enfant à l'intérieur de son parent.

- TODO Link?
- TODO Link?
Alignment Constructor
const Alignment(
double x,
double y
)
Flutter place un système de coordonnées au centre du widget parent et vous pouvez créer un objet Alignment à partir des deux paramètres x et y pour décrire la manière d'aligner la position du widget enfant.

La classe Alignment définit certaines constantes correspondant à certaines positions courantes:

Constant | Define |
bottomCenter | Alignment(0.0, 1.0) |
bottomLeft | Alignment(-1.0, 1.0) |
bottomRight | Alignment(1.0, 1.0) |
center | Alignment(0.0, 0.0) |
centerLeft | Alignment(-1.0, 0.0) |
centerRight | Alignment(1.0, 0.0) |
topCenter | Alignment(0.0, -1.0) |
topLeft | Alignment(-1.0, -1.0) |
topRight | Alignment(1.0, -1.0) |

Container (
decoration: BoxDecoration (
image: const DecorationImage(
image: NetworkImage('https://s3.o7planning.com/images/tom-and-jerry.png'),
fit: BoxFit.cover,
)
),
margin: EdgeInsets.all(10),
alignment: Alignment.bottomLeft,
child: Text (
"Tom and Jerry",
style: TextStyle(
fontSize: 20,
color: Colors.red,
fontWeight: FontWeight.bold
),
)
)