Viet Tran a38d04c3d5
feat(search): overhaul relevance and curated design data
Overhaul BM25 relevance, reasoning and data-quality contracts; refresh UI styles and framework guidance; add resilient text, chip, badge and micro-interaction guidance; strengthen release, provenance and catalog refresh gates; update bilingual documentation.
2026-08-14 00:08:23 +07:00

14 KiB

1NoCategoryGuidelineDescriptionDoDon'tCode GoodCode BadSeverityDocs URLApplies ToStatusVerified At
21WidgetsUse StatelessWidget when possibleImmutable widgets are simplerStatelessWidget for static UIStatefulWidget for everythingclass MyWidget extends StatelessWidgetclass MyWidget extends StatefulWidget (static)Mediumhttps://api.flutter.dev/flutter/widgets/StatelessWidget-class.htmlflutter 3.44.x (current stable line)active2026-08-13
32WidgetsKeep widgets smallSingle responsibility principleExtract widgets into smaller piecesLarge build methodsColumn(children: [Header() Content()])500+ line build methodMediumflutter 3.44.x (current stable line)active2026-08-13
43WidgetsUse const constructorsCompile-time constants for performanceconst MyWidget() when possibleNon-const for static widgetsconst Text('Hello')Text('Hello') for literalsHighhttps://docs.flutter.dev/perf/best-practices#control-build-costflutter 3.44.x (current stable line)active2026-08-13
54WidgetsPrefer composition over inheritanceCombine widgets using childrenCompose widgetsExtend widget classesContainer(child: MyContent())class MyContainer extends ContainerMediumflutter 3.44.x (current stable line)active2026-08-13
65StateUse setState correctlyMinimal state in StatefulWidgetsetState for UI state changessetState for business logicsetState(() { _counter++; })Complex logic in setStateMediumhttps://api.flutter.dev/flutter/widgets/State/setState.htmlflutter 3.44.x (current stable line)active2026-08-13
76StateAvoid setState in buildNever call setState during buildsetState in callbacks onlysetState in build methodonPressed: () => setState(() {})build() { setState(); }Highhttps://api.flutter.dev/flutter/widgets/State/setState.htmlflutter 3.44.x (current stable line)active2026-08-13
87StateUse state management for complex appsProvider Riverpod BLoCState management for shared statesetState for global stateProvider.of<MyState>(context)Global setState callsMediumflutter 3.44.x (current stable line)active2026-08-13
98StatePrefer Riverpod or ProviderRecommended state solutionsRiverpod for new projectsInheritedWidget manuallyref.watch(myProvider)Custom InheritedWidgetMediumhttps://riverpod.dev/flutter 3.44.x (current stable line)active2026-08-13
109StateDispose resourcesClean up controllers and subscriptionsdispose() for cleanupMemory leaks from subscriptions@override void dispose() { controller.dispose(); }No dispose implementationHighhttps://api.flutter.dev/flutter/widgets/State/dispose.htmlflutter 3.44.x (current stable line)active2026-08-13
1110LayoutUse Column and RowBasic layout widgetsColumn Row for linear layoutsStack for simple layoutsColumn(children: [Text(), Button()])Stack for vertical listMediumhttps://api.flutter.dev/flutter/widgets/Column-class.htmlflutter 3.44.x (current stable line)active2026-08-13
1211LayoutUse Expanded and FlexibleControl flex behaviorExpanded to fill spaceFixed sizes in flex containersExpanded(child: Container())Container(width: 200) in RowMediumflutter 3.44.x (current stable line)active2026-08-13
1312LayoutUse SizedBox for spacingConsistent spacingSizedBox for gapsContainer for spacing onlySizedBox(height: 16)Container(height: 16)Lowflutter 3.44.x (current stable line)active2026-08-13
1413LayoutUse LayoutBuilder for responsiveRespond to constraintsLayoutBuilder for adaptive layoutsFixed sizes for responsiveLayoutBuilder(builder: (context constraints) {})Container(width: 375)Mediumhttps://api.flutter.dev/flutter/widgets/LayoutBuilder-class.htmlflutter 3.44.x (current stable line)active2026-08-13
1514LayoutAvoid deep nestingKeep widget tree shallowExtract deeply nested widgets10+ levels of nestingExtract widget to method or classColumn(Row(Column(Row(...))))Mediumflutter 3.44.x (current stable line)active2026-08-13
1615ListsUse ListView.builderLazy list buildingListView.builder for long listsListView with children for large listsListView.builder(itemCount: 100, itemBuilder: ...)ListView(children: items.map(...).toList())Highhttps://api.flutter.dev/flutter/widgets/ListView-class.htmlflutter 3.44.x (current stable line)active2026-08-13
1716ListsProvide itemExtent when knownSkip measurementitemExtent for fixed height itemsNo itemExtent for uniform listsListView.builder(itemExtent: 50)ListView.builder without itemExtentMediumflutter 3.44.x (current stable line)active2026-08-13
1817ListsUse keys for stateful itemsPreserve widget stateKey for stateful list itemsNo key for dynamic listsListTile(key: ValueKey(item.id))ListTile without keyHighhttps://api.flutter.dev/flutter/foundation/ValueKey-class.htmlflutter 3.44.x (current stable line)active2026-08-13
1918ListsUse SliverList for custom scrollCustom scroll effectsCustomScrollView with SliversNested ListViewsCustomScrollView(slivers: [SliverList()])ListView inside ListViewMediumhttps://api.flutter.dev/flutter/widgets/SliverList-class.htmlflutter 3.44.x (current stable line)active2026-08-13
2019NavigationUse Navigator 2.0 or GoRouterDeclarative routinggo_router for navigationNavigator.push for complex appsGoRouter(routes: [...])Navigator.push everywhereMediumhttps://pub.dev/packages/go_routerflutter 3.44.x (current stable line)active2026-08-13
2120NavigationUse named routesOrganized navigationNamed routes for clarityAnonymous routesNavigator.pushNamed(context '/home')Navigator.push(context MaterialPageRoute())Lowflutter 3.44.x (current stable line)active2026-08-13
2221NavigationHandle back button with PopScopeAndroid back behavior and predictive back (Android 14+)Use PopScope with onPopInvokedWithResultUse WillPopScopePopScope(canPop: canPop, onPopInvokedWithResult: (didPop, result) { ... })WillPopScope(onWillPop: ...)Highhttps://api.flutter.dev/flutter/widgets/PopScope-class.htmlflutter 3.44.x (current stable line)active2026-08-13
2322NavigationPass typed argumentsType-safe route argumentsTyped route argumentsDynamic argumentsMyRoute(id: '123')arguments: {'id': '123'}Mediumflutter 3.44.x (current stable line)active2026-08-13
2423AsyncUse FutureBuilderAsync UI buildingFutureBuilder for async datasetState for asyncFutureBuilder(future: fetchData())fetchData().then((d) => setState())Mediumhttps://api.flutter.dev/flutter/widgets/FutureBuilder-class.htmlflutter 3.44.x (current stable line)active2026-08-13
2524AsyncUse StreamBuilderStream UI buildingStreamBuilder for streamsManual stream subscriptionStreamBuilder(stream: myStream)stream.listen in initStateMediumhttps://api.flutter.dev/flutter/widgets/StreamBuilder-class.htmlflutter 3.44.x (current stable line)active2026-08-13
2625AsyncHandle loading and error statesComplete async UI statesConnectionState checksOnly success stateif (snapshot.connectionState == ConnectionState.waiting)No loading indicatorHighhttps://api.flutter.dev/flutter/widgets/FutureBuilder-class.htmlflutter 3.44.x (current stable line)active2026-08-13
2726AsyncCancel subscriptionsClean up stream subscriptionsCancel in disposeMemory leakssubscription.cancel() in disposeNo subscription cleanupHighhttps://api.flutter.dev/flutter/dart-async/StreamSubscription/cancel.htmlflutter 3.44.x (current stable line)active2026-08-13
2827ThemingUse ThemeDataConsistent themingThemeData for app themeHardcoded colorsTheme.of(context).primaryColorColor(0xFF123456) everywhereMediumhttps://api.flutter.dev/flutter/material/ThemeData-class.htmlflutter 3.44.x (current stable line)active2026-08-13
2928ThemingUse ColorSchemeMaterial 3 color systemColorScheme for colorsIndividual color propertiescolorScheme: ColorScheme.fromSeed()primaryColor: Colors.blueMediumflutter 3.44.x (current stable line)active2026-08-13
3029ThemingAccess theme via contextDynamic theme accessTheme.of(context)Static theme referenceTheme.of(context).textTheme.bodyLargeTextStyle(fontSize: 16)Mediumflutter 3.44.x (current stable line)active2026-08-13
3130ThemingSupport dark modeRespect system themedarkTheme in MaterialAppLight theme onlyMaterialApp(theme: light, darkTheme: dark)MaterialApp(theme: light)Mediumflutter 3.44.x (current stable line)active2026-08-13
3231AnimationUse implicit animationsSimple animationsAnimatedContainer AnimatedOpacityExplicit for simple transitionsAnimatedContainer(duration: Duration())AnimationController for fadeLowhttps://api.flutter.dev/flutter/widgets/AnimatedContainer-class.htmlflutter 3.44.x (current stable line)active2026-08-13
3332AnimationUse AnimationController for complexFine-grained controlAnimationController with TickerImplicit for complex sequencesAnimationController(vsync: this)AnimatedContainer for staggeredMediumflutter 3.44.x (current stable line)active2026-08-13
3433AnimationDispose AnimationControllersClean up animation resourcesdispose() for controllersMemory leakscontroller.dispose() in disposeNo controller disposalHighhttps://api.flutter.dev/flutter/animation/AnimationController/dispose.htmlflutter 3.44.x (current stable line)active2026-08-13
3534AnimationUse Hero for transitionsShared element transitionsHero for navigation animationsManual shared elementHero(tag: 'image' child: Image())Custom shared element animationLowhttps://api.flutter.dev/flutter/widgets/Hero-class.htmlflutter 3.44.x (current stable line)active2026-08-13
3635FormsUse Form widgetForm validationForm with GlobalKeyIndividual validationForm(key: _formKey child: ...)TextField without FormMediumhttps://api.flutter.dev/flutter/widgets/Form-class.htmlflutter 3.44.x (current stable line)active2026-08-13
3736FormsUse TextEditingControllerControl text inputController for text fieldsonChanged for all textfinal controller = TextEditingController()onChanged: (v) => setState()Mediumflutter 3.44.x (current stable line)active2026-08-13
3837FormsValidate on submitForm validation flow_formKey.currentState!.validate()Skip validationif (_formKey.currentState!.validate())Submit without validationHighhttps://api.flutter.dev/flutter/widgets/FormState/validate.htmlflutter 3.44.x (current stable line)active2026-08-13
3938FormsDispose controllersClean up text controllersdispose() for controllersMemory leakscontroller.dispose() in disposeNo controller disposalHighhttps://api.flutter.dev/flutter/widgets/TextEditingController-class.htmlflutter 3.44.x (current stable line)active2026-08-13
4039PerformanceUse const widgetsReduce rebuildsconst for static widgetsNo const for literalsconst Icon(Icons.add)Icon(Icons.add)Highhttps://docs.flutter.dev/perf/best-practices#control-build-costflutter 3.44.x (current stable line)active2026-08-13
4140PerformanceAvoid rebuilding entire treeMinimal rebuild scopeIsolate changing widgetssetState on parentConsumer only around changing widgetsetState on root widgetHighhttps://docs.flutter.dev/perf/best-practices#control-build-costflutter 3.44.x (current stable line)active2026-08-13
4241PerformanceUse RepaintBoundaryIsolate repaintsRepaintBoundary for animationsFull screen repaintsRepaintBoundary(child: AnimatedWidget())Animation without boundaryMediumhttps://api.flutter.dev/flutter/widgets/RepaintBoundary-class.htmlflutter 3.44.x (current stable line)active2026-08-13
4342PerformanceProfile with DevToolsMeasure before optimizingFlutter DevTools profilingGuess at performanceDevTools performance tabOptimize without measuringMediumhttps://docs.flutter.dev/tools/devtoolsflutter 3.44.x (current stable line)active2026-08-13
4443AccessibilityUse Semantics widgetScreen reader supportSemantics for accessibilityMissing accessibility infoSemantics(label: 'Submit button')GestureDetector without semanticsHighhttps://api.flutter.dev/flutter/widgets/Semantics-class.htmlflutter 3.44.x (current stable line)active2026-08-13
4544AccessibilitySupport large fontsUse TextScaler for nonlinear text scalingUse MediaQuery.textScalerOf(context)Fixed font sizesfinal scaler = MediaQuery.textScalerOf(context); scaler.scale(14)MediaQuery.textScaleFactorHighhttps://api.flutter.dev/flutter/widgets/MediaQuery/textScalerOf.htmlflutter 3.44.x (current stable line)active2026-08-13
4645AccessibilityTest with screen readersTalkBack and VoiceOverTest accessibility regularlySkip accessibility testingRegular TalkBack testingNo screen reader testingHighhttps://docs.flutter.dev/ui/accessibility-and-internationalization/accessibility#screen-readersflutter 3.44.x (current stable line)active2026-08-13
4746TestingUse widget testsTest widget behaviorWidgetTester for UI testsUnit tests onlytestWidgets('...' (tester) async {})Only test() for UIMediumhttps://docs.flutter.dev/testingflutter 3.44.x (current stable line)active2026-08-13
4847TestingUse integration testsFull app testingintegration_test packageManual testing onlyIntegrationTestWidgetsFlutterBindingManual E2E testingMediumflutter 3.44.x (current stable line)active2026-08-13
4948TestingMock dependenciesIsolate testsMockito or mocktailReal dependencies in testswhen(mock.method()).thenReturn()Real API calls in testsMediumflutter 3.44.x (current stable line)active2026-08-13
5049PlatformUse Platform checksPlatform-specific codePlatform.isIOS Platform.isAndroidSame code for all platformsif (Platform.isIOS) {}Hardcoded iOS behaviorMediumflutter 3.44.x (current stable line)active2026-08-13
5150PlatformUse kIsWeb for webWeb platform detectionkIsWeb for web checksPlatform for webif (kIsWeb) {}Platform.isWeb (doesn't exist)Mediumflutter 3.44.x (current stable line)active2026-08-13
5251PackagesUse pub.dev packagesCommunity packagesPopular maintained packagesCustom implementationscached_network_imageCustom image cacheMediumhttps://pub.dev/flutter 3.44.x (current stable line)active2026-08-13
5352PackagesCheck package qualityQuality before addingPub points and popularityAny package without review100+ pub pointsUnmaintained packagesMediumflutter 3.44.x (current stable line)active2026-08-13