Open Source Contributhon Review (Flutter Contribution)
Sharing my experience contributing to the Flutter project over six weeks at the Open Source Contributhon. ๐โโ๏ธ๐โโ๏ธ
What is the Open Source Contributhon?

Source - oss.kr
The Open Source Contributhon is an open-source software program run by Korea's Ministry of Science and ICT, and its homepage describes it as follows.
Contributhon is a portmanteau of 'contribute' to open source and 'marathon'.
A program where you work on open source projects built on participation, sharing, openness, and collaboration with the guidance of senior developers, breaking through the barrier to entry of open source development and directly experiencing various contributions.
It focuses on the process rather than just quantity, and encourages contributing to open source culture through diverse activities, including not only code contributions but also code reviews, tests, bug reports, questions, feature suggestions, issue comments, proposals, and writing documentation.
It runs for six weeks in total with 26 projects, and to participate you apply by choosing the projects you want as your 1st, 2nd, and 3rd choices. You can see the full list of projects as of 2020 here. I had been deep into Flutter recently, so without a second of hesitation I applied with a project called Flutter Moum as my 1st, 2nd, and 3rd choices, and made it through the fierce competition to be selected as a mentee. ๐๐
Pre-training
Before the orientation, there was pre-training on Git and contribution, open on a first-come, first-served basis, taught by instructor Taewoong Song of Real Linux. (You can see the class materials here.)
I was late for the first-come, first-served signup and could only attend the second half of the class, but I got to practice rebase, which can change Git's history, and blame, which can trace who modified a given piece of source code, and even practiced sending a simple PR as a team and resolving conflicts.
It was also a rewarding session for learning general background on open source, such as commit message writing tips and the open source collaborative development process from a micro perspective. ๐๐
OT & Study
The Flutter Moum project ran with two mentors and 12 mentees contributing to Flutter together for six weeks. (In the past, the activity was developing Plugins used with Flutter as open source, but starting in 2020 it changed to contributing to Flutter itself ๐)
For the first two weeks, we studied setting up the Flutter development environment, how to contribute, how Flutter works internally, and how to submit a PR.
Activity Log
You can see all mentees' activity at Flutter Moum.

Contributing to the Flutter project works by picking an issue and sending a solution as a PR (Pull Request), and over four weeks I worked on a total of five PRs.
List of issues I worked on
- Closed ยท Add rowSpacing property to Table issue
- Merged ยท ReorderableListView list items jump down on dragging issue
- Merged ยท ReorderableListView dropping animation issue
- Closed ยท SwitchListTile.adaptive has splash effect on iOS & macOS issue
- Merged ยท Tab indicator flies off issue
1. [Closed] Add rowSpacing property to Table issue
โ๏ธ Issue : Padding inside Table #52248
โ๏ธ PR : [Table] adds rowSpacing property #63322
The first issue I worked on was adding a new property called rowSpacing to adjust the spacing between the TableRows of the Table Widget.

To add the rowSpacing property, I first analyzed how the Table Widget is implemented, and the theory about how Flutter works internally that my mentor taught in the first study session was a big help. While adding the property, I remembered that the Wrap Widget has a similar property called spacing, so I referred to it and added the rowSpacing property without trouble. For the test code too, I followed how spacing is tested and implemented it without major issues, then submitted the PR with before & after images.

Two days later, there was a negative comment saying this seemed similar to a past issue proposing a Spacing property for Column and Row, which was rejected because there are many alternatives and those two Widgets were already too complex. I worked hard to prepare and post a rebuttal, but another person also left a negative comment for a similar reason, and sadly my first PR was Closed.
What I learned and felt along the way
- Not every issue is verified, and just implementing and solving one doesn't mean it gets merged
- A label being attached doesn't make an issue a verified one
- It was my first PR, and I found it easier than expected by referring to the similar
spacingfeature in Wrap - If every PR were accepted, open source would become a mess, so I found the culture of reviewers voicing their opinions and debating refreshing
- It was a pity that my lack of English made me unsure about joining the discussion (it motivated me to study English)
- Picking meaningful issues likely to be merged seems more important than picking easy ones
- I learned that linking an issue within Github leaves a history below it

