devstory

Le Tutoriel de Flutter Alignment

View more Tutorials:

Site d'apprentissage des langues gratuit:
Suivez-nous sur notre fanpage pour recevoir des notifications chaque fois qu'il y a de nouveaux articles. Facebook

1- Flutter Alignment

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)

2- Examples


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
    ),
  )
)

View more Tutorials: