将容器用作MaterialApp / Scaffold的父容器时要注意的事项

问题描述 投票:-2回答:1

说我正在构建一个不需要Material设计元素的应用,并且使用容器作为父代。

使用MaterialApp / Scaffold时是否需要手动(布局)设置不必要的东西?

以下是我在使用容器作为父级时发现的一些意外行为:•文本小部件中的黄线(当使用脚手架时,这些线消失)•即使设置了约束,ClipRRect小部件也会占据全屏状态

flutter containers flutter-layout scaffold
1个回答
0
投票

Material类是用户界面的主要组成部分。将Material小部件用作父级并不意味着您被迫在整个应用程序中使用Material Design,您可以执行自己的自定义小部件,UI等。

作为官方文档的一部分:

The Material widget is responsible for:

Clipping: If clipBehavior is not Clip.none, Material clips its widget sub-tree to the shape specified by shape, type, and borderRadius. By default, clipBehavior is Clip.none for performance considerations.
Elevation: Material elevates its widget sub-tree on the Z axis by elevation pixels, and draws the appropriate shadow.
Ink effects: Material shows ink effects implemented by InkFeatures like InkSplash and InkHighlight below its children.

它还负责为文本提供默认样式(这就是为什么看到黄色下划线的原因。)>

仍然,请记住,您正在为移动客户端制作应用程序,因此,即使您决定采用MaterialApp

CupertinoApp开箱即用的一些最佳做法,使用自己的自定义Widgets >>等]在应用程序中的自己路径
© www.soinside.com 2019 - 2024. All rights reserved.