My mentor warned me to be careful, and I messed up the very next day.
2. [Merged] ReorderableListView list items jump down on dragging issue
โ๏ธ Issue : ReorderableListView list items jump down on dragging #58411
โ๏ธ PR : [ReorderableListView] remove extra margin added after picking up the item #65080
Second, I tackled the problem in ReorderableListView where the items below the selected item are pushed down when you pick it up. In the before image of the gif below, you can see that when C is picked up, space appears below C and items E ~ H get pushed down slightly.


The cause was _dropAreaMargin being added as a Margin below an item when it's picked up, and I confirmed the issue could be solved simply by setting that value to 0 or removing it.
However, when I removed that value or set it to 0, the two tests (horizontal, vertical) that check _dropAreaMargin is added correctly Failed, and since breaking or changing existing tests can lead to Breaking Changes, I posted a question, but got no answer for over 10 days.. Frustrated, I asked on Discord, and Alex Li advised me that since the priority was a relatively low P4, it would be faster to just submit the PR.

Encouraged, I got ready to submit the PR. Removing _dropAreaMargin seemed more right, but to avoid causing Breaking Changes, I chose a fix that gets the same result with as small a change as possible and submitted the PR.
A reviewer was assigned 12 days after I submitted the PR. Seven days later, as expected, they reviewed that fixing the issue by removing rather than modifying would be better, and additionally asked for a Golden Test. Switching to removal was fine, but I had never even heard the term Golden Test, which flustered me. Luckily some of the mentees had experience with Golden Tests and gave me various pieces of advice. After that, I referred to a fellow mentee's PR and other Golden Tests, and after some trial and error I was able to push the commit.
A Golden Test is a testing method that takes a screenshot and exports it as an image to test the UI. As shown below, you specify the Widget you want to export as an image in the test code, then run matchesGoldenFile() to export it.
await expectLater(
find.byType(RepaintBoundary),
matchesGoldenFile('test_name.subtest.subfile.png'),
);Then, if you run the test code with the --update-goldens option like flutter test --update-goldens test/foo/bar_test.dart, the images are exported to bin/cache/pkg/skia_goldens/packages/flutter/test/ under the Flutter project.
The images below were exported by running matchesGoldenFile() on a Widget with the second, blue item out of three picked up, to test whether space appears below an item when it's picked up in ReorderableListView.


I put the exported images in the PR's Description and pushed the commit, but a lint error occurred because I hadn't declared the Key as const in the test code. It was an error I could have caught locally by running flutter analyze --flutter-repo before pushing, but I forgot and took up the busy reviewers' time. ๐
After fixing the error and pushing again, on Saturday, September 12, 2020, I finally met the LGTM I'd only heard about, for the first time in my life. ๐๐๐

What I learned and felt along the way
- I realized that the people doing triage aren't reviewers
- For issues of relatively low priority (P4 or below), submitting a PR first makes things move faster
- Existing code or tests failing doesn't automatically mean
Breaking Changes - If there's no reply for a long time (over a week), pinging in the Discord hackers channel gets a quick response
- I experienced the Golden Test, which tests using images
- The existing tests are all treasures. I learned a lot from them about which tests to write and how
- Having a Google developer look at my code seems like a really rare opportunity
- I left out const in the final
Golden Test, causing a lint error, and when I ranflutter analyze --flutter-repolocally, I confirmed the same error occurred. I resolved to always run analyze before submitting a PR - Getting the LGTM felt like all my effort had been rewarded
3. [Merged] ReorderableListView dropping animation issue
โ๏ธ Issue : N/A
โ๏ธ PR : [ReorderableListView] Fix item dropping animation #64140
While writing the PR for the second issue, I noticed the animation when dropping an item in ReorderableListView looked unnatural, so I prepared a PR right away without a separate Issue. In the before image below, you can see that when item C is dropped, space briefly appears between B and C and then disappears.


