Loading...
Loading...
Enforces Flutter/Dart project scaffolding where the layout makes defects greppable — a single-package app by default (feature-first under lib/features/, shared foundation split by role in core/ data/ services/ routing/ theme/ l10n/, a thin main.dart that calls bootstrap(), no lib/src in the app), extracting a generically-named pure-Dart package only when a body of logic earns it (public barrel over private lib/src/ for PACKAGES only, meta-only deps as the compile firewall, resolution:workspace member, downward-only dependency DAG), with pubspec treated as the audit artifact and no utils/helpers/common/misc/grab-bag-shared junk-drawer folders. Use when creating any .dart file or directory, deciding where a repository/Notifier/MethodChannel/value-type/token belongs, authoring or fixing a pubspec.yaml, adding a workspace member, writing an import directive, mirroring a test under test/, or reviewing a diff for organisation.
npx skill4agent add zakariaf/flutter-skills project-structure-and-packagesgreplslib/features/pubspec.yamlreferences/single-package-layout.mdreferences/layering-and-dependencies.mdreferences/workspace-and-packages.mdresolution: workspacescripts/check_structure.shscripts/check_import_boundaries.sh*_coremoneyschedulingPURE_DIR=packages/money scripts/check_import_boundaries.shpubspec.lockpackages/references/workspace-and-packages.mdlib/features/lib/features/<feature>/presentation/<feature>_notifier.dartapplication/domain/data/core/data/services/routing/theme/l10n/main.dartbootstrap()bootstrap.dartapp.dartMaterialApp.routerfeatures/orders/presentation/utils/helpers/common/misc/shared/core/data/services/native/core/domain/pubspec.yamlfeatures → services/data → corecoredataservicesnavigation-and-routingmetalib/core/ResultFailurepackage:clockClockclockClockDateTime.now()ClockServiceservice-boundary-and-nativeWidgetDateTime.now()lib/src/lib/<package>.dartlib/src/lib/src/utils/helpers/common/misc/shared/core/lib/test/data/order_repository_test.dartlib/data/order_repository.dartlstest/policy/test/support/snake_caseorder_repository.dartOrderRepositorysealedalways_use_package_importspackage:├── analysis_options.yaml # the lint safety net (see lint-and-style-config)
├── pubspec.yaml # pubspec.lock is COMMITTED — this is an app
├── lib/
│ ├── main.dart # thin entry: runs bootstrap(). Nothing else.
│ ├── bootstrap.dart # composition root: build infra, override providers, error net, runApp (see app-startup-and-bootstrap)
│ ├── app.dart # MaterialApp.router, theme wiring, ProviderScope child
│ ├── core/ # PURE foundation, NO Flutter: value objects, Result/Failure, Clock seam, calculators
│ ├── data/ # shared data layer: Drift db, DAOs, repositories, row→model mappers
│ ├── services/ # injectable side-effect ports + impls; native/ quarantines MethodChannel
│ │ └── native/
│ ├── routing/ # the single go_router config, typed routes, guards (see navigation-and-routing)
│ ├── theme/ # ThemeExtension token sets, ColorScheme (see design-system-structure)
│ ├── l10n/ # generated AppLocalizations + ARB (see i18n-rtl-l10n)
│ └── features/ # BY FEATURE — one folder per surface
│ └── orders/
│ ├── presentation/
│ │ ├── orders_screen.dart
│ │ ├── orders_notifier.dart # the ViewModel: a Riverpod Notifier (see state-management-riverpod)
│ │ └── widgets/
│ │ └── order_tile.dart
│ ├── application/ # OPTIONAL: use-cases spanning repositories
│ └── domain/ # OPTIONAL: feature-local models
├── test/ # mirrors lib/ 1:1
└── integration_test/ # only what unit/widget tests cannot reachdata/lib/data/references/single-package-layout.md// Q: where does OrderRepository go? A: it owns DB failure → lib/data/
class OrderRepository {
OrderRepository(this._db);
final AppDatabase _db;
// Rows never escape this class; the UI is owed a value type, not a raw row.
Future<List<Order>> loadAll() async {
final rows = await _db.selectOrders(); // package:drift confined here
return rows.map(Order.fromRow).toList();
}
}// Q: where does PaymentChannel go? A: it constructs a MethodChannel → lib/services/native/
// One `grep -rn MethodChannel lib/` outside services/native/ is a review failure.
class PaymentChannel {
static const _channel = MethodChannel('app/payment');
Future<bool> canPay() async => await _channel.invokeMethod('canPay') ?? false;
}lib/core/lib/data/lib/features/routing/scaffold-feature-modulenavigation-and-routingMediaQuery.textScalerOfMediaQueryBuildContextaccessibility-as-codelib/core/# packages/domain_core/pubspec.yaml — the manifest IS the purity audit
name: domain_core # a GENERIC name — never the brand, so a rename never churns the core
publish_to: none
resolution: workspace # member of the root workspace (modern successor to path:/overrides)
environment:
sdk: ^3.6.0
dependencies:
meta: ^1.15.0 # the ONLY dependency. No flutter, no dart:io, no dart:ui, no clock.
dev_dependencies:
test: ^1.25.0 # plain `dart test` — NOT flutter_testpubspec.yamlworkspace:pubspec.locklib/domain_core.dartlib/src/references/workspace-and-packages.mdWhen multi-package (workspace) only. Everything in this section —,packages/, barrels,resolution: workspace— applies solely once you have decided to split. A single-package app does none of it.lib/src/
orders/settings/lib/data/lib/core/lib/features/coredataservicesutils/helpers/common/misc/shared/core/lib/src/lib/src/MethodChannelservices/native/flutterdart:ioDateTime.now()lib/core/Clockpackage:clockpath:dependency_overridesresolution: workspacemyapp_coredomain_coremoneypackage:pubspec.lockpackages/core/ data/ services/ routing/ theme/ l10n/lib/features/<feature>/main.dartbootstrap()coredataservicesMethodChannelservices/native/data/core/utils/helpers/common/misc/shared/core/lib/src/test/lib/test/support/test/policy/snake_casealways_use_package_importsresolution: workspacelib/src/metaflutterdart:iodart:uipubspec.locklib/src/scripts/check_structure.shscripts/check_import_boundaries.shflutter-architecturescaffold-feature-modulelib/features/<feature>/<feature>_notifier.dartapp-startup-and-bootstrapmain.dartbootstrap.dartnavigation-and-routinglib/routing/naming-conventionsScreenNotifierRepositoryServiceGatewaydependency-hygienecodegen-and-toolchainbuild.yamllint-and-style-configanalysis_options.yamlalways_use_package_importsservice-boundary-and-nativeservices/native/ClockclockProvidervalue-objects-money-and-unitslib/core/resolution: workspace