如何更改原始代码以在我的SafeArea小部件中始终添加`top:false'?

发布于 2025-02-13 22:43:08 字数 749 浏览 0 评论 0原文

我想使用“ statusbarcolor:colors.thransparent”,在所有视图上,我都可以使用themedata来执行此操作,我必须使用Safearea(top:false),是的,是的,这是一个解决方案,但我必须使用safearea( top:false)在所有视图上,

 Widget build(BuildContext context) {
    return SafeArea(
      top: false,
.........

“在此处intraim

我找不到任何使用themedata的解决方案,所以我要么要去要在我拥有的所有视图上使用它,或者我将更改原始代码(safe_area.dart)。如果这样做,这就是我想要的,这完全适合我的情况。

问题=>更改原始代码是坏主意吗?还是好主意?在什么情况下,我们应该这样做,还是应该这样做?

I wanted to use "statusBarColor: Colors.transparent", on all views, I can do this with ThemeData besides, I have to use SafeArea(top: false,) like this, yeah this is a solution but I have to use SafeArea(top: false) on all view,

 Widget build(BuildContext context) {
    return SafeArea(
      top: false,
.........

enter image description here

I didn't find any solution with ThemeData, so I was either going to use it on all views I have or I was going to change the original code(safe_area.dart). If I do, this is what I want and this fits perfectly in my situation.

question => to change original code is bad idea ? or good idea ? in what case should we do this, or should we do it?
enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

逆夏时光 2025-02-20 22:43:08

始终添加top:false每当您调用safearea()
您可以创建自己的类,扩展 safearea

class mySafeArea extends SafeArea {
   Widget child;

  mySafeArea({
    Key? key,
    required this.child,
  }) : super(
            key: key,
            child: child,
            top: false,
            bottom: true,
            left: true,
            right: true,
            minimum: const EdgeInsets.all(0),
            maintainBottomViewPadding: false);
  @override
  Widget build(BuildContext context) {
    return SafeArea(child: child);
  }
}

然后调用mySafeArea()而不是safearea()

To always add top: false whenever you call a SafeArea(),
you can create your own class that extends SafeArea:

class mySafeArea extends SafeArea {
   Widget child;

  mySafeArea({
    Key? key,
    required this.child,
  }) : super(
            key: key,
            child: child,
            top: false,
            bottom: true,
            left: true,
            right: true,
            minimum: const EdgeInsets.all(0),
            maintainBottomViewPadding: false);
  @override
  Widget build(BuildContext context) {
    return SafeArea(child: child);
  }
}

Then call mySafeArea() instead of SafeArea()

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文