首页 > 解决方案 > 像谷歌日历一样颤动底页

问题描述

我如何创建像谷歌日历这样的底页?(下图),我无法制作像图片中一样的头像。谁能帮帮我,谢谢。。

在此处输入图像描述

标签: flutter

解决方案


它可以通过使用堆栈小部件来实现

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

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

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: RaisedButton(
          onPressed: () {
            _settingModalBottomSheet();
          },
          child: Text('Show Bottom Sheet'),
        ),
      ),
    );
  }

  void _settingModalBottomSheet() {
    final double imageRadius = 50;
    showModalBottomSheet(
      context: context,
      backgroundColor: Colors.transparent,
      builder: (BuildContext bc) {
        return Column(
          mainAxisSize: MainAxisSize.min,
          children: [
            Stack(
              children: [
                Container(
                  margin: EdgeInsets.only(top: imageRadius),
                  padding: EdgeInsets.only(top: imageRadius),
                  decoration: BoxDecoration(
                    borderRadius: BorderRadius.only(
                      topLeft: Radius.circular(16),
                      topRight: Radius.circular(16),
                    ),
                    color: Colors.white,
                  ),
                  child: Column(
                    children: [
                      Text('asdfsdf asdfasdf'),
                      Row(
                        mainAxisAlignment: MainAxisAlignment.center,
                        children: [
                          IconButton(
                            icon: Icon(Icons.message),
                            onPressed: () {},
                          ),
                          SizedBox(
                            width: 16,
                          ),
                          IconButton(
                            icon: Icon(Icons.message),
                            onPressed: () {},
                          ),
                          SizedBox(
                            width: 16,
                          ),
                          IconButton(
                            icon: Icon(Icons.message),
                            onPressed: () {},
                          )
                        ],
                      ),
                    ],
                  ),
                ),
                Align(
                  alignment: Alignment.topCenter,
                  child: CircleAvatar(
                    radius: imageRadius,
                  ),
                ),
              ],
            )
          ],
        );
      },
    );
  }
}

推荐阅读