Skip to content

Commit c6c9318

Browse files
authored
Update contributing guidelines for repository (#2500)
Update contributing guidelines to reflect new policies for 2025. Related to #2497, but does not complete it. ## Pre-launch Checklist - [x] I read the [Flutter Style Guide] _recently_, and have followed its advice. - [x] I signed the [CLA]. - [x] I read the [Contributors Guide]. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] All existing and new tests are passing.
1 parent 16c3c02 commit c6c9318

File tree

1 file changed

+209
-74
lines changed

1 file changed

+209
-74
lines changed

CONTRIBUTING.md

Lines changed: 209 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,45 @@
11
# Contributing
22

3-
_See also: [Flutter's code of conduct](https://github.com/flutter/flutter/blob/master/CODE_OF_CONDUCT.md)_
4-
53
Want to contribute to the Flutter sample ecosystem? Great! First, read this
64
page (including the small print at the end).
75

8-
## Is this the right place for your contribution?
6+
Do you work at Google? Great! You should **definitely** read this page before submitting a PR :)
7+
8+
* [Before you contribute]
9+
* [Contribute enhancements and fixes]
10+
* [Write a new sample]
11+
* [Sample checklist]
12+
13+
_See also: [Flutter's code of conduct]_
14+
15+
<br />
16+
17+
# Before you contribute
918

10-
This repo is used by members of the Flutter team and a few partners as a place
11-
to store example apps and demos. It's not meant to be the one and only source of
12-
truth for Flutter samples or the only place people go to learn about the best
13-
ways to build with Flutter. What that means in practice is that if you've
14-
written a great example app, it doesn't need to be maintained here in order to
15-
get noticed, be of help to new Flutter devs, and have an impact on the
16-
community.
1719

18-
You can maintain your sample app in your own repo (or with another source
19-
control provider) and still be as important a part of the Flutter-verse as
20-
anything you see here. You can let us know on the
21-
[FlutterDev Google Group](https://groups.google.com/forum/#!forum/flutter-dev)
22-
when you've published something and Tweet about it with the
23-
[#FlutterDev](https://twitter.com/search?q=%23FlutterDev) hashtag.
20+
## Is this the right place for your sample?
2421

25-
## So what should be contributed here, then?
22+
In most cases, if you've written a great sample app, it should be maintained
23+
in your own repoistory. You can maintain your sample app in your own repo
24+
(or with another source control provider) and still be as important a part of
25+
the Flutter-verse as anything you see here.
2626

27-
Fixes and necessary improvements to the existing samples, mostly.
27+
**What should be contributed here, then?**
2828

29-
## Before you contribute
29+
Fixes and necessary improvements to the existing samples, mostly.
3030

31-
### File an issue first!
31+
## File an issue first!
3232

3333
If you see a bug or have an idea for a feature that you feel would improve one
34-
of the samples already in the repo, **please
35-
[file an issue](https://github.com/flutter/samples/issues/new) before you begin
34+
of the samples already in the repo, **please [file an issue] before you begin
3635
coding or send a PR**. This will help prevent duplicate work by letting us know
3736
what you're up to. It will help avoid a situation in which you spend a lot of
3837
time coding something that's not quite right for the repo or its goals.
3938

40-
### Sign the license agreement.
39+
## Sign the license agreement.
4140

4241
Before we can use your code, you must sign the
43-
[Google Individual Contributor License Agreement](https://cla.developers.google.com/about/google-individual)
42+
[Google Individual Contributor License Agreement]
4443
(CLA), which you can do online. The CLA is necessary mainly because you own the
4544
copyright to your changes, even after your contribution becomes part of our
4645
codebase, so we need your permission to use and distribute your code. We also
@@ -54,47 +53,177 @@ us first through the issue tracker with your idea so that we can help out and
5453
possibly guide you. Coordinating up front makes it much easier to avoid
5554
frustration later on.
5655

57-
## A few ground rules
58-
59-
This is monorepo containing a bunch of projects. While different codebases have
60-
different needs, there are a few basic conventions that every project here is
61-
expected to follow. All of them are based on our experience over the last
62-
couple years keeping the repo tidy and running smooth.
63-
64-
Each app should:
65-
66-
* Be designed to build against the current
67-
[stable](https://github.com/flutter/flutter/blob/master/docs/releases/Flutter-build-release-channels.md)
68-
release of the Flutter SDK.
69-
* Include the top level
70-
[`analysis_options.yaml`](analysis_options.yaml)
71-
file used throughout the repo. This file include a base set of analyzer
72-
conventions and lints.
73-
* Have no analyzer errors or warnings.
74-
* Be formatted with `dart format`.
75-
* Include at least one working test in its `test` folder.
76-
* Be wired into the list of projects in the CI scripts for [stable](tool/flutter_ci_script_stable.sh),
77-
[beta](tool/flutter_ci_script_beta.sh), and [master](tool/flutter_ci_script_master.sh),
78-
which runs the analyzer, the formatter, and `flutter test`.
79-
* Add the new project directory to the [dependabot](.github/dependabot.yaml) configuration
80-
to keep dependencies updated in an on-going basis.
81-
* Avoid adding an onerous amount of blobs (typically images or other assets) to
82-
the repo.
83-
84-
In addition, sample code is, at the end of the day, still code. It should be
85-
written with at least as much care as the Flutter code you'd find in the SDK
86-
itself. For that reason, most of the
87-
[Flutter style guide](https://github.com/flutter/flutter/blob/master/docs/contributing/Style-guide-for-Flutter-repo.md)
88-
also applies to code in this repo.
56+
<br />
57+
58+
# Contribute enhancements and fixes
59+
60+
Enhancements and bug fixes are welcome and appreciated.
61+
If you spot an [issue] that you might want to fix but aren't sure how to get started,
62+
feel free to comment on the issue and tag @ericwindmill with questions.
63+
64+
## Filing issues and evaluating existing samples
65+
66+
You can also contribute by filing issues against existing samples. This is thankless work
67+
and is _greatly_ appreciated. It's also a good way to familiarize yourself with the repository.
68+
69+
To evaluate a sample for possible issues, use the [Sample checklist] below.
70+
71+
<br />
72+
73+
# Writing a new sample
74+
75+
Before filing an issue for a new sample or submitting a PR, you must read the rest of this page.
76+
77+
## What is a sample?
78+
79+
Samples are reference materials that teach developers how to solve a specific problem.
80+
Samples contain **correct and concise code** that developers can
81+
**quickly understand** and **easily reuse** with minimal side effects.
82+
83+
### What samples should we have?
84+
85+
Samples in this repo demonstrates how to **use current features** of the **Flutter and Dart SDKs** using **best practices**.
86+
In other words, a sample should meet the following criteria:
87+
88+
* Demonstrates _how to use the SDKS_ rather than show an end-product.
89+
* Covers a critical developer journey in the SDK that is useful to >80% of developers.
90+
* Prefers primitives in the SDK over libraries.
91+
* Demonstrates features available on the stable channel of Flutter.
92+
93+
These guidelines can be broken in rare cases. For example, this is likely the best place in the
94+
Flutter github org for demo apps, but those demo apps must be justified.
95+
96+
## Is this the right place for your sample? (revisited)
97+
98+
Validate your idea against the following criteria:
99+
100+
1. **The sample solves a single problem or set of tightly coupled problems.** <br/>
101+
If not, you're either writing a Demo app or an extended sample. These might
102+
still be appropriate for the samples repos, but need to be justified.
103+
104+
2. **The target audience for the sample isn’t beginners.**
105+
3. **The sample code isn’t so complex that it needs video or text explanation.** <br />
106+
Samples are reference materials, and the code should speak for itself. If either of these aren't true,
107+
you may prefer to write a blogpost or tutorial.
108+
109+
5. **The sample isn’t tied to an event.** <br />
110+
If it is, you should likely use a personal repository.
111+
112+
5. **The sample isn’t tied to a library or package.** <br />
113+
If it is, the usage example should likely be in the [repository of that package].
114+
115+
6. **The topic doesn’t have crossover with any existing samples.** <br />
116+
If it does, ensure that it wouldn't be better to update the existing sample.
117+
118+
## What are your ongoing maintenance resposibilities?
119+
120+
All sample code has an unbound maintenance cost. If you cannot commit to maintaining a sample
121+
(for the forseeable future, barring changes in life circumstances), then you should talk to the
122+
[primary maintainers] of this project, particularly @ericwindmill, before submitting a PR.
123+
124+
Any new sample **must** have a CODEOWNER, and that owner is most likely you (the author).
125+
126+
## What type of sample are your writing?
127+
128+
This repository contains two types of sample apps: **quickstarts** and **demo apps**.
129+
130+
### Quickstarts
131+
132+
* **Purpose**: Provides starting points that a developer can extend.
133+
Solves specific problems or implements generic app features.
134+
* **Size**: <= 200 lines of code, not including boiler plate (guide, not rule)
135+
* **Qualities:**
136+
* Contains one feature or a small set of related features, but generally runnable.
137+
* Generic and un-opinionated about the context in which it is used.
138+
* Prioritizes being generic over best practices.
139+
* The code is Copy+paste-able.
140+
* In Flutter, this means that the code that is being demonstrated should be separated from and boiler plate (i.e. `runApp`)
141+
* **Audience:**
142+
* Developers with Flutter and Dart experience that don't need code explained to them.
143+
* **Answers the questions:**
144+
* “What’s the minimal amount of code needed to implement this feature…”
145+
* “... so I can understand how it works?”
146+
* “... so I can understand how to add it to my app?”
147+
* “How can I make sure I know how to extend this feature without missing anything?”
148+
* "What code should I use as a starting point given I want to solve a very similar problem?"
149+
150+
### Demo apps
151+
152+
* **Purpose**: Meant to be built and ran. Demos the _product_, not how to write code.
153+
* **Criteria**: Demo apps _only_ belong here if they...
154+
* ...aren't tied to an event or moment in time.
155+
* ...aren't tied to another resource (website, workshop, etc).
156+
* ...don't require explanation (other than a short README).
157+
* ...aren't primarily used to demonstrate an SDK feature.
158+
159+
### Other sample types
160+
161+
Other sample types, like demo apps that accompany docs or events, do not belong in this repository.
162+
They should be maintained alongside the accompanying resources (i.e. in the website repository), or in a personal repository.
89163

90164
### The `experimental` folder
91165

92-
Projects in the repo's top-level `experimental` directory are allowed to skirt
93-
some of the above rules. These apps are either experimental in nature or use
94-
APIs that haven't landed in the SDK's `stable` channel. They build against
95-
`main`, and aren't (by default) wired into our CI system.
166+
The experimental folder is being deprecated. If you have an experiemental sample project,
167+
you should manage it in a personal repository until it runs on the stable channel.
168+
169+
<br />
170+
171+
# Sample checklist
172+
173+
Every piece of code will have value to someone, but it is easy for maintenance costs to grow over time.
174+
The more items checked on this list, the higher the value and lower the maintenance costs.
175+
176+
Use this checklist to write new samples and evaluate existing ones.
177+
178+
**NB:** Demo apps have looser requirements. Use your best judgement when following the guidelines.
179+
180+
* Code
181+
- [ ] Be designed to build against the current [stable]
182+
release of the Flutter SDK.
183+
- [ ] Sample is the only one for the API in question (across all Dash samples)
184+
- [ ] Repository and pubspec name are titled for its ingredients (i.e. mvvm_architecture instead of compass_app)
185+
- [ ] Only includes the minimal required code to demonstrate the feature or API and run the code.
186+
- [ ] Sample favors 1P dependencies over 3P.
187+
- [ ] Code has been sufficiently explained with doc comments.
188+
- [ ] The sample app separates its bespoke code from general Flutter or Dart code.
189+
- [ ] Favor readability over best practices unless readability requires an anti pattern. Use your best judgment.
190+
- [ ] Avoid adding an onerous amount of blobs (typically images or other assets) to the repo.
191+
- [ ] All files in the project must start with the appropriate [file headers].
192+
193+
* Tests, style and maintenance
194+
- [ ] Sample has Dart tests that cover the business logic
195+
- [ ] Sample is wired into the list of projects in the CI scripts for [stable](tool/flutter_ci_script_stable.sh),
196+
[beta](tool/flutter_ci_script_beta.sh), and [master](tool/flutter_ci_script_master.sh),
197+
which runs the analyzer, the formatter, and `flutter test`.
198+
- [ ] Sample has a codeowner (it's likely you, the author)
199+
- [ ] Sample is formatted with `dart format`.
200+
- [ ] Sample has no analyzer errors or warnings.
201+
- [ ] Add the new project directory to the [dependabot](.github/dependabot.yaml) configuration
202+
to keep dependencies updated in an on-going basis.
203+
- [ ] Follows the [Flutter style guide]
204+
- [ ] Include the top level [`analysis_options.yaml`](analysis_options.yaml)
205+
file used throughout the repo. This file include a base set of analyzer
206+
conventions and lints.
207+
208+
* README
209+
- [ ] Describes the apps design and purpose.
210+
- [ ] Describes common errors and debugging steps.
211+
- [ ] Describes any steps necessary to build and run.
212+
- [ ] Has ‘Open in IDX’ button, and a nix file (if compatible with IDX).
213+
214+
## File headers
215+
216+
All files in the project must start with the following header.
217+
218+
```
219+
// Copyright 2024 The Flutter team. All rights reserved.
220+
// Use of this source code is governed by a BSD-style license that can be
221+
// found in the LICENSE file.
222+
```
223+
224+
<br />
96225

97-
## Code reviews
226+
# Code reviews
98227

99228
All submissions, including submissions by project members, require review.
100229

@@ -107,7 +236,7 @@ primary maintainers, though, are:
107236
* [@domesticmouse](https://github.com/domesticmouse)
108237
* [@ericwindmill](https://github.com/ericwindmill)
109238

110-
You are free to add one of these folks (particularly @RedBrogdon) as a reviewer
239+
You are free to add one of these folks (particularly @ericwindmill) as a reviewer
111240
to any PR sent to this repo. We're happy to comment, answer (or ask) questions,
112241
and provide feedback.
113242

@@ -121,18 +250,24 @@ before, or changing something that's a meta-concern like the CI setup, web
121250
hosting, project setup, etc., please include one of the primary maintainers as a
122251
reviewer.
123252

124-
## File headers
125-
126-
All files in the project must start with the following header.
127-
128-
```
129-
// Copyright 2024 The Flutter team. All rights reserved.
130-
// Use of this source code is governed by a BSD-style license that can be
131-
// found in the LICENSE file.
132-
```
253+
<br />
133254

134-
## The small print
255+
# The small print
135256

136257
Contributions made by corporations are covered by a different agreement than the
137-
one above, the
138-
[Software Grant and Corporate Contributor License Agreement](https://developers.google.com/open-source/cla/corporate).
258+
one above, the [Software Grant and Corporate Contributor License Agreement].
259+
260+
[Flutter's code of conduct]: https://github.com/flutter/flutter/blob/master/CODE_OF_CONDUCT.md
261+
[Before you contribute]: https://github.com/flutter/samples/blob/main/CONTRIBUTING.md#before-you-contribute
262+
[Contribute enhancements and fixes]: https://github.com/flutter/samples/blob/main/CONTRIBUTING.md#contribute-enhancements-and-fixes
263+
[Write a new sample]: https://github.com/flutter/samples/blob/main/CONTRIBUTING.md#write-a-new-sample
264+
[Sample checklist]: https://github.com/flutter/samples/blob/main/CONTRIBUTING.md#samples-checklist
265+
[file headers]: https://github.com/flutter/samples/blob/main/CONTRIBUTING.md#file-headers
266+
[Software Grant and Corporate Contributor License Agreement]: https://developers.google.com/open-source/cla/corporate
267+
[issue]: https://github.com/flutter/samples/issues
268+
[file an issue]: https://github.com/flutter/samples/issues/new
269+
[repository of that package]: https://dart.dev/tools/pub/package-layout#examples
270+
[stable]: https://github.com/flutter/flutter/blob/master/docs/releases/Flutter-build-release-channels.md
271+
[Flutter style guide]: (https://github.com/flutter/flutter/blob/master/docs/contributing/Style-guide-for-Flutter-repo.md)
272+
[Google Individual Contributor License Agreement]: https://cla.developers.google.com/about/google-individual
273+
[primary maintainers]: https://github.com/flutter/samples/blob/main/CONTRIBUTING.md#code-reviews

0 commit comments

Comments
 (0)