My analysis found it was caused by the animation starting from 0.1 instead of 0 when an item is dropped, and since it was a very simple fix, I submitted the PR without separate test code.
However, a test is a feature that automatically checks whether future changes bring back problems already solved, so I was asked to add test code, and I pushed a commit adding code that tests the position when an item is dropped. After that, the reviewer didn't respond for over a week, so I pinged them on Discord, only to find out they were on vacation, and I felt very sorry. ๐
What I learned and felt along the way
- Before pinging, check on github or elsewhere whether the person might be on vacation
- I learned it's fine to send a PR right away for a problem you find, even without an issue
- Even a very small change should always come with a test
- I felt that test code is essential, especially in large projects
4. [Closed] SwitchListTile.adaptive has splash effect on iOS & macOS issue
โ๏ธ Issue : SwitchListTile.adaptive has splash effect on iOS #35399
โ๏ธ PR : [SwitchListTile.adaptive] Remove splash effect on iOS and macOS #65081
The fourth issue was that the SwitchListTile.adaptive Widget shows the Material Widget InkWell effect (splash effect) on iOS and macOS. iOS naturally has no InkWell effect, so I thought it was a valid fix and began analyzing the cause. SwitchListTile internally uses the ListTile Widget, and an InkWell was inside that Widget.
So I couldn't handle InkWell directly as an exception, and solved the problem by making the Theme's splashColor and highlightColor transparent only when running as adaptive and the platform is iOS or macOS.


In the before on the left, you can see a white Splash effect when clicking SwitchListTile.adaptive on iOS, while in the after, there's no particular effect when selecting the item.
I submitted the PR expecting to happily get an LGTM, but sure enough, LongCatIsLooong was assigned as Reviewer and commented, as below, that since SwitchListTile is a Material Widget, it should have a Splash effect like ListTile.

After receiving the comment and thinking about it, InkWell belongs to ListTile, and that Widget isn't implemented differently per platform, so implementing it differently per platform only in SwitchListTile, which uses it, seemed like a fundamentally wrong solution. In other words, I felt the problem could only be solved properly if Widgets like ListTile.adaptive or an iOS-specific CupertinoListTile existed.
On actual iOS, there's a separate component called UITableViewCell that plays the same role as ListTile, and there was already a discussion in #19228 about implementing a corresponding Widget. In the end, this issue grew out to involve the parent Widget, and work on it was put on hold.
What I learned and felt along the way
- I experienced the process of finding the root cause of a problem and a better solution through discussion
- I realized it's important to think more deeply and discuss before submitting a PR with a one-dimensional solution
- I learned that issues are also something to treat with reasonable suspicion
- It was nice for no reason that there were so many cat people
5. [Merged] Tab indicator flies off issue
โ๏ธ Issue : Tab indicator flies off when tabs are tapped in quick succession #48000
โ๏ธ PR : [Tabs] Fix tab indicator flies off #65463
The last issue I worked on was reported by Hixie, one of Flutter's main Contributors.

In the before below, if you tap 1 and then quickly tap 2, the Indicator of the Tab Widget disappears somewhere to the left and then comes back.


