如何在抽屉的扩展图块中对齐子标题?

flu*_*ter 1 dart flutter

我在.. ExpansionTile中有ListView一个。Drawer我希望子标题直接在其主标题下对齐,以下gif显示当前状态。

抽屉:希望子标题直接位于Item0下

Scaffold(
  appBar: AppBar(title: Text(title)),
  body: Center(child: Text('My Page!')),
  drawer: Drawer(
    // Add a ListView to the drawer. This ensures the user can scroll
    // through the options in the Drawer if there isn't enough vertical
    // space to fit everything.
    child: ListView(
      // Important: Remove any padding from the ListView.
      // padding: EdgeInsets.zero,
      children: <Widget>[
        DrawerHeader(
          child: Text('Drawer Header'),
          decoration: BoxDecoration(
            color: Colors.blue,
          ),
        ),
        ExpansionTile(
          title: Text('Item0'),
          children: <Widget>[
            Padding(
              padding: const EdgeInsets.all(8.0),
              child: Text('subHeading1'),
            ),
            Text('subheading2')
          ],
        ),
        ListTile(
          title: Text('Item 1'),
          onTap: () {
            // Update the state of the app
            // ...
            // Then close the drawer
            Navigator.pop(context);
          },
        ),
        ListTile(
          title: Text('Item 2'),
          onTap: () {
            // Update the state of the app
            // ...
            // Then close the drawer
            Navigator.pop(context);
          },
        ),
      ],
    ),
  ),
);
Run Code Online (Sandbox Code Playgroud)

anm*_*ail 6

这应该解决这个问题:

    ExpansionTile(
      title: Text('Item0'),
      children: <Widget>[
        Padding(
          padding: const EdgeInsets.symmetric(horizontal: 16.0),
          child: Align(
            alignment: Alignment.topLeft,
            child: Column(
              mainAxisSize: MainAxisSize.min,
              children: <Widget>[
                Text('subHeading1'),
                Text('subHeading2')
              ],
            ),
          ),
        ),
      ],
    ),
Run Code Online (Sandbox Code Playgroud)