flutterdart

How Do I Vertical Align Widgets Within A ListView Builder


I noticed that the ListView.builder doesn't support the mainAxisAlignment to vertically align widgets. I am trying to align the avatar image on my ListTile to the top. It is currently aligning in the middle. Here is my code:

body: ListView.builder(
    itemCount: 30,
    itemBuilder: (context, index) {
        return ListTile(
            titleAlignment: ,
            leading: ClipRRect(
                  borderRadius: BorderRadius.circular(22.0),
                  child: Image.asset(
                    'lib/images/pic1.jpg',
                     width: 44.0,
                    height: 44.0,
                      fit: BoxFit.fill,
                  ),
            ),
            title: Text('Capton Jack @xproject'),
            subtitle: Text('This is a whooping 76 KM road and no foolish soul is doing before n after like obidient ipob did over 3 KM road by Alex Otti over Aguiyi Ironsi Road in Abia.'),
        );
    }

  ),

UI Screenshot


Solution

  • You can set titleAlignment: ListTileTitleAlignment.top which vertically aligns the leading and trailing widgets of the ListTile to top.

    for more info ListTileTitleAlignment