Analyzing the cause, the code that runs when a tab is selected while an animation is in progress was implemented incorrectly, and there was already code below that could replace that functionality. In the sample code Hixie provided, timeDilation was set for debugging to run all animations 10 times slower, yet you can see the indicator moves very fast, and the reason is in the code below.
In the problematic code, _currentRect is passed into Rect.lerp() and the result is assigned back to _currentRect, which makes the indicator move with acceleration.
_currentRect = Rect.lerp(targetRect, _currentRect ?? targetRect, _indexChangeProgress(controller));To help with understanding, I prepared sample code on DartPad.
import 'package:flutter/material.dart';
void main() {
var a = Rect.fromLTRB(0.0, 0.0, 0, 0);
var b = Rect.fromLTRB(0.0, 0.0, 0, 0);
var target = Rect.fromLTRB(100.0, 0.0, 0, 0);
var resultA = [];
var resultB = [];
for (double i=0; i < 1.0; i += 0.1) {
// case 1. normal
resultA.add(Rect.lerp(a, target, i).topLeft.dx);
// case 2. Put b in Rect.lerp and assign the result back to b
b = Rect.lerp(b, target, i);
resultB.add(b.topLeft.dx);
}
// case 1. normal
// [0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]
print(resultA);
// case 2. Put b in Rect.lerp and assign the result back to b
// [0, 10, 28, 49.6, 69.76, 84.88, 93.952, 98.1856, 99.63712, 99.963712, 100]
print(resultB);
}case 2 above is the problematic situation, where you can see the result doesn't increase linearly by 10 but rises sharply.
I also pinned down why it disappears from the screen, but I'll let the image below stand in for a detailed explanation.

I removed the unnecessary code and submitted the PR with only test code that verifies this problem works correctly.
However, I found an edge case where that code doesn't work correctly, and I discussed ideas with the reviewer to fix it. During that, the reviewer proposed a simple yet perfect algorithm, I implemented it and submitted the PR, and it was finally Merged.
What I learned and felt along the way
- My mentor said they had worked on Tabs before, and that there's a lot of incorrectly implemented code scattered around there. After seeing the incorrect code myself, I understood why the reviewers reviewed so picky, and realized how important their role is
- I learned how to write and share code snippets with DartPad
- It was the hardest issue so far, and I felt the importance of algorithms
Review
Open source contribution wasn't easy. Even setting up the initial development environment was hard, the English documentation, which you have to see as a barrier to entry, was enormous, and the first PR I painstakingly wrote after careful consideration of which issue to pick was rejected along with the issue. I had mistakenly believed that solving an issue meant it would be merged, so I'd gone for easy issues only and realized that wasn't the case. After that I judged which issues might get merged and sent PRs, but six weeks flew by in the meantime. The LGTM I'd only heard about already felt like a legendary word, and as the program neared its end, I'd often wonder, "Did I do anything meaningful?"
But comparing myself before and after open source work, my understanding of Github and Git improved remarkably, opening Flutter's internal source myself let me understand its inner workings more deeply than before, and I'd had little experience writing test code, but by referring to the abundant test code for similar cases, I naturally learned best practices for what testing is and how to do it. Also, realizing how rare an opportunity it is to have my code reviewed by excellent developers, I came to see that I had learned and received a great deal.
If I had jumped into the open source ecosystem alone, I would probably have given up at the environment setup stage. But thanks to the mentors' laser-accurate special lectures and fellow mentees who struggled and worked hard alongside me, I could keep going and finish.

People of all kinds of backgrounds from around the world gathering around their interest in the open source project Flutter, discussing and sharing code for a better Flutter, was very fresh, but I deeply regretted that my limited English kept me from having deeper conversations.
To share about four tips I learned over the six weeks of contributing:
- First, you need to know that issues are just problems or suggestions anyone posted based on their own thinking, and even the people who label issues can't deeply consider whether an issue is truly needed. So you have to judge for yourself whether an issue is valid.
- Second, always write test code, even when modifying or adding a small feature. At first I thought I'd do it when a reviewer asked me to add tests, but you'll almost always be asked for tests. And that turns an issue that would take one week into two, so I recommend writing test code right from the start.
- The third tip: if a reviewer hasn't looked at your issue for over a week, you can ping that reviewer in the Discord hackers channel to ask for a review. But before pinging, check their github account to see whether they're on vacation.
- The fourth tip: there's already a lot of code for features similar to the one you want to implement, so refer to that code and things go much more smoothly. It was especially helpful when writing test code. (Open source is actually a treasure chest ๐)
Finally, if you haven't experienced open source yet, I strongly recommend giving it a try ๐๐
p.s. 2020.09.17 The ReorderableListView dropping animation issue PR was finally Merged

p.s. 2020.09.29 The final winners were announced.. and we won the grand prize.. ๐

Comments