From 97703dc86c4f005d5efd36f0a3b52c853486e817 Mon Sep 17 00:00:00 2001 From: Parker Lougheed Date: Sun, 19 Apr 2026 15:49:12 +0200 Subject: [PATCH 1/3] Add FWE excerpt projects to examples workspace and fix lints --- examples/fwe/birdle/.gitignore | 45 ----------------- examples/fwe/birdle/.metadata | 45 ----------------- examples/fwe/birdle/README.md | 5 +- examples/fwe/birdle/analysis_options.yaml | 1 - examples/fwe/birdle/lib/game.dart | 50 +++++++++---------- examples/fwe/birdle/lib/main.dart | 15 +++--- examples/fwe/birdle/lib/step1_main.dart | 1 - examples/fwe/birdle/lib/step2_main.dart | 3 +- examples/fwe/birdle/lib/step2a_main.dart | 1 - examples/fwe/birdle/lib/step2b_main.dart | 1 - examples/fwe/birdle/lib/step2c_main.dart | 3 +- examples/fwe/birdle/lib/step2d_main.dart | 1 - examples/fwe/birdle/lib/step2e_main.dart | 1 - examples/fwe/birdle/lib/step2f_main.dart | 1 - examples/fwe/birdle/lib/step3_main.dart | 13 +++-- examples/fwe/birdle/lib/step3a_main.dart | 3 +- examples/fwe/birdle/lib/step3b_main.dart | 3 +- examples/fwe/birdle/lib/step3c_main.dart | 5 +- examples/fwe/birdle/lib/step4_main.dart | 7 ++- examples/fwe/birdle/lib/step4a_main.dart | 3 +- examples/fwe/birdle/lib/step4b_main.dart | 3 +- examples/fwe/birdle/lib/step4c_main.dart | 3 +- examples/fwe/birdle/lib/step4d_main.dart | 1 - examples/fwe/birdle/lib/step4e_main.dart | 3 +- examples/fwe/birdle/lib/step4f_main.dart | 1 - examples/fwe/birdle/lib/step4g_main.dart | 3 +- examples/fwe/birdle/lib/step4h_main.dart | 3 +- examples/fwe/birdle/lib/step4i_main.dart | 3 +- examples/fwe/birdle/lib/step4j_main.dart | 3 +- examples/fwe/birdle/lib/step4k_main.dart | 11 ++-- examples/fwe/birdle/lib/step4l_main.dart | 5 +- examples/fwe/birdle/lib/step4m_main.dart | 3 +- examples/fwe/birdle/lib/step5_main.dart | 7 ++- examples/fwe/birdle/pubspec.yaml | 8 +-- examples/fwe/rolodex/README.md | 4 ++ .../step1_advanced_ui/data/contact_group.dart | 12 ++--- .../data/contact_group.dart | 12 ++--- .../lib/step3_slivers/data/contact_group.dart | 12 ++--- .../step3_slivers/screens/contact_groups.dart | 2 +- .../screens/contact_groups_v1.dart | 2 +- .../lib/step3_slivers/screens/contacts.dart | 7 +-- .../step3_slivers/screens/contacts_v1.dart | 4 +- .../step3_slivers/screens/contacts_v2.dart | 4 +- .../step4_navigation/data/contact_group.dart | 12 ++--- .../screens/contact_groups.dart | 6 +-- .../step4_navigation/screens/contacts.dart | 7 +-- examples/fwe/rolodex/pubspec.yaml | 8 +-- examples/fwe/wikipedia_reader/README.md | 5 +- .../fwe/wikipedia_reader/lib/step3e_main.dart | 2 - examples/fwe/wikipedia_reader/pubspec.yaml | 5 +- examples/pubspec.yaml | 3 ++ src/_snippets/tutorial/game-code.dart | 6 +-- .../learn/pathway/tutorial/advanced-ui.md | 12 ++--- src/content/learn/pathway/tutorial/layout.md | 13 +++-- .../learn/pathway/tutorial/navigation.md | 4 +- src/content/learn/pathway/tutorial/slivers.md | 17 ++----- .../learn/pathway/tutorial/user-input.md | 22 ++++---- 57 files changed, 175 insertions(+), 270 deletions(-) delete mode 100644 examples/fwe/birdle/.gitignore delete mode 100644 examples/fwe/birdle/.metadata delete mode 100644 examples/fwe/birdle/analysis_options.yaml create mode 100644 examples/fwe/rolodex/README.md diff --git a/examples/fwe/birdle/.gitignore b/examples/fwe/birdle/.gitignore deleted file mode 100644 index 3820a95c65c..00000000000 --- a/examples/fwe/birdle/.gitignore +++ /dev/null @@ -1,45 +0,0 @@ -# Miscellaneous -*.class -*.log -*.pyc -*.swp -.DS_Store -.atom/ -.build/ -.buildlog/ -.history -.svn/ -.swiftpm/ -migrate_working_dir/ - -# IntelliJ related -*.iml -*.ipr -*.iws -.idea/ - -# The .vscode folder contains launch configuration and tasks you configure in -# VS Code which you may wish to be included in version control, so this line -# is commented out by default. -#.vscode/ - -# Flutter/Dart/Pub related -**/doc/api/ -**/ios/Flutter/.last_build_id -.dart_tool/ -.flutter-plugins-dependencies -.pub-cache/ -.pub/ -/build/ -/coverage/ - -# Symbolication related -app.*.symbols - -# Obfuscation related -app.*.map.json - -# Android Studio will place build artifacts here -/android/app/debug -/android/app/profile -/android/app/release diff --git a/examples/fwe/birdle/.metadata b/examples/fwe/birdle/.metadata deleted file mode 100644 index c9627623eef..00000000000 --- a/examples/fwe/birdle/.metadata +++ /dev/null @@ -1,45 +0,0 @@ -# This file tracks properties of this Flutter project. -# Used by Flutter tool to assess capabilities and perform upgrades etc. -# -# This file should be version controlled and should not be manually edited. - -version: - revision: "e308d690a1193ea0d93d62aad6efe48e5994bc3c" - channel: "[user-branch]" - -project_type: app - -# Tracks metadata for the flutter migrate command -migration: - platforms: - - platform: root - create_revision: e308d690a1193ea0d93d62aad6efe48e5994bc3c - base_revision: e308d690a1193ea0d93d62aad6efe48e5994bc3c - - platform: android - create_revision: e308d690a1193ea0d93d62aad6efe48e5994bc3c - base_revision: e308d690a1193ea0d93d62aad6efe48e5994bc3c - - platform: ios - create_revision: e308d690a1193ea0d93d62aad6efe48e5994bc3c - base_revision: e308d690a1193ea0d93d62aad6efe48e5994bc3c - - platform: linux - create_revision: e308d690a1193ea0d93d62aad6efe48e5994bc3c - base_revision: e308d690a1193ea0d93d62aad6efe48e5994bc3c - - platform: macos - create_revision: e308d690a1193ea0d93d62aad6efe48e5994bc3c - base_revision: e308d690a1193ea0d93d62aad6efe48e5994bc3c - - platform: web - create_revision: e308d690a1193ea0d93d62aad6efe48e5994bc3c - base_revision: e308d690a1193ea0d93d62aad6efe48e5994bc3c - - platform: windows - create_revision: e308d690a1193ea0d93d62aad6efe48e5994bc3c - base_revision: e308d690a1193ea0d93d62aad6efe48e5994bc3c - - # User provided section - - # List of Local paths (relative to this file) that should be - # ignored by the migrate tool. - # - # Files that are not part of the templates will be ignored by default. - unmanaged_files: - - 'lib/main.dart' - - 'ios/Runner.xcodeproj/project.pbxproj' diff --git a/examples/fwe/birdle/README.md b/examples/fwe/birdle/README.md index 4ff8a5029ea..206b6b43e22 100644 --- a/examples/fwe/birdle/README.md +++ b/examples/fwe/birdle/README.md @@ -1,3 +1,4 @@ -# birdle +# Birdle app -A new Flutter project. +Code excerpts for the Birdle example app built in +the [Flutter tutorial](https://docs.flutter.dev/learn/pathway/tutorial). diff --git a/examples/fwe/birdle/analysis_options.yaml b/examples/fwe/birdle/analysis_options.yaml deleted file mode 100644 index f9b303465f1..00000000000 --- a/examples/fwe/birdle/analysis_options.yaml +++ /dev/null @@ -1 +0,0 @@ -include: package:flutter_lints/flutter.yaml diff --git a/examples/fwe/birdle/lib/game.dart b/examples/fwe/birdle/lib/game.dart index 394ec65eef5..3c223e0ef4f 100644 --- a/examples/fwe/birdle/lib/game.dart +++ b/examples/fwe/birdle/lib/game.dart @@ -8,28 +8,28 @@ enum HitType { none, hit, partial, miss, removed } typedef Letter = ({String char, HitType type}); -const legalWords = ["aback", "abase", "abate", "abbey", "abbot"]; +const legalWords = ['aback', 'abase', 'abate', 'abbey', 'abbot']; /// Legal guesses minus legal wordles const legalGuesses = [ - "aback", - "abase", - "abate", - "abbey", - "abbot", - "abhor", - "abide", - "abled", - "abode", - "abort", + 'aback', + 'abase', + 'abate', + 'abbey', + 'abbot', + 'abhor', + 'abide', + 'abled', + 'abode', + 'abort', ]; /// This class holds game state for a single round of Bulls and Cows, /// and exposes methods that a UI would need to manage the game state. /// -/// On it's own, this class won't manage a game. For example, it won't -/// call [startGame] on it's own. It assumes that a client will use it's -/// methods to progress through a game. +/// On it's own, this class won't manage a game. +/// For example, it won't call [resetGame] on its own. +/// It assumes that a client will use its methods to progress through a game. class Game { Game({this.numAllowedGuesses = defaultNumGuesses, this.seed}) { _wordToGuess = seed == null ? Word.random() : Word.fromSeed(seed!); @@ -76,7 +76,7 @@ class Game { bool get didWin { if (_guesses.first.isEmpty) return false; - for (var letter in previousGuess) { + for (final letter in previousGuess) { if (letter.type != HitType.hit) return false; } @@ -94,7 +94,7 @@ class Game { // Doesn't move the game forward, only executes match logic. Word matchGuessOnly(String guess) { // The hidden word will be used by subsequent guesses. - var hiddenCopy = Word.fromString(_wordToGuess.toString()); + final hiddenCopy = Word.fromString(_wordToGuess.toString()); return Word.fromString(guess).evaluateGuess(hiddenCopy); } @@ -112,16 +112,16 @@ class Word with IterableMixin { } factory Word.fromString(String guess) { - var list = guess.toLowerCase().split(''); - var letters = list - .map((String char) => (char: char, type: HitType.none)) + final list = guess.toLowerCase().split(''); + final letters = list + .map((char) => (char: char, type: HitType.none)) .toList(); return Word(letters); } factory Word.random() { - var rand = Random(); - var nextWord = legalWords[rand.nextInt(legalWords.length)]; + final rand = Random(); + final nextWord = legalWords[rand.nextInt(legalWords.length)]; return Word.fromString(nextWord); } @@ -148,7 +148,7 @@ class Word with IterableMixin { @override String toString() { - return _letters.map((Letter c) => c.char).join().trim(); + return _letters.map((c) => c.char).join().trim(); } // Used to play game in the CLI implementation @@ -168,7 +168,7 @@ extension WordUtils on Word { } /// Compares two [Word] objects and returns a new [Word] that - /// has the same letters as the [this], but each [Letter] + /// has the same letters as this word, but each [Letter] /// has new a [HitType] of either [HitType.hit], /// [HitType.partial], or [HitType.miss]. Word evaluateGuess(Word other) { @@ -188,12 +188,12 @@ extension WordUtils on Word { for (var i = 0; i < other.length; i++) { // If a letter in the hidden word is already marked as "removed", // then it's already an exact match, so skip it - Letter targetLetter = other[i]; + final targetLetter = other[i]; if (targetLetter.type != HitType.none) continue; // loop through the guessed word onces for each letter in the hidden word for (var j = 0; j < length; j++) { - Letter guessedLetter = this[j]; + final guessedLetter = this[j]; // skip letters that have already been marked as exact matches if (guessedLetter.type != HitType.none) continue; // If this letter, which must not be in the same position, is the same, diff --git a/examples/fwe/birdle/lib/main.dart b/examples/fwe/birdle/lib/main.dart index f059d0ba04e..30ad42c4c51 100644 --- a/examples/fwe/birdle/lib/main.dart +++ b/examples/fwe/birdle/lib/main.dart @@ -14,9 +14,12 @@ class MainApp extends StatelessWidget { return MaterialApp( home: Scaffold( appBar: AppBar( - title: Align(alignment: Alignment.centerLeft, child: Text('Birdle')), + title: const Align( + alignment: Alignment.centerLeft, + child: Text('Birdle'), + ), ), - body: Center(child: GamePage()), + body: const Center(child: GamePage()), ), ); } @@ -42,16 +45,16 @@ class _GamePageState extends State { spacing: 5.0, mainAxisAlignment: MainAxisAlignment.center, children: [ - for (var guess in _game.guesses) + for (final guess in _game.guesses) Row( spacing: 5.0, mainAxisAlignment: MainAxisAlignment.center, children: [ - for (var letter in guess) Tile(letter.char, letter.type), + for (final letter in guess) Tile(letter.char, letter.type), ], ), GuessInput( - onSubmitGuess: (String guess) { + onSubmitGuess: (guess) { setState(() { _game.guess(guess); }); @@ -98,7 +101,7 @@ class GuessInput extends StatelessWidget { controller: _textEditingController, autofocus: true, focusNode: _focusNode, - onSubmitted: (String input) { + onSubmitted: (input) { _onSubmit(); }, ), diff --git a/examples/fwe/birdle/lib/step1_main.dart b/examples/fwe/birdle/lib/step1_main.dart index a2dd8274a3b..067c1e6443f 100644 --- a/examples/fwe/birdle/lib/step1_main.dart +++ b/examples/fwe/birdle/lib/step1_main.dart @@ -1,4 +1,3 @@ -// ignore_for_file: unused_import, unused_field, unused_local_variable, avoid_print, prefer_const_constructors_in_immutables, use_key_in_widget_constructors, sized_box_for_whitespace import 'package:flutter/material.dart'; // #docregion main diff --git a/examples/fwe/birdle/lib/step2_main.dart b/examples/fwe/birdle/lib/step2_main.dart index c6e622a7d77..80273d12291 100644 --- a/examples/fwe/birdle/lib/step2_main.dart +++ b/examples/fwe/birdle/lib/step2_main.dart @@ -1,4 +1,5 @@ -// ignore_for_file: unused_import, unused_field, unused_local_variable, avoid_print, prefer_const_constructors_in_immutables, use_key_in_widget_constructors, sized_box_for_whitespace +// ignore_for_file: prefer_const_constructors + import 'package:flutter/material.dart'; import 'game.dart'; diff --git a/examples/fwe/birdle/lib/step2a_main.dart b/examples/fwe/birdle/lib/step2a_main.dart index cd17708632e..5517bef2278 100644 --- a/examples/fwe/birdle/lib/step2a_main.dart +++ b/examples/fwe/birdle/lib/step2a_main.dart @@ -1,4 +1,3 @@ -// ignore_for_file: unused_import, unused_field, unused_local_variable, avoid_print, prefer_const_constructors_in_immutables, use_key_in_widget_constructors, sized_box_for_whitespace import 'package:flutter/material.dart'; import 'game.dart'; diff --git a/examples/fwe/birdle/lib/step2b_main.dart b/examples/fwe/birdle/lib/step2b_main.dart index 2a4bbf5bdcc..f7501d09a32 100644 --- a/examples/fwe/birdle/lib/step2b_main.dart +++ b/examples/fwe/birdle/lib/step2b_main.dart @@ -1,4 +1,3 @@ -// ignore_for_file: unused_import, unused_field, unused_local_variable, avoid_print, prefer_const_constructors_in_immutables, use_key_in_widget_constructors, sized_box_for_whitespace import 'package:flutter/material.dart'; import 'game.dart'; diff --git a/examples/fwe/birdle/lib/step2c_main.dart b/examples/fwe/birdle/lib/step2c_main.dart index 51b8301fcbe..b10b9334e8b 100644 --- a/examples/fwe/birdle/lib/step2c_main.dart +++ b/examples/fwe/birdle/lib/step2c_main.dart @@ -1,4 +1,5 @@ -// ignore_for_file: unused_import, unused_field, unused_local_variable, avoid_print, prefer_const_constructors_in_immutables, use_key_in_widget_constructors, sized_box_for_whitespace +// ignore_for_file: sized_box_for_whitespace + import 'package:flutter/material.dart'; import 'game.dart'; diff --git a/examples/fwe/birdle/lib/step2d_main.dart b/examples/fwe/birdle/lib/step2d_main.dart index 4a99d110c82..70a9f8a9414 100644 --- a/examples/fwe/birdle/lib/step2d_main.dart +++ b/examples/fwe/birdle/lib/step2d_main.dart @@ -1,4 +1,3 @@ -// ignore_for_file: unused_import, unused_field, unused_local_variable, avoid_print, prefer_const_constructors_in_immutables, use_key_in_widget_constructors, sized_box_for_whitespace import 'package:flutter/material.dart'; import 'game.dart'; diff --git a/examples/fwe/birdle/lib/step2e_main.dart b/examples/fwe/birdle/lib/step2e_main.dart index f57ebad773e..a58a597a2b7 100644 --- a/examples/fwe/birdle/lib/step2e_main.dart +++ b/examples/fwe/birdle/lib/step2e_main.dart @@ -1,4 +1,3 @@ -// ignore_for_file: unused_import, unused_field, unused_local_variable, avoid_print, prefer_const_constructors_in_immutables, use_key_in_widget_constructors, sized_box_for_whitespace import 'package:flutter/material.dart'; import 'game.dart'; diff --git a/examples/fwe/birdle/lib/step2f_main.dart b/examples/fwe/birdle/lib/step2f_main.dart index d564ba9f2b3..1c93e12b17c 100644 --- a/examples/fwe/birdle/lib/step2f_main.dart +++ b/examples/fwe/birdle/lib/step2f_main.dart @@ -1,4 +1,3 @@ -// ignore_for_file: unused_import, unused_field, unused_local_variable, avoid_print, prefer_const_constructors_in_immutables, use_key_in_widget_constructors, sized_box_for_whitespace import 'package:flutter/material.dart'; import 'game.dart'; diff --git a/examples/fwe/birdle/lib/step3_main.dart b/examples/fwe/birdle/lib/step3_main.dart index 50660e0bb16..b9499465126 100644 --- a/examples/fwe/birdle/lib/step3_main.dart +++ b/examples/fwe/birdle/lib/step3_main.dart @@ -1,10 +1,6 @@ -// ignore_for_file: unused_import, unused_field, unused_local_variable, avoid_print, prefer_const_constructors_in_immutables, use_key_in_widget_constructors, sized_box_for_whitespace import 'package:flutter/material.dart'; import 'game.dart'; -import 'step2_main.dart' - show Tile; // Use Tile from step2 for simplicity, or just define it here. -// But actually the excerpt tool just reads the file, so redefining `Tile` is fine, we just don't tag it. class Tile extends StatelessWidget { const Tile(this.letter, this.hitType, {super.key}); final String letter; @@ -25,7 +21,10 @@ class MainApp extends StatelessWidget { home: Scaffold( // #docregion AppBar appBar: AppBar( - title: Align(alignment: Alignment.centerLeft, child: Text('Birdle')), + title: const Align( + alignment: Alignment.centerLeft, + child: Text('Birdle'), + ), ), // #enddocregion AppBar body: Center(child: GamePage()), @@ -51,12 +50,12 @@ class GamePage extends StatelessWidget { spacing: 5.0, children: [ // #docregion Rows - for (var guess in _game.guesses) + for (final guess in _game.guesses) Row( spacing: 5.0, children: [ // #docregion TileLoop - for (var letter in guess) Tile(letter.char, letter.type), + for (final letter in guess) Tile(letter.char, letter.type), // #enddocregion TileLoop ], ), diff --git a/examples/fwe/birdle/lib/step3a_main.dart b/examples/fwe/birdle/lib/step3a_main.dart index 436fe7e73e8..81f821cdbfb 100644 --- a/examples/fwe/birdle/lib/step3a_main.dart +++ b/examples/fwe/birdle/lib/step3a_main.dart @@ -1,4 +1,5 @@ -// ignore_for_file: unused_import, unused_field, unused_local_variable, avoid_print, prefer_const_constructors_in_immutables, use_key_in_widget_constructors, sized_box_for_whitespace +// ignore_for_file: unused_field + import 'package:flutter/material.dart'; import 'game.dart'; diff --git a/examples/fwe/birdle/lib/step3b_main.dart b/examples/fwe/birdle/lib/step3b_main.dart index 25945c8218c..1cce99f92d4 100644 --- a/examples/fwe/birdle/lib/step3b_main.dart +++ b/examples/fwe/birdle/lib/step3b_main.dart @@ -1,4 +1,5 @@ -// ignore_for_file: unused_import, unused_field, unused_local_variable, avoid_print, prefer_const_constructors_in_immutables, use_key_in_widget_constructors, sized_box_for_whitespace +// ignore_for_file: prefer_const_literals_to_create_immutables, unused_field, prefer_const_constructors + import 'package:flutter/material.dart'; import 'game.dart'; diff --git a/examples/fwe/birdle/lib/step3c_main.dart b/examples/fwe/birdle/lib/step3c_main.dart index 6e1e1fd7f51..e5d38aa4884 100644 --- a/examples/fwe/birdle/lib/step3c_main.dart +++ b/examples/fwe/birdle/lib/step3c_main.dart @@ -1,4 +1,5 @@ -// ignore_for_file: unused_import, unused_field, unused_local_variable, avoid_print, prefer_const_constructors_in_immutables, use_key_in_widget_constructors, sized_box_for_whitespace +// ignore_for_file: unused_local_variable, prefer_const_literals_to_create_immutables, prefer_const_constructors + import 'package:flutter/material.dart'; import 'game.dart'; @@ -15,7 +16,7 @@ class GamePage extends StatelessWidget { child: Column( spacing: 5.0, children: [ - for (var guess in _game.guesses) + for (final guess in _game.guesses) Row( spacing: 5.0, children: [ diff --git a/examples/fwe/birdle/lib/step4_main.dart b/examples/fwe/birdle/lib/step4_main.dart index c4715051035..f8d6cb6c173 100644 --- a/examples/fwe/birdle/lib/step4_main.dart +++ b/examples/fwe/birdle/lib/step4_main.dart @@ -1,4 +1,3 @@ -// ignore_for_file: unused_import, unused_field, unused_local_variable, avoid_print, prefer_const_constructors_in_immutables, use_key_in_widget_constructors, sized_box_for_whitespace import 'package:flutter/material.dart'; import 'game.dart'; import 'step2_main.dart' show Tile; @@ -15,11 +14,11 @@ class GamePage extends StatelessWidget { child: Column( spacing: 5.0, children: [ - for (var guess in _game.guesses) + for (final guess in _game.guesses) Row( spacing: 5.0, children: [ - for (var letter in guess) Tile(letter.char, letter.type), + for (final letter in guess) Tile(letter.char, letter.type), ], ), // #docregion GuessInputInstance @@ -73,7 +72,7 @@ class GuessInput extends StatelessWidget { ), ), controller: _textEditingController, - onSubmitted: (String value) { + onSubmitted: (value) { _onSubmit(); }, ), diff --git a/examples/fwe/birdle/lib/step4a_main.dart b/examples/fwe/birdle/lib/step4a_main.dart index ab64c11a1c9..c754561ab1c 100644 --- a/examples/fwe/birdle/lib/step4a_main.dart +++ b/examples/fwe/birdle/lib/step4a_main.dart @@ -1,4 +1,5 @@ -// ignore_for_file: unused_import, unused_field, unused_local_variable, avoid_print, prefer_const_constructors_in_immutables, use_key_in_widget_constructors, sized_box_for_whitespace +// ignore_for_file: prefer_const_constructors_in_immutables + import 'package:flutter/material.dart'; // #docregion GuessInput diff --git a/examples/fwe/birdle/lib/step4b_main.dart b/examples/fwe/birdle/lib/step4b_main.dart index fc195160398..3771531e787 100644 --- a/examples/fwe/birdle/lib/step4b_main.dart +++ b/examples/fwe/birdle/lib/step4b_main.dart @@ -1,4 +1,5 @@ -// ignore_for_file: unused_import, unused_field, unused_local_variable, avoid_print, prefer_const_constructors_in_immutables, use_key_in_widget_constructors, sized_box_for_whitespace +// ignore_for_file: prefer_const_constructors_in_immutables, prefer_const_literals_to_create_immutables, prefer_const_constructors + import 'package:flutter/material.dart'; // #docregion GuessInput diff --git a/examples/fwe/birdle/lib/step4c_main.dart b/examples/fwe/birdle/lib/step4c_main.dart index f820aaf92f0..fcf5967e173 100644 --- a/examples/fwe/birdle/lib/step4c_main.dart +++ b/examples/fwe/birdle/lib/step4c_main.dart @@ -1,4 +1,5 @@ -// ignore_for_file: unused_import, unused_field, unused_local_variable, avoid_print, prefer_const_constructors_in_immutables, use_key_in_widget_constructors, sized_box_for_whitespace +// ignore_for_file: prefer_const_literals_to_create_immutables, unused_field, prefer_const_constructors + import 'package:flutter/material.dart'; // #docregion GuessInput diff --git a/examples/fwe/birdle/lib/step4d_main.dart b/examples/fwe/birdle/lib/step4d_main.dart index 0af4c27cc9a..02a0cd47924 100644 --- a/examples/fwe/birdle/lib/step4d_main.dart +++ b/examples/fwe/birdle/lib/step4d_main.dart @@ -1,4 +1,3 @@ -// ignore_for_file: unused_import, unused_field, unused_local_variable, avoid_print, prefer_const_constructors_in_immutables, use_key_in_widget_constructors, sized_box_for_whitespace import 'package:flutter/material.dart'; // #docregion GuessInput diff --git a/examples/fwe/birdle/lib/step4e_main.dart b/examples/fwe/birdle/lib/step4e_main.dart index 0a2ffc790a3..53f89dcfb1a 100644 --- a/examples/fwe/birdle/lib/step4e_main.dart +++ b/examples/fwe/birdle/lib/step4e_main.dart @@ -1,4 +1,3 @@ -// ignore_for_file: unused_import, unused_field, unused_local_variable, avoid_print, prefer_const_constructors_in_immutables, use_key_in_widget_constructors, sized_box_for_whitespace import 'package:flutter/material.dart'; // #docregion GuessInput @@ -24,7 +23,7 @@ class GuessInput extends StatelessWidget { ), ), controller: _textEditingController, - onSubmitted: (String input) { + onSubmitted: (input) { // NEW print(_textEditingController.text); // Temporary }, diff --git a/examples/fwe/birdle/lib/step4f_main.dart b/examples/fwe/birdle/lib/step4f_main.dart index 9fe2df27407..3668ec06eef 100644 --- a/examples/fwe/birdle/lib/step4f_main.dart +++ b/examples/fwe/birdle/lib/step4f_main.dart @@ -1,4 +1,3 @@ -// ignore_for_file: unused_import, unused_field, unused_local_variable, avoid_print, prefer_const_constructors_in_immutables, use_key_in_widget_constructors, sized_box_for_whitespace import 'package:flutter/material.dart'; // #docregion GuessInput diff --git a/examples/fwe/birdle/lib/step4g_main.dart b/examples/fwe/birdle/lib/step4g_main.dart index cb160d8953f..0cdcd5e3047 100644 --- a/examples/fwe/birdle/lib/step4g_main.dart +++ b/examples/fwe/birdle/lib/step4g_main.dart @@ -1,4 +1,3 @@ -// ignore_for_file: unused_import, unused_field, unused_local_variable, avoid_print, prefer_const_constructors_in_immutables, use_key_in_widget_constructors, sized_box_for_whitespace import 'package:flutter/material.dart'; // #docregion GuessInput @@ -25,7 +24,7 @@ class GuessInput extends StatelessWidget { ), controller: _textEditingController, autofocus: true, // NEW - onSubmitted: (String input) { + onSubmitted: (input) { print(input); // Temporary _textEditingController.clear(); }, diff --git a/examples/fwe/birdle/lib/step4h_main.dart b/examples/fwe/birdle/lib/step4h_main.dart index cf2ba7fc25e..53908106cbb 100644 --- a/examples/fwe/birdle/lib/step4h_main.dart +++ b/examples/fwe/birdle/lib/step4h_main.dart @@ -1,4 +1,5 @@ -// ignore_for_file: unused_import, unused_field, unused_local_variable, avoid_print, prefer_const_constructors_in_immutables, use_key_in_widget_constructors, sized_box_for_whitespace +// ignore_for_file: unused_field + import 'package:flutter/material.dart'; // #docregion GuessInput diff --git a/examples/fwe/birdle/lib/step4i_main.dart b/examples/fwe/birdle/lib/step4i_main.dart index 222a7005f3c..e55ad66db09 100644 --- a/examples/fwe/birdle/lib/step4i_main.dart +++ b/examples/fwe/birdle/lib/step4i_main.dart @@ -1,4 +1,3 @@ -// ignore_for_file: unused_import, unused_field, unused_local_variable, avoid_print, prefer_const_constructors_in_immutables, use_key_in_widget_constructors, sized_box_for_whitespace import 'package:flutter/material.dart'; // #docregion GuessInput @@ -28,7 +27,7 @@ class GuessInput extends StatelessWidget { controller: _textEditingController, autofocus: true, focusNode: _focusNode, // NEW - onSubmitted: (String input) { + onSubmitted: (input) { print(input); // Temporary _textEditingController.clear(); _focusNode.requestFocus(); // NEW diff --git a/examples/fwe/birdle/lib/step4j_main.dart b/examples/fwe/birdle/lib/step4j_main.dart index ad05a6cfc9b..0786503955a 100644 --- a/examples/fwe/birdle/lib/step4j_main.dart +++ b/examples/fwe/birdle/lib/step4j_main.dart @@ -1,4 +1,3 @@ -// ignore_for_file: unused_import, unused_field, unused_local_variable, avoid_print, prefer_const_constructors_in_immutables, use_key_in_widget_constructors, sized_box_for_whitespace import 'package:flutter/material.dart'; // #docregion GuessInput @@ -28,7 +27,7 @@ class GuessInput extends StatelessWidget { controller: _textEditingController, autofocus: true, focusNode: _focusNode, - onSubmitted: (String input) { + onSubmitted: (input) { onSubmitGuess(_textEditingController.text.trim()); _textEditingController.clear(); _focusNode.requestFocus(); diff --git a/examples/fwe/birdle/lib/step4k_main.dart b/examples/fwe/birdle/lib/step4k_main.dart index 38d5a332554..40e02410617 100644 --- a/examples/fwe/birdle/lib/step4k_main.dart +++ b/examples/fwe/birdle/lib/step4k_main.dart @@ -1,10 +1,13 @@ -// ignore_for_file: unused_import, unused_field, unused_local_variable, avoid_print, prefer_const_constructors_in_immutables, use_key_in_widget_constructors, sized_box_for_whitespace +// ignore_for_file: prefer_const_constructors_in_immutables + import 'package:flutter/material.dart'; import 'game.dart'; import 'step2_main.dart' show Tile; // #docregion GamePage class GamePage extends StatelessWidget { + GamePage({super.key}); + final Game _game = Game(); @override @@ -14,15 +17,15 @@ class GamePage extends StatelessWidget { child: Column( spacing: 5.0, children: [ - for (var guess in _game.guesses) + for (final guess in _game.guesses) Row( spacing: 5.0, children: [ - for (var letter in guess) Tile(letter.char, letter.type), + for (final letter in guess) Tile(letter.char, letter.type), ], ), GuessInput( - onSubmitGuess: (String guess) { + onSubmitGuess: (guess) { // TODO, handle guess print(guess); // Temporary }, diff --git a/examples/fwe/birdle/lib/step4l_main.dart b/examples/fwe/birdle/lib/step4l_main.dart index 63af3c20fd5..e26edcef986 100644 --- a/examples/fwe/birdle/lib/step4l_main.dart +++ b/examples/fwe/birdle/lib/step4l_main.dart @@ -1,4 +1,5 @@ -// ignore_for_file: unused_import, unused_field, unused_local_variable, avoid_print, prefer_const_constructors_in_immutables, use_key_in_widget_constructors, sized_box_for_whitespace +// ignore_for_file: prefer_const_constructors, unused_field + import 'package:flutter/material.dart'; // #docregion GuessInput @@ -17,7 +18,7 @@ class GuessInput extends StatelessWidget { Expanded(child: Container()), IconButton( padding: EdgeInsets.zero, - icon: Icon(Icons.arrow_circle_up), + icon: const Icon(Icons.arrow_circle_up), onPressed: null, ), ], diff --git a/examples/fwe/birdle/lib/step4m_main.dart b/examples/fwe/birdle/lib/step4m_main.dart index 55d292182d4..c1fc3013b2c 100644 --- a/examples/fwe/birdle/lib/step4m_main.dart +++ b/examples/fwe/birdle/lib/step4m_main.dart @@ -1,4 +1,3 @@ -// ignore_for_file: unused_import, unused_field, unused_local_variable, avoid_print, prefer_const_constructors_in_immutables, use_key_in_widget_constructors, sized_box_for_whitespace import 'package:flutter/material.dart'; // #docregion GuessInput @@ -17,7 +16,7 @@ class GuessInput extends StatelessWidget { Expanded(child: Container()), IconButton( padding: EdgeInsets.zero, - icon: Icon(Icons.arrow_circle_up), + icon: const Icon(Icons.arrow_circle_up), onPressed: () { onSubmitGuess(_textEditingController.text.trim()); _textEditingController.clear(); diff --git a/examples/fwe/birdle/lib/step5_main.dart b/examples/fwe/birdle/lib/step5_main.dart index 43b5d591697..5f70bd334e4 100644 --- a/examples/fwe/birdle/lib/step5_main.dart +++ b/examples/fwe/birdle/lib/step5_main.dart @@ -1,4 +1,3 @@ -// ignore_for_file: unused_import, unused_field, unused_local_variable, avoid_print, prefer_const_constructors_in_immutables, use_key_in_widget_constructors, sized_box_for_whitespace import 'package:flutter/material.dart'; import 'game.dart'; import 'step2_main.dart' show Tile; @@ -23,11 +22,11 @@ class _GamePageState extends State { padding: const EdgeInsets.all(8.0), child: Column( children: [ - for (var guess in _game.guesses) + for (final guess in _game.guesses) Row( mainAxisAlignment: MainAxisAlignment.center, children: [ - for (var letter in guess) + for (final letter in guess) Padding( padding: const EdgeInsets.symmetric( horizontal: 2.5, @@ -39,7 +38,7 @@ class _GamePageState extends State { ), GuessInput( // #docregion GuessInputInstance - onSubmitGuess: (String guess) { + onSubmitGuess: (guess) { // #docregion setState setState(() { // NEW diff --git a/examples/fwe/birdle/pubspec.yaml b/examples/fwe/birdle/pubspec.yaml index 026c3b982d8..09999ff4de8 100644 --- a/examples/fwe/birdle/pubspec.yaml +++ b/examples/fwe/birdle/pubspec.yaml @@ -1,8 +1,9 @@ name: birdle -description: "A new Flutter project." -publish_to: 'none' -version: 0.1.0+1 +description: >- + Code excerpts for the Birdle example app in the Flutter tutorial. +publish_to: none +resolution: workspace environment: sdk: ^3.11.0 @@ -13,7 +14,6 @@ dependencies: dev_dependencies: flutter_test: sdk: flutter - flutter_lints: ^6.0.0 flutter: uses-material-design: true diff --git a/examples/fwe/rolodex/README.md b/examples/fwe/rolodex/README.md new file mode 100644 index 00000000000..0bd26cd6385 --- /dev/null +++ b/examples/fwe/rolodex/README.md @@ -0,0 +1,4 @@ +# Rolodex app + +Code excerpts for the Rolodex example app built in +the [Flutter tutorial](https://docs.flutter.dev/learn/pathway/tutorial). diff --git a/examples/fwe/rolodex/lib/step1_advanced_ui/data/contact_group.dart b/examples/fwe/rolodex/lib/step1_advanced_ui/data/contact_group.dart index 256e49599a0..9c4c841de35 100644 --- a/examples/fwe/rolodex/lib/step1_advanced_ui/data/contact_group.dart +++ b/examples/fwe/rolodex/lib/step1_advanced_ui/data/contact_group.dart @@ -42,9 +42,9 @@ class ContactGroup { List get contacts => _contacts; AlphabetizedContactMap get alphabetizedContacts { - final AlphabetizedContactMap contactsMap = AlphabetizedContactMap(); - for (final Contact contact in _contacts) { - final String lastInitial = contact.lastName[0].toUpperCase(); + final contactsMap = AlphabetizedContactMap(); + for (final contact in _contacts) { + final lastInitial = contact.lastName[0].toUpperCase(); if (contactsMap.containsKey(lastInitial)) { contactsMap[lastInitial]!.add(contact); } else { @@ -64,16 +64,16 @@ typedef AlphabetizedContactMap = SplayTreeMap>; /// If names are identical, sorts by contact ID to ensure consistent ordering. void _sortContacts(List contacts) { contacts.sort((a, b) { - final int checkLastName = a.lastName.compareTo(b.lastName); + final checkLastName = a.lastName.compareTo(b.lastName); if (checkLastName != 0) { return checkLastName; } - final int checkFirstName = a.firstName.compareTo(b.firstName); + final checkFirstName = a.firstName.compareTo(b.firstName); if (checkFirstName != 0) { return checkFirstName; } if (a.middleName != null && b.middleName != null) { - final int checkMiddleName = a.middleName!.compareTo(b.middleName!); + final checkMiddleName = a.middleName!.compareTo(b.middleName!); if (checkMiddleName != 0) { return checkMiddleName; } diff --git a/examples/fwe/rolodex/lib/step2_adaptive_layout/data/contact_group.dart b/examples/fwe/rolodex/lib/step2_adaptive_layout/data/contact_group.dart index 86954f27e57..c964ebe955f 100644 --- a/examples/fwe/rolodex/lib/step2_adaptive_layout/data/contact_group.dart +++ b/examples/fwe/rolodex/lib/step2_adaptive_layout/data/contact_group.dart @@ -41,9 +41,9 @@ class ContactGroup { List get contacts => _contacts; AlphabetizedContactMap get alphabetizedContacts { - final AlphabetizedContactMap contactsMap = AlphabetizedContactMap(); - for (final Contact contact in _contacts) { - final String lastInitial = contact.lastName[0].toUpperCase(); + final contactsMap = AlphabetizedContactMap(); + for (final contact in _contacts) { + final lastInitial = contact.lastName[0].toUpperCase(); if (contactsMap.containsKey(lastInitial)) { contactsMap[lastInitial]!.add(contact); } else { @@ -61,16 +61,16 @@ typedef AlphabetizedContactMap = SplayTreeMap>; /// If names are identical, sorts by contact ID to ensure consistent ordering. void _sortContacts(List contacts) { contacts.sort((a, b) { - final int checkLastName = a.lastName.compareTo(b.lastName); + final checkLastName = a.lastName.compareTo(b.lastName); if (checkLastName != 0) { return checkLastName; } - final int checkFirstName = a.firstName.compareTo(b.firstName); + final checkFirstName = a.firstName.compareTo(b.firstName); if (checkFirstName != 0) { return checkFirstName; } if (a.middleName != null && b.middleName != null) { - final int checkMiddleName = a.middleName!.compareTo(b.middleName!); + final checkMiddleName = a.middleName!.compareTo(b.middleName!); if (checkMiddleName != 0) { return checkMiddleName; } diff --git a/examples/fwe/rolodex/lib/step3_slivers/data/contact_group.dart b/examples/fwe/rolodex/lib/step3_slivers/data/contact_group.dart index 86954f27e57..c964ebe955f 100644 --- a/examples/fwe/rolodex/lib/step3_slivers/data/contact_group.dart +++ b/examples/fwe/rolodex/lib/step3_slivers/data/contact_group.dart @@ -41,9 +41,9 @@ class ContactGroup { List get contacts => _contacts; AlphabetizedContactMap get alphabetizedContacts { - final AlphabetizedContactMap contactsMap = AlphabetizedContactMap(); - for (final Contact contact in _contacts) { - final String lastInitial = contact.lastName[0].toUpperCase(); + final contactsMap = AlphabetizedContactMap(); + for (final contact in _contacts) { + final lastInitial = contact.lastName[0].toUpperCase(); if (contactsMap.containsKey(lastInitial)) { contactsMap[lastInitial]!.add(contact); } else { @@ -61,16 +61,16 @@ typedef AlphabetizedContactMap = SplayTreeMap>; /// If names are identical, sorts by contact ID to ensure consistent ordering. void _sortContacts(List contacts) { contacts.sort((a, b) { - final int checkLastName = a.lastName.compareTo(b.lastName); + final checkLastName = a.lastName.compareTo(b.lastName); if (checkLastName != 0) { return checkLastName; } - final int checkFirstName = a.firstName.compareTo(b.firstName); + final checkFirstName = a.firstName.compareTo(b.firstName); if (checkFirstName != 0) { return checkFirstName; } if (a.middleName != null && b.middleName != null) { - final int checkMiddleName = a.middleName!.compareTo(b.middleName!); + final checkMiddleName = a.middleName!.compareTo(b.middleName!); if (checkMiddleName != 0) { return checkMiddleName; } diff --git a/examples/fwe/rolodex/lib/step3_slivers/screens/contact_groups.dart b/examples/fwe/rolodex/lib/step3_slivers/screens/contact_groups.dart index cd7690f3afa..6b581732344 100644 --- a/examples/fwe/rolodex/lib/step3_slivers/screens/contact_groups.dart +++ b/examples/fwe/rolodex/lib/step3_slivers/screens/contact_groups.dart @@ -22,7 +22,7 @@ class _ContactGroupsView extends StatelessWidget { const _ContactGroupsView({required this.onListSelected, this.selectedListId}); final int? selectedListId; - final Function(ContactGroup) onListSelected; + final void Function(ContactGroup) onListSelected; @override Widget build(BuildContext context) { diff --git a/examples/fwe/rolodex/lib/step3_slivers/screens/contact_groups_v1.dart b/examples/fwe/rolodex/lib/step3_slivers/screens/contact_groups_v1.dart index 5f62b7b585a..414574672d9 100644 --- a/examples/fwe/rolodex/lib/step3_slivers/screens/contact_groups_v1.dart +++ b/examples/fwe/rolodex/lib/step3_slivers/screens/contact_groups_v1.dart @@ -25,7 +25,7 @@ class _ContactGroupsView extends StatelessWidget { const _ContactGroupsView({required this.onListSelected, this.selectedListId}); final int? selectedListId; - final Function(ContactGroup) onListSelected; + final void Function(ContactGroup) onListSelected; @override Widget build(BuildContext context) { diff --git a/examples/fwe/rolodex/lib/step3_slivers/screens/contacts.dart b/examples/fwe/rolodex/lib/step3_slivers/screens/contacts.dart index 02dbb7f8a06..a695a544086 100644 --- a/examples/fwe/rolodex/lib/step3_slivers/screens/contacts.dart +++ b/examples/fwe/rolodex/lib/step3_slivers/screens/contacts.dart @@ -35,12 +35,9 @@ class _ContactListView extends StatelessWidget { child: ValueListenableBuilder>( valueListenable: contactGroupsModel.listsNotifier, builder: (context, contactGroups, child) { - final ContactGroup contactList = contactGroupsModel.findContactList( - listId, - ); + final contactList = contactGroupsModel.findContactList(listId); - final AlphabetizedContactMap contacts = - contactList.alphabetizedContacts; + final contacts = contactList.alphabetizedContacts; return CustomScrollView( slivers: [ diff --git a/examples/fwe/rolodex/lib/step3_slivers/screens/contacts_v1.dart b/examples/fwe/rolodex/lib/step3_slivers/screens/contacts_v1.dart index 616949cd84d..af54d2995cd 100644 --- a/examples/fwe/rolodex/lib/step3_slivers/screens/contacts_v1.dart +++ b/examples/fwe/rolodex/lib/step3_slivers/screens/contacts_v1.dart @@ -34,9 +34,7 @@ class _ContactListView extends StatelessWidget { child: ValueListenableBuilder>( valueListenable: contactGroupsModel.listsNotifier, builder: (context, contactGroups, child) { - final ContactGroup contactList = contactGroupsModel.findContactList( - listId, - ); + final contactList = contactGroupsModel.findContactList(listId); return CustomScrollView( slivers: [ diff --git a/examples/fwe/rolodex/lib/step3_slivers/screens/contacts_v2.dart b/examples/fwe/rolodex/lib/step3_slivers/screens/contacts_v2.dart index b1b51af43c1..84055864d40 100644 --- a/examples/fwe/rolodex/lib/step3_slivers/screens/contacts_v2.dart +++ b/examples/fwe/rolodex/lib/step3_slivers/screens/contacts_v2.dart @@ -34,9 +34,7 @@ class _ContactListView extends StatelessWidget { child: ValueListenableBuilder>( valueListenable: contactGroupsModel.listsNotifier, builder: (context, contactGroups, child) { - final ContactGroup contactList = contactGroupsModel.findContactList( - listId, - ); + final contactList = contactGroupsModel.findContactList(listId); return CustomScrollView( slivers: [ diff --git a/examples/fwe/rolodex/lib/step4_navigation/data/contact_group.dart b/examples/fwe/rolodex/lib/step4_navigation/data/contact_group.dart index 86954f27e57..c964ebe955f 100644 --- a/examples/fwe/rolodex/lib/step4_navigation/data/contact_group.dart +++ b/examples/fwe/rolodex/lib/step4_navigation/data/contact_group.dart @@ -41,9 +41,9 @@ class ContactGroup { List get contacts => _contacts; AlphabetizedContactMap get alphabetizedContacts { - final AlphabetizedContactMap contactsMap = AlphabetizedContactMap(); - for (final Contact contact in _contacts) { - final String lastInitial = contact.lastName[0].toUpperCase(); + final contactsMap = AlphabetizedContactMap(); + for (final contact in _contacts) { + final lastInitial = contact.lastName[0].toUpperCase(); if (contactsMap.containsKey(lastInitial)) { contactsMap[lastInitial]!.add(contact); } else { @@ -61,16 +61,16 @@ typedef AlphabetizedContactMap = SplayTreeMap>; /// If names are identical, sorts by contact ID to ensure consistent ordering. void _sortContacts(List contacts) { contacts.sort((a, b) { - final int checkLastName = a.lastName.compareTo(b.lastName); + final checkLastName = a.lastName.compareTo(b.lastName); if (checkLastName != 0) { return checkLastName; } - final int checkFirstName = a.firstName.compareTo(b.firstName); + final checkFirstName = a.firstName.compareTo(b.firstName); if (checkFirstName != 0) { return checkFirstName; } if (a.middleName != null && b.middleName != null) { - final int checkMiddleName = a.middleName!.compareTo(b.middleName!); + final checkMiddleName = a.middleName!.compareTo(b.middleName!); if (checkMiddleName != 0) { return checkMiddleName; } diff --git a/examples/fwe/rolodex/lib/step4_navigation/screens/contact_groups.dart b/examples/fwe/rolodex/lib/step4_navigation/screens/contact_groups.dart index 10e8c03d6b7..58dd7f6bf6a 100644 --- a/examples/fwe/rolodex/lib/step4_navigation/screens/contact_groups.dart +++ b/examples/fwe/rolodex/lib/step4_navigation/screens/contact_groups.dart @@ -13,7 +13,7 @@ class ContactGroupsPage extends StatelessWidget { Widget build(BuildContext context) { return _ContactGroupsView( onListSelected: (list) => Navigator.of(context).push( - CupertinoPageRoute( + CupertinoPageRoute( title: list.title, builder: (context) => ContactListsPage(listId: list.id), ), @@ -33,7 +33,7 @@ class ContactGroupsSidebar extends StatelessWidget { }); final int selectedListId; - final Function(int) onListSelected; + final void Function(int) onListSelected; @override Widget build(BuildContext context) { @@ -49,7 +49,7 @@ class _ContactGroupsView extends StatelessWidget { const _ContactGroupsView({required this.onListSelected, this.selectedListId}); final int? selectedListId; - final Function(ContactGroup) onListSelected; + final void Function(ContactGroup) onListSelected; @override Widget build(BuildContext context) { diff --git a/examples/fwe/rolodex/lib/step4_navigation/screens/contacts.dart b/examples/fwe/rolodex/lib/step4_navigation/screens/contacts.dart index 1602990d426..768230ee3a8 100644 --- a/examples/fwe/rolodex/lib/step4_navigation/screens/contacts.dart +++ b/examples/fwe/rolodex/lib/step4_navigation/screens/contacts.dart @@ -43,12 +43,9 @@ class _ContactListView extends StatelessWidget { child: ValueListenableBuilder>( valueListenable: contactGroupsModel.listsNotifier, builder: (context, contactGroups, child) { - final ContactGroup contactList = contactGroupsModel.findContactList( - listId, - ); + final contactList = contactGroupsModel.findContactList(listId); - final AlphabetizedContactMap contacts = - contactList.alphabetizedContacts; + final contacts = contactList.alphabetizedContacts; return CustomScrollView( slivers: [ diff --git a/examples/fwe/rolodex/pubspec.yaml b/examples/fwe/rolodex/pubspec.yaml index 23fb072d3b7..f3d34939328 100644 --- a/examples/fwe/rolodex/pubspec.yaml +++ b/examples/fwe/rolodex/pubspec.yaml @@ -1,8 +1,9 @@ name: rolodex -description: Rolodex example for FWE Part 3. -version: 1.0.0+1 -publish_to: 'none' +description: >- + Code excerpts for the Rolodex example app in the Flutter tutorial. +publish_to: none +resolution: workspace environment: sdk: ^3.11.0 @@ -14,7 +15,6 @@ dependencies: dev_dependencies: flutter_test: sdk: flutter - flutter_lints: ^6.0.0 flutter: uses-material-design: true diff --git a/examples/fwe/wikipedia_reader/README.md b/examples/fwe/wikipedia_reader/README.md index b8b0a1613e2..2ec265d536e 100644 --- a/examples/fwe/wikipedia_reader/README.md +++ b/examples/fwe/wikipedia_reader/README.md @@ -1,3 +1,4 @@ -# wikipedia_reader +# Wikipedia reader app -Code excerpts for the Wikipedia reader app in the Flutter tutorial. +Code excerpts for the Wikipedia reader app built in +the [Flutter tutorial](https://docs.flutter.dev/learn/pathway/tutorial). diff --git a/examples/fwe/wikipedia_reader/lib/step3e_main.dart b/examples/fwe/wikipedia_reader/lib/step3e_main.dart index 9f46f8d9e7a..e2f21faa337 100644 --- a/examples/fwe/wikipedia_reader/lib/step3e_main.dart +++ b/examples/fwe/wikipedia_reader/lib/step3e_main.dart @@ -1,5 +1,3 @@ -// ignore_for_file: unused_import, avoid_dynamic_calls, avoid_print - import 'dart:io'; import 'package:flutter/material.dart'; diff --git a/examples/fwe/wikipedia_reader/pubspec.yaml b/examples/fwe/wikipedia_reader/pubspec.yaml index 057d66c0e0c..3910df12408 100644 --- a/examples/fwe/wikipedia_reader/pubspec.yaml +++ b/examples/fwe/wikipedia_reader/pubspec.yaml @@ -1,7 +1,9 @@ name: wikipedia_reader -description: Code excerpts for the Wikipedia reader app in the Flutter tutorial. +description: >- + Code excerpts for the Wikipedia reader app in the Flutter tutorial. publish_to: none +resolution: workspace environment: sdk: ^3.11.0 @@ -13,7 +15,6 @@ dependencies: dev_dependencies: flutter_test: sdk: flutter - flutter_lints: ^6.0.0 flutter: uses-material-design: true diff --git a/examples/pubspec.yaml b/examples/pubspec.yaml index 84208b495a0..cb57c6b650d 100644 --- a/examples/pubspec.yaml +++ b/examples/pubspec.yaml @@ -93,6 +93,9 @@ workspace: - cookbook/testing/widget/tap_drag - data-and-backend/json - deployment/obfuscate + - fwe/birdle + - fwe/rolodex + - fwe/wikipedia_reader - get-started/flutter-for/android_devs - get-started/flutter-for/declarative - get-started/flutter-for/ios_devs diff --git a/src/_snippets/tutorial/game-code.dart b/src/_snippets/tutorial/game-code.dart index 43c577b04fc..6b22c3221c4 100644 --- a/src/_snippets/tutorial/game-code.dart +++ b/src/_snippets/tutorial/game-code.dart @@ -27,9 +27,9 @@ const legalGuesses = [ /// This class holds game state for a single round of Bulls and Cows, /// and exposes methods that a UI would need to manage the game state. /// -/// On it's own, this class won't manage a game. For example, it won't -/// call [startGame] on it's own. It assumes that a client will use it's -/// methods to progress through a game. +/// On it's own, this class won't manage a game. +/// For example, it won't call [resetGame] on its own. +/// It assumes that a client will use its methods to progress through a game. class Game { Game({this.numAllowedGuesses = defaultNumGuesses, this.seed}) { _wordToGuess = seed == null ? Word.random() : Word.fromSeed(seed!); diff --git a/src/content/learn/pathway/tutorial/advanced-ui.md b/src/content/learn/pathway/tutorial/advanced-ui.md index 53ee0df0b23..482152b8ee4 100644 --- a/src/content/learn/pathway/tutorial/advanced-ui.md +++ b/src/content/learn/pathway/tutorial/advanced-ui.md @@ -397,9 +397,9 @@ class ContactGroup { List get contacts => _contacts; AlphabetizedContactMap get alphabetizedContacts { - final AlphabetizedContactMap contactsMap = AlphabetizedContactMap(); - for (final Contact contact in _contacts) { - final String lastInitial = contact.lastName[0].toUpperCase(); + final contactsMap = AlphabetizedContactMap(); + for (final contact in _contacts) { + final lastInitial = contact.lastName[0].toUpperCase(); if (contactsMap.containsKey(lastInitial)) { contactsMap[lastInitial]!.add(contact); } else { @@ -425,16 +425,16 @@ typedef AlphabetizedContactMap = SplayTreeMap>; /// If names are identical, sorts by contact ID to ensure consistent ordering. void _sortContacts(List contacts) { contacts.sort((a, b) { - final int checkLastName = a.lastName.compareTo(b.lastName); + final checkLastName = a.lastName.compareTo(b.lastName); if (checkLastName != 0) { return checkLastName; } - final int checkFirstName = a.firstName.compareTo(b.firstName); + final checkFirstName = a.firstName.compareTo(b.firstName); if (checkFirstName != 0) { return checkFirstName; } if (a.middleName != null && b.middleName != null) { - final int checkMiddleName = a.middleName!.compareTo(b.middleName!); + final checkMiddleName = a.middleName!.compareTo(b.middleName!); if (checkMiddleName != 0) { return checkMiddleName; } diff --git a/src/content/learn/pathway/tutorial/layout.md b/src/content/learn/pathway/tutorial/layout.md index 3284f179a63..94b5d478826 100644 --- a/src/content/learn/pathway/tutorial/layout.md +++ b/src/content/learn/pathway/tutorial/layout.md @@ -120,7 +120,7 @@ Then update your `MainPage` widget to create and display a `GamePage` widget instead of "Hello World!". -```dart highlightLines=11 +```dart highlightLines=14 class MainApp extends StatelessWidget { const MainApp({super.key}); @@ -129,7 +129,10 @@ class MainApp extends StatelessWidget { return MaterialApp( home: Scaffold( appBar: AppBar( - title: Align(alignment: Alignment.centerLeft, child: Text('Birdle')), + title: const Align( + alignment: Alignment.centerLeft, + child: Text('Birdle'), + ), ), body: Center(child: GamePage()), ), @@ -202,7 +205,7 @@ class GamePage extends StatelessWidget { child: Column( spacing: 5.0, children: [ - for (var guess in _game.guesses) + for (final guess in _game.guesses) Row( spacing: 5.0, children: [ @@ -262,11 +265,11 @@ class GamePage extends StatelessWidget { child: Column( spacing: 5.0, children: [ - for (var guess in _game.guesses) + for (final guess in _game.guesses) Row( spacing: 5.0, children: [ - for (var letter in guess) Tile(letter.char, letter.type), + for (final letter in guess) Tile(letter.char, letter.type), ], ), ], diff --git a/src/content/learn/pathway/tutorial/navigation.md b/src/content/learn/pathway/tutorial/navigation.md index 24b8c87179a..a1c4998b87b 100644 --- a/src/content/learn/pathway/tutorial/navigation.md +++ b/src/content/learn/pathway/tutorial/navigation.md @@ -81,7 +81,7 @@ class ContactGroupsPage extends StatelessWidget { Widget build(BuildContext context) { return _ContactGroupsView( onListSelected: (list) => Navigator.of(context).push( - CupertinoPageRoute( + CupertinoPageRoute( title: list.title, builder: (context) => ContactListsPage(listId: list.id), ), @@ -129,7 +129,7 @@ class ContactGroupsSidebar extends StatelessWidget { }); final int selectedListId; - final Function(int) onListSelected; + final void Function(int) onListSelected; @override Widget build(BuildContext context) { diff --git a/src/content/learn/pathway/tutorial/slivers.md b/src/content/learn/pathway/tutorial/slivers.md index 9ccecc54842..0727faaeb45 100644 --- a/src/content/learn/pathway/tutorial/slivers.md +++ b/src/content/learn/pathway/tutorial/slivers.md @@ -91,7 +91,7 @@ class _ContactGroupsView extends StatelessWidget { const _ContactGroupsView({required this.onListSelected, this.selectedListId}); final int? selectedListId; - final Function(ContactGroup) onListSelected; + final void Function(ContactGroup) onListSelected; @override Widget build(BuildContext context) { @@ -321,9 +321,7 @@ class _ContactListView extends StatelessWidget { child: ValueListenableBuilder>( valueListenable: contactGroupsModel.listsNotifier, builder: (context, contactGroups, child) { - final ContactGroup contactList = contactGroupsModel.findContactList( - listId, - ); + final contactList = contactGroupsModel.findContactList(listId); return CustomScrollView( slivers: [ @@ -383,9 +381,7 @@ class _ContactListView extends StatelessWidget { child: ValueListenableBuilder>( valueListenable: contactGroupsModel.listsNotifier, builder: (context, contactGroups, child) { - final ContactGroup contactList = contactGroupsModel.findContactList( - listId, - ); + final contactList = contactGroupsModel.findContactList(listId); return CustomScrollView( slivers: [ @@ -493,12 +489,9 @@ class _ContactListView extends StatelessWidget { child: ValueListenableBuilder>( valueListenable: contactGroupsModel.listsNotifier, builder: (context, contactGroups, child) { - final ContactGroup contactList = contactGroupsModel.findContactList( - listId, - ); + final contactList = contactGroupsModel.findContactList(listId); - final AlphabetizedContactMap contacts = - contactList.alphabetizedContacts; + final contacts = contactList.alphabetizedContacts; return CustomScrollView( slivers: [ diff --git a/src/content/learn/pathway/tutorial/user-input.md b/src/content/learn/pathway/tutorial/user-input.md index b11a9ecc5b5..40b37408fcc 100644 --- a/src/content/learn/pathway/tutorial/user-input.md +++ b/src/content/learn/pathway/tutorial/user-input.md @@ -251,7 +251,7 @@ class GuessInput extends StatelessWidget { ), ), controller: _textEditingController, - onSubmitted: (String input) { + onSubmitted: (input) { // NEW print(_textEditingController.text); // Temporary }, @@ -353,7 +353,7 @@ class GuessInput extends StatelessWidget { ), controller: _textEditingController, autofocus: true, // NEW - onSubmitted: (String input) { + onSubmitted: (input) { print(input); // Temporary _textEditingController.clear(); }, @@ -424,7 +424,7 @@ class GuessInput extends StatelessWidget { controller: _textEditingController, autofocus: true, focusNode: _focusNode, // NEW - onSubmitted: (String input) { + onSubmitted: (input) { print(input); // Temporary _textEditingController.clear(); _focusNode.requestFocus(); // NEW @@ -479,7 +479,7 @@ class GuessInput extends StatelessWidget { controller: _textEditingController, autofocus: true, focusNode: _focusNode, - onSubmitted: (String input) { + onSubmitted: (input) { onSubmitGuess(_textEditingController.text.trim()); _textEditingController.clear(); _focusNode.requestFocus(); @@ -506,6 +506,8 @@ add the `GuessInput` widget: ```dart class GamePage extends StatelessWidget { + GamePage({super.key}); + final Game _game = Game(); @override @@ -515,15 +517,15 @@ class GamePage extends StatelessWidget { child: Column( spacing: 5.0, children: [ - for (var guess in _game.guesses) + for (final guess in _game.guesses) Row( spacing: 5.0, children: [ - for (var letter in guess) Tile(letter.char, letter.type), + for (final letter in guess) Tile(letter.char, letter.type), ], ), GuessInput( - onSubmitGuess: (String guess) { + onSubmitGuess: (guess) { // TODO, handle guess print(guess); // Temporary }, @@ -577,7 +579,7 @@ class GuessInput extends StatelessWidget { Expanded(child: Container()), IconButton( padding: EdgeInsets.zero, - icon: Icon(Icons.arrow_circle_up), + icon: const Icon(Icons.arrow_circle_up), onPressed: null, ), ], @@ -605,7 +607,7 @@ class GuessInput extends StatelessWidget { Expanded(child: Container()), IconButton( padding: EdgeInsets.zero, - icon: Icon(Icons.arrow_circle_up), + icon: const Icon(Icons.arrow_circle_up), onPressed: () { onSubmitGuess(_textEditingController.text.trim()); _textEditingController.clear(); @@ -671,7 +673,7 @@ class GuessInput extends StatelessWidget { ), ), controller: _textEditingController, - onSubmitted: (String value) { + onSubmitted: (value) { _onSubmit(); }, ), From b02400e98bad52cb69253f3cc842dc827398bece Mon Sep 17 00:00:00 2001 From: Parker Lougheed Date: Sun, 19 Apr 2026 15:50:26 +0200 Subject: [PATCH 2/3] Organize imports --- examples/fwe/birdle/lib/main.dart | 1 + examples/fwe/birdle/lib/step2_main.dart | 1 + examples/fwe/birdle/lib/step2a_main.dart | 1 + examples/fwe/birdle/lib/step2b_main.dart | 1 + examples/fwe/birdle/lib/step2c_main.dart | 1 + examples/fwe/birdle/lib/step2d_main.dart | 1 + examples/fwe/birdle/lib/step2e_main.dart | 1 + examples/fwe/birdle/lib/step2f_main.dart | 1 + examples/fwe/birdle/lib/step3_main.dart | 1 + examples/fwe/birdle/lib/step3a_main.dart | 1 + examples/fwe/birdle/lib/step3b_main.dart | 1 + examples/fwe/birdle/lib/step3c_main.dart | 1 + examples/fwe/birdle/lib/step4_main.dart | 1 + examples/fwe/birdle/lib/step4k_main.dart | 1 + examples/fwe/birdle/lib/step5_main.dart | 1 + 15 files changed, 15 insertions(+) diff --git a/examples/fwe/birdle/lib/main.dart b/examples/fwe/birdle/lib/main.dart index 30ad42c4c51..062a1c6a716 100644 --- a/examples/fwe/birdle/lib/main.dart +++ b/examples/fwe/birdle/lib/main.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; + import 'game.dart'; void main() { diff --git a/examples/fwe/birdle/lib/step2_main.dart b/examples/fwe/birdle/lib/step2_main.dart index 80273d12291..e8f5b64cf00 100644 --- a/examples/fwe/birdle/lib/step2_main.dart +++ b/examples/fwe/birdle/lib/step2_main.dart @@ -1,6 +1,7 @@ // ignore_for_file: prefer_const_constructors import 'package:flutter/material.dart'; + import 'game.dart'; void main() { diff --git a/examples/fwe/birdle/lib/step2a_main.dart b/examples/fwe/birdle/lib/step2a_main.dart index 5517bef2278..a880634f6de 100644 --- a/examples/fwe/birdle/lib/step2a_main.dart +++ b/examples/fwe/birdle/lib/step2a_main.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; + import 'game.dart'; // #docregion Tile diff --git a/examples/fwe/birdle/lib/step2b_main.dart b/examples/fwe/birdle/lib/step2b_main.dart index f7501d09a32..3cf854b6bfd 100644 --- a/examples/fwe/birdle/lib/step2b_main.dart +++ b/examples/fwe/birdle/lib/step2b_main.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; + import 'game.dart'; // #docregion Tile diff --git a/examples/fwe/birdle/lib/step2c_main.dart b/examples/fwe/birdle/lib/step2c_main.dart index b10b9334e8b..7542f1edd16 100644 --- a/examples/fwe/birdle/lib/step2c_main.dart +++ b/examples/fwe/birdle/lib/step2c_main.dart @@ -1,6 +1,7 @@ // ignore_for_file: sized_box_for_whitespace import 'package:flutter/material.dart'; + import 'game.dart'; // #docregion Tile diff --git a/examples/fwe/birdle/lib/step2d_main.dart b/examples/fwe/birdle/lib/step2d_main.dart index 70a9f8a9414..348ea08742b 100644 --- a/examples/fwe/birdle/lib/step2d_main.dart +++ b/examples/fwe/birdle/lib/step2d_main.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; + import 'game.dart'; // #docregion Tile diff --git a/examples/fwe/birdle/lib/step2e_main.dart b/examples/fwe/birdle/lib/step2e_main.dart index a58a597a2b7..1651ee06072 100644 --- a/examples/fwe/birdle/lib/step2e_main.dart +++ b/examples/fwe/birdle/lib/step2e_main.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; + import 'game.dart'; // #docregion Tile diff --git a/examples/fwe/birdle/lib/step2f_main.dart b/examples/fwe/birdle/lib/step2f_main.dart index 1c93e12b17c..53e4108f93b 100644 --- a/examples/fwe/birdle/lib/step2f_main.dart +++ b/examples/fwe/birdle/lib/step2f_main.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; + import 'game.dart'; // #docregion Tile diff --git a/examples/fwe/birdle/lib/step3_main.dart b/examples/fwe/birdle/lib/step3_main.dart index b9499465126..f07905ea888 100644 --- a/examples/fwe/birdle/lib/step3_main.dart +++ b/examples/fwe/birdle/lib/step3_main.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; + import 'game.dart'; class Tile extends StatelessWidget { diff --git a/examples/fwe/birdle/lib/step3a_main.dart b/examples/fwe/birdle/lib/step3a_main.dart index 81f821cdbfb..0c53e8db663 100644 --- a/examples/fwe/birdle/lib/step3a_main.dart +++ b/examples/fwe/birdle/lib/step3a_main.dart @@ -1,6 +1,7 @@ // ignore_for_file: unused_field import 'package:flutter/material.dart'; + import 'game.dart'; // #docregion GamePage diff --git a/examples/fwe/birdle/lib/step3b_main.dart b/examples/fwe/birdle/lib/step3b_main.dart index 1cce99f92d4..e3b9fb17e08 100644 --- a/examples/fwe/birdle/lib/step3b_main.dart +++ b/examples/fwe/birdle/lib/step3b_main.dart @@ -1,6 +1,7 @@ // ignore_for_file: prefer_const_literals_to_create_immutables, unused_field, prefer_const_constructors import 'package:flutter/material.dart'; + import 'game.dart'; // #docregion GamePage diff --git a/examples/fwe/birdle/lib/step3c_main.dart b/examples/fwe/birdle/lib/step3c_main.dart index e5d38aa4884..9d18cc5b105 100644 --- a/examples/fwe/birdle/lib/step3c_main.dart +++ b/examples/fwe/birdle/lib/step3c_main.dart @@ -1,6 +1,7 @@ // ignore_for_file: unused_local_variable, prefer_const_literals_to_create_immutables, prefer_const_constructors import 'package:flutter/material.dart'; + import 'game.dart'; // #docregion GamePage diff --git a/examples/fwe/birdle/lib/step4_main.dart b/examples/fwe/birdle/lib/step4_main.dart index f8d6cb6c173..1940ab78c10 100644 --- a/examples/fwe/birdle/lib/step4_main.dart +++ b/examples/fwe/birdle/lib/step4_main.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; + import 'game.dart'; import 'step2_main.dart' show Tile; diff --git a/examples/fwe/birdle/lib/step4k_main.dart b/examples/fwe/birdle/lib/step4k_main.dart index 40e02410617..0d72f28fa18 100644 --- a/examples/fwe/birdle/lib/step4k_main.dart +++ b/examples/fwe/birdle/lib/step4k_main.dart @@ -1,6 +1,7 @@ // ignore_for_file: prefer_const_constructors_in_immutables import 'package:flutter/material.dart'; + import 'game.dart'; import 'step2_main.dart' show Tile; diff --git a/examples/fwe/birdle/lib/step5_main.dart b/examples/fwe/birdle/lib/step5_main.dart index 5f70bd334e4..38ee4f8067b 100644 --- a/examples/fwe/birdle/lib/step5_main.dart +++ b/examples/fwe/birdle/lib/step5_main.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; + import 'game.dart'; import 'step2_main.dart' show Tile; import 'step4_main.dart' show GuessInput; From 694735d520e853a28d2f173d15c5f2aabe4ab7cf Mon Sep 17 00:00:00 2001 From: Parker Lougheed Date: Sun, 19 Apr 2026 17:36:03 +0200 Subject: [PATCH 3/3] Apply copy suggestion from Gemini review Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> --- examples/fwe/birdle/lib/game.dart | 2 +- src/_snippets/tutorial/game-code.dart | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/fwe/birdle/lib/game.dart b/examples/fwe/birdle/lib/game.dart index 3c223e0ef4f..135475a6f4f 100644 --- a/examples/fwe/birdle/lib/game.dart +++ b/examples/fwe/birdle/lib/game.dart @@ -27,7 +27,7 @@ const legalGuesses = [ /// This class holds game state for a single round of Bulls and Cows, /// and exposes methods that a UI would need to manage the game state. /// -/// On it's own, this class won't manage a game. +/// On its own, this class won't manage a game. /// For example, it won't call [resetGame] on its own. /// It assumes that a client will use its methods to progress through a game. class Game { diff --git a/src/_snippets/tutorial/game-code.dart b/src/_snippets/tutorial/game-code.dart index 6b22c3221c4..5e8fb69afd5 100644 --- a/src/_snippets/tutorial/game-code.dart +++ b/src/_snippets/tutorial/game-code.dart @@ -27,7 +27,7 @@ const legalGuesses = [ /// This class holds game state for a single round of Bulls and Cows, /// and exposes methods that a UI would need to manage the game state. /// -/// On it's own, this class won't manage a game. +/// On its own, this class won't manage a game. /// For example, it won't call [resetGame] on its own. /// It assumes that a client will use its methods to progress through a game. class Game {