Flutter:如何在不复制整个文件的情况下调整/覆盖Flutter核心代码的属性? [英] Flutter: how to adjust/override properties of the Flutter core code without copying entire files?

查看:112
本文介绍了Flutter:如何在不复制整个文件的情况下调整/覆盖Flutter核心代码的属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此问题与以下StackOverflow问题有关:底页,其初始高度为屏幕的一半,如果滚动,则高度会增加到全屏

This question is related to the following StackOverflow issue: bottom sheet with initial height half of screen and if it scroll then height is increase to full screen

是关于Flutter代码在底部表格中设置的约束,我不希望这样。我了解上面链接中提到的解决方案,但是我不知道如何以一种很好的方式来实现它。

It is about a constraint that is set within the Flutter code about bottom sheets, that I do not want to have. I understand the solution mentioned in the link above, but I don't know how to implement it in a nice way.

现在,我的解决方案是从官方Flutter代码库中完全复制bottom_sheet.dart文件,并删除带有maxHeight属性的行169: https://github.com/flutter/ flutter / blob / 1ad538e454c77496fbd068b9e8b5f8b61c2f6d96 / packages / flutter / lib / src / material / bottom_sheet.dart#L169

Right now my 'solution' is to completely copy the bottom_sheet.dart file from the official Flutter codebase and remove just the line 169 with the maxHeight property: https://github.com/flutter/flutter/blob/1ad538e454c77496fbd068b9e8b5f8b61c2f6d96/packages/flutter/lib/src/material/bottom_sheet.dart#L169

任何以更优雅的方式做到这一点的想法?

Any ideas to do this in a more elegant way?

谢谢!

推荐答案

您不能。如果要更改源,则必须克隆源。

You can't. You have to clone the sources if you want to make a change to them.

这部分是自愿的。 Flutter的目的是让您轻松地复制源代码并进行一些更改。

This is partially voluntary. Flutter is purposefully designed to easily let you copy the sources and make some changes.

如果这对解决方案来说太糟糕了,

If that's too bad of a solution, you can instead fork flutter.

Flutter很容易分叉,因为安装过程只不过是一个简单的git clone:

Flutter is very easy to fork, as the installation process is nothing but a simple git clone:

  • go to http://github.com/flutter/flutter
  • click on fork
  • replace your local SDK with this fork
  • make your change to the sources

这篇关于Flutter:如何在不复制整个文件的情况下调整/覆盖Flutter核心代码的属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