颤振的透明粘性页脚

时间:2018-04-20 06:03:16

标签: dart flutter

我是following this Stack Overflow post用于制作粘性页脚。页脚按需要执行,但有没有办法添加透明度,以便页脚后面的列表中的项目可见?

坚实的页脚 enter image description here

透明页脚

enter image description here

以下是制作实体页脚的所有代码

import 'package:flutter/material.dart';

void main() => runApp(new MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      home: new MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage();

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

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      body: new Column(
        children: <Widget>[
          new Expanded(
            child: new ListView.builder(
              itemCount: 200,
              itemBuilder: (context, index) {
                return new ListTile(
                  title: new Text("title $index"),
                );
              },
            ),
          ),
          new Container(
            height: 40.0,
            color: Colors.red,
          ),
        ],
      ),
    );
  }
}

1 个答案:

答案 0 :(得分:2)

您可以使用Stack在彼此的顶部显示小部件。

new Scaffold(
  body: new Stack(
    alignment: Alignment.bottomCenter
    children: [
      new ListView(...),
      new Container(height: 40.0, color: Colors.red),
    ],
  ),
),