Flutter: how to adjust/override properties of the Flutter core code without copying entire files?

爷,独闯天下 提交于 2020-05-15 03:38:49

问题


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

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.

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?

Thanks!


回答1:


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

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 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


来源:https://stackoverflow.com/questions/53084411/flutter-how-to-adjust-override-properties-of-the-flutter-core-code-without-copy

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!