1
0
mirror of https://github.com/nisrulz/flutter-examples.git synced 2026-08-25 01:05:36 +00:00

docs: document the wrapper/example app structure

This commit is contained in:
Nishant Srivastava
2026-08-18 01:05:36 +02:00
parent bcb3629907
commit 9d67d31c72
3 changed files with 33 additions and 0 deletions

View File

@@ -2,6 +2,23 @@
I welcome and encourage all pull requests. It usually takes 24-48 hours to respond to any issue or request.
## Example app structure
Every example app uses the same structure, so the code that teaches a concept is
easy to find:
- `lib/main.dart`: the app wrapper. It holds only `runApp()` and a `MyApp` widget
that returns the `MaterialApp` (title, theme, routes). Keep this file minimal and
uniform across apps.
- `lib/example.dart`: the focused example code. It contains the full screen
(`Scaffold` + `AppBar`) and the widget that demonstrates the concept, with a
`// Example: <what this app teaches>` comment at the top.
- Supporting files (screens, tabs, services, models, widgets, utils) sit alongside
the example and are imported by `lib/example.dart`.
To understand an example app, read `lib/example.dart`. That file holds the concept;
`lib/main.dart` holds only the wrapping boilerplate.
## Basic rules
1. Match coding style (braces, spacing, etc.). Use the `Reformat Code` feature of Android Studio (`CMD` + `Option` + `L` on Mac, `CTRL` + `ALT` + `L` on Linux and Windows).
@@ -11,3 +28,7 @@ I welcome and encourage all pull requests. It usually takes 24-48 hours to respo
1. Check for existing [issues](https://github.com/nisrulz/flutter-examples/issues) before filing a new one.
1. Follow the same standard as all other projects in this repo.
> The package name must conform to the format: `github.nisrulz.<app_name>`
When you add a new example app, keep the wrapper in `lib/main.dart` and the focused
example code in `lib/example.dart`. Run `make docs`, `make analyze`, and `make doctor`
before opening a pull request.