高程不适用于颤动材料

时间:2018-11-14 11:32:31

标签: dart flutter material-design flutter-layout scaffold

我想制作一个看起来像Shrine App的应用,并将该切片放在角落。我可以制作幻灯片,但我的应用程序没有阴影。

我将我的前层包裹在一个具有高程的材料杂物盒中,如示例MDC-104所示。

这是我要剪切的代码

import 'package:flutter/material.dart';

class ShapeLayer extends StatelessWidget {
  final Widget frontLayer;
  final Widget backLayer = Container(
    color: Colors.green,
  );

  ShapeLayer({Key key, this.frontLayer}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Stack(
      children: <Widget>[
        backLayer,
        Material(
          elevation: 60.0,
          shape: BeveledRectangleBorder(
            borderRadius: BorderRadius.only(topLeft: Radius.circular(46.0)),
          ),
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.stretch,
            children: <Widget>[
              Expanded(child: frontLayer),
            ],
          ),
        ),
      ],
    );
  }
}

我这样使用它:

return Scaffold(
  appBar: appBar,
  body: ShapeLayer(frontLayer: Container(//Some stuff here)

它看起来像这样: My App

如您所见,它看起来很平坦,根本没有高程。

我该如何解决?

谢谢!

编辑:正如@SnakeyHips所建议的,这是我的海拔高度为16.0的应用程序

elevation 16.0

1 个答案:

答案 0 :(得分:0)

将海拔高度从60.0更改为16.0可以做到:

import 'package:flutter/material.dart';

class ShapeLayer extends StatelessWidget {
  final Widget frontLayer;
  final Widget backLayer = Container(
    color: Colors.green,
  );

  ShapeLayer({Key key, this.frontLayer}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Stack(
      children: <Widget>[
        backLayer,
        Material(
          elevation: 16.0,
          shape: BeveledRectangleBorder(
            borderRadius: BorderRadius.only(topLeft: Radius.circular(46.0)),
          ),
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.stretch,
            children: <Widget>[
              Expanded(child: frontLayer),
            ],
          ),
        ),
      ],
    );
  }
}