抽屉页脚项目

Sw*_*bie 4 items footer drawer flutter

我的抽屉遇到了一些小问题,我在堆栈上搜索了这个问题的解决方案,并找到了解决方案,但在尝试之后,它对我不起作用!:) 我的想法是,我想把抽屉里的一些物品展示在它的最后!:)

Drawer(
    child: Container(
      decoration: BoxDecoration(color: Color(0xFF0098c2)),
      child: ListView(
        children: <Widget>[
          ListTile(
            title: Text(
              'Dealer',
              style: TextStyle(fontSize: 18.0, color: Colors.white),
            ),
            leading: Icon(
              Icons.person,
              size: 20.0,
              color: Colors.white,
            ),
            onTap: () {
              Navigator.pop(context);
              Navigator.of(context).push(new MaterialPageRoute(
                  builder: (context) => dealerBuilder()));
            },
          ),
          ListTile(
            title: Text(
              'Shuffler',
              style: TextStyle(fontSize: 18.0, color: Colors.white),
            ),
            leading: Icon(
              Icons.shuffle,
              size: 20.0,
              color: Colors.white,
            ),
            onTap: () {
              Navigator.pop(context);
              Navigator.of(context).push(new MaterialPageRoute(
                  builder: (context) => shufflerBuilder()));
            },
          ),
          ListTile(
            title: Text(
              'Mistakes',
              style: TextStyle(fontSize: 18.0, color: Colors.white),
            ),
            leading: Icon(
              Icons.info_outline,
              size: 20.0,
              color: Colors.white,
            ),
            onTap: () {
              Navigator.pop(context);
              Navigator.of(context).push(new MaterialPageRoute(
                  builder: (context) => mistakePage()));
            },
          ),
          ListTile(
            title: Text(
              'Important links',
              style: TextStyle(fontSize: 18.0, color: Colors.white),
            ),
            leading: Icon(
              Icons.border_color,
              size: 20.0,
              color: Colors.white,
            ),
            onTap: () {
              Navigator.of(context).push(new MaterialPageRoute(
                  builder: (context) => importantLinks()));
            },
          ),
          Container(
              child: Align(
                  alignment: FractionalOffset.bottomCenter,
                  child: Column(
                    children: <Widget>[
                      Divider(),
                      ListTile(
                          leading: Icon(Icons.settings),
                          title: Text('Facebook')),
                      ListTile(
                          leading: Icon(Icons.help),
                          title: Text('Instagram'))
                    ],
                  ))),
        ],
      ),
    ),
  ),
Run Code Online (Sandbox Code Playgroud)

这就是我抽屉里的代码,到目前为止它是这样显示的!这就是输出,但我想将其显示在底部

chu*_*han 12

您可以复制粘贴运行下面的完整代码
您可以替换ListViewColumn并将第一组包装为Expaned Column

 child: Column(
          children: <Widget>[
            Expanded(
              child: Column(children: <Widget>[
              ...
              Container(
                child: Align(
Run Code Online (Sandbox Code Playgroud)

工作演示

在此输入图像描述

完整代码

import 'package:flutter/material.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
        visualDensity: VisualDensity.adaptivePlatformDensity,
      ),
      home: MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);

  final String title;

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  int _counter = 0;

  void _incrementCounter() {
    setState(() {
      _counter++;
    });
  }

  @override
  Widget build(BuildContext context) {
    return SafeArea(
      child: Scaffold(
        appBar: AppBar(
          title: Text(widget.title),
        ),
        drawer: Drawer(
          child: Container(
            decoration: BoxDecoration(color: Color(0xFF0098c2)),
            child: Column(
              children: <Widget>[
                Expanded(
                  child: Column(children: <Widget>[
                    ListTile(
                      title: Text(
                        'Dealer',
                        style: TextStyle(fontSize: 18.0, color: Colors.white),
                      ),
                      leading: Icon(
                        Icons.person,
                        size: 20.0,
                        color: Colors.white,
                      ),
                      onTap: () {
                        /* Navigator.pop(context);
                      Navigator.of(context).push(new MaterialPageRoute(
                          builder: (context) => dealerBuilder()));*/
                      },
                    ),
                    ListTile(
                      title: Text(
                        'Shuffler',
                        style: TextStyle(fontSize: 18.0, color: Colors.white),
                      ),
                      leading: Icon(
                        Icons.shuffle,
                        size: 20.0,
                        color: Colors.white,
                      ),
                      onTap: () {
                        /*Navigator.pop(context);
                      Navigator.of(context).push(new MaterialPageRoute(
                          builder: (context) => shufflerBuilder()));*/
                      },
                    ),
                    ListTile(
                      title: Text(
                        'Mistakes',
                        style: TextStyle(fontSize: 18.0, color: Colors.white),
                      ),
                      leading: Icon(
                        Icons.info_outline,
                        size: 20.0,
                        color: Colors.white,
                      ),
                      onTap: () {
                        /* Navigator.pop(context);
                      Navigator.of(context).push(new MaterialPageRoute(
                          builder: (context) => mistakePage()));*/
                      },
                    ),
                    ListTile(
                      title: Text(
                        'Important links',
                        style: TextStyle(fontSize: 18.0, color: Colors.white),
                      ),
                      leading: Icon(
                        Icons.border_color,
                        size: 20.0,
                        color: Colors.white,
                      ),
                      onTap: () {
                        /*Navigator.of(context).push(new MaterialPageRoute(
                          builder: (context) => importantLinks()));*/
                      },
                    ),
                  ]),
                ),
                Container(
                    child: Align(
                        alignment: FractionalOffset.bottomCenter,
                        child: Column(
                          children: <Widget>[
                            Divider(),
                            ListTile(
                                leading: Icon(Icons.settings),
                                title: Text('Facebook')),
                            ListTile(
                                leading: Icon(Icons.help),
                                title: Text('Instagram'))
                          ],
                        ))),
              ],
            ),
          ),
        ),
        body: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              Text(
                'You have pushed the button this many times:',
              ),
              Text(
                '$_counter',
                style: Theme.of(context).textTheme.headline4,
              ),
            ],
          ),
        ),
        floatingActionButton: FloatingActionButton(
          onPressed: _incrementCounter,
          tooltip: 'Increment',
          child: Icon(Icons.add),
        ),
      ),
    );
  }
}
Run Code Online (Sandbox Code Playgroud)