Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 35 additions & 30 deletions generate_crossword/codelab_rebuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ steps:
analyzer:
language:
strict-inference: false
exclude:
- lib/*.g.dart

linter:
rules:
Expand Down Expand Up @@ -199,13 +201,14 @@ steps:

import 'package:built_collection/built_collection.dart';
import 'package:flutter/services.dart';
import 'package:riverpod/riverpod.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';

part 'providers.g.dart';

/// A provider for the wordlist to use when generating the crossword.
@riverpod
Future<BuiltSet<String>> wordList(WordListRef ref) async {
Future<BuiltSet<String>> wordList(Ref ref) async {
// This codebase requires that all words consist of lowercase characters
// in the range 'a'-'z'. Words containing uppercase letters will be
// lowercased, and words containing runes outside this range will
Expand Down Expand Up @@ -49373,24 +49376,25 @@ steps:
patch: |
--- b/generate_crossword/step_04/lib/providers.dart
+++ a/generate_crossword/step_04/lib/providers.dart
@@ -3,11 +3,16 @@
@@ -3,12 +3,17 @@
// found in the LICENSE file.

import 'dart:convert';
+import 'dart:math';

import 'package:built_collection/built_collection.dart';
+import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart';
import 'package:riverpod/riverpod.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';

+import 'model.dart' as model;
+import 'utils.dart';
+
part 'providers.g.dart';

/// A provider for the wordlist to use when generating the crossword.
@@ -25,3 +30,72 @@ Future<BuiltSet<String>> wordList(WordListRef ref) async {
@@ -26,3 +31,72 @@ Future<BuiltSet<String>> wordList(Ref ref) async {
..where((word) => word.length > 2)
..where((word) => re.hasMatch(word)));
}
Expand Down Expand Up @@ -49430,7 +49434,7 @@ steps:
+final _random = Random();
+
+@riverpod
+Stream<model.Crossword> crossword(CrosswordRef ref) async* {
+Stream<model.Crossword> crossword(Ref ref) async* {
+ final size = ref.watch(sizeProvider);
+ final wordListAsync = ref.watch(wordListProvider);
+
Expand Down Expand Up @@ -50174,7 +50178,7 @@ steps:
patch: |
--- b/generate_crossword/step_05_a/lib/providers.dart
+++ a/generate_crossword/step_05_a/lib/providers.dart
@@ -82,10 +82,16 @@ Stream<model.Crossword> crossword(CrosswordRef ref) async* {
@@ -83,10 +83,16 @@ Stream<model.Crossword> crossword(Ref ref) async* {
final location = model.Location.at(
_random.nextInt(size.width), _random.nextInt(size.height));

Expand Down Expand Up @@ -50232,7 +50236,7 @@ steps:
patch: |
--- b/generate_crossword/step_05_b/lib/providers.dart
+++ a/generate_crossword/step_05_b/lib/providers.dart
@@ -81,16 +81,20 @@ Stream<model.Crossword> crossword(CrosswordRef ref) async* {
@@ -82,16 +82,20 @@ Stream<model.Crossword> crossword(Ref ref) async* {
_random.nextBool() ? model.Direction.across : model.Direction.down;
final location = model.Location.at(
_random.nextInt(size.width), _random.nextInt(size.height));
Expand Down Expand Up @@ -50343,15 +50347,16 @@ steps:
patch: |
--- b/generate_crossword/step_05_c/lib/providers.dart
+++ a/generate_crossword/step_05_c/lib/providers.dart
@@ -3,15 +3,14 @@
@@ -3,7 +3,6 @@
// found in the LICENSE file.

import 'dart:convert';
-import 'dart:math';

import 'package:built_collection/built_collection.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart';
@@ -11,8 +10,8 @@ import 'package:flutter/services.dart';
import 'package:riverpod/riverpod.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';

+import 'isolates.dart';
Expand All @@ -50360,14 +50365,14 @@ steps:

part 'providers.g.dart';

@@ -63,49 +62,25 @@ class Size extends _$Size {
@@ -64,49 +63,25 @@ class Size extends _$Size {
}
}

-final _random = Random();
-
@riverpod
Stream<model.Crossword> crossword(CrosswordRef ref) async* {
Stream<model.Crossword> crossword(Ref ref) async* {
final size = ref.watch(sizeProvider);
final wordListAsync = ref.watch(wordListProvider);

Expand Down Expand Up @@ -50950,12 +50955,12 @@ steps:

import 'package:built_collection/built_collection.dart';
import 'package:flutter/foundation.dart';
@@ -63,12 +64,19 @@ class Size extends _$Size {
@@ -64,12 +65,19 @@ class Size extends _$Size {
}

@riverpod
-Stream<model.Crossword> crossword(CrosswordRef ref) async* {
+Stream<model.WorkQueue> workQueue(WorkQueueRef ref) async* {
-Stream<model.Crossword> crossword(Ref ref) async* {
+Stream<model.WorkQueue> workQueue(Ref ref) async* {
final size = ref.watch(sizeProvider);
final wordListAsync = ref.watch(wordListProvider);
-
Expand All @@ -50972,7 +50977,7 @@ steps:

yield* wordListAsync.when(
data: (wordList) => exploreCrosswordSolutions(
@@ -77,10 +85,100 @@ Stream<model.Crossword> crossword(CrosswordRef ref) async* {
@@ -78,10 +86,100 @@ Stream<model.Crossword> crossword(Ref ref) async* {
),
error: (error, stackTrace) async* {
debugPrint('Error loading word list: $error');
Expand Down Expand Up @@ -51022,7 +51027,7 @@ steps:
+const _estimatedTotalCoverage = 0.54;
+
+@riverpod
+Duration expectedRemainingTime(ExpectedRemainingTimeRef ref) {
+Duration expectedRemainingTime(Ref ref) {
+ final startTime = ref.watch(startTimeProvider);
+ final endTime = ref.watch(endTimeProvider);
+ final workQueueAsync = ref.watch(workQueueProvider);
Expand Down Expand Up @@ -51544,23 +51549,23 @@ steps:
patch: |
--- b/generate_crossword/step_08/lib/providers.dart
+++ a/generate_crossword/step_08/lib/providers.dart
@@ -65,6 +65,7 @@ class Size extends _$Size {
@@ -66,6 +66,7 @@ class Size extends _$Size {

@riverpod
Stream<model.WorkQueue> workQueue(WorkQueueRef ref) async* {
Stream<model.WorkQueue> workQueue(Ref ref) async* {
+ final workers = ref.watch(workerCountProvider);
final size = ref.watch(sizeProvider);
final wordListAsync = ref.watch(wordListProvider);
final emptyCrossword =
@@ -82,6 +83,7 @@ Stream<model.WorkQueue> workQueue(WorkQueueRef ref) async* {
@@ -83,6 +84,7 @@ Stream<model.WorkQueue> workQueue(Ref ref) async* {
data: (wordList) => exploreCrosswordSolutions(
crossword: emptyCrossword,
wordList: wordList,
+ maxWorkerCount: workers.count,
),
error: (error, stackTrace) async* {
debugPrint('Error loading word list: $error');
@@ -182,3 +184,33 @@ class DisplayInfo extends _$DisplayInfo {
@@ -183,3 +185,33 @@ class DisplayInfo extends _$DisplayInfo {
loading: () => model.DisplayInfo.empty,
);
}
Expand Down Expand Up @@ -52201,24 +52206,24 @@ steps:

import 'package:built_collection/built_collection.dart';
import 'package:flutter/foundation.dart';
@@ -15,6 +14,8 @@ import 'model.dart' as model;
@@ -16,6 +15,8 @@ import 'model.dart' as model;

part 'providers.g.dart';

+const backgroundWorkerCount = 4;
+
/// A provider for the wordlist to use when generating the crossword.
@riverpod
Future<BuiltSet<String>> wordList(WordListRef ref) async {
@@ -65,7 +66,6 @@ class Size extends _$Size {
Future<BuiltSet<String>> wordList(Ref ref) async {
@@ -66,7 +67,6 @@ class Size extends _$Size {

@riverpod
Stream<model.WorkQueue> workQueue(WorkQueueRef ref) async* {
Stream<model.WorkQueue> workQueue(Ref ref) async* {
- final workers = ref.watch(workerCountProvider);
final size = ref.watch(sizeProvider);
final wordListAsync = ref.watch(wordListProvider);
final emptyCrossword =
@@ -76,14 +76,11 @@ Stream<model.WorkQueue> workQueue(WorkQueueRef ref) async* {
@@ -77,14 +77,11 @@ Stream<model.WorkQueue> workQueue(Ref ref) async* {
startLocation: model.Location.at(0, 0),
);

Expand All @@ -52234,7 +52239,7 @@ steps:
),
error: (error, stackTrace) async* {
debugPrint('Error loading word list: $error');
@@ -93,124 +90,78 @@ Stream<model.WorkQueue> workQueue(WorkQueueRef ref) async* {
@@ -94,124 +91,78 @@ Stream<model.WorkQueue> workQueue(Ref ref) async* {
yield emptyWorkQueue;
},
);
Expand Down Expand Up @@ -52276,7 +52281,7 @@ steps:
-const _estimatedTotalCoverage = 0.54;
-
@riverpod
-Duration expectedRemainingTime(ExpectedRemainingTimeRef ref) {
-Duration expectedRemainingTime(Ref ref) {
- final startTime = ref.watch(startTimeProvider);
- final endTime = ref.watch(endTimeProvider);
- final workQueueAsync = ref.watch(workQueueProvider);
Expand Down
2 changes: 2 additions & 0 deletions generate_crossword/step_02/analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ include: ../../analysis_options.yaml
analyzer:
language:
strict-inference: false
exclude:
- lib/*.g.dart

linter:
rules:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.3-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-all.zip
4 changes: 2 additions & 2 deletions generate_crossword/step_02/android/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ pluginManagement {

plugins {
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
id "com.android.application" version "7.3.0" apply false
id "org.jetbrains.kotlin.android" version "1.7.10" apply false
id "com.android.application" version "8.1.0" apply false
id "org.jetbrains.kotlin.android" version "1.8.22" apply false
}

include ":app"
18 changes: 9 additions & 9 deletions generate_crossword/step_02/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,29 @@ publish_to: 'none'
version: 0.1.0

environment:
sdk: ^3.5.1
sdk: ^3.5.3

dependencies:
flutter:
sdk: flutter
built_collection: ^5.1.1
built_value: ^8.9.2
characters: ^1.3.0
flutter_riverpod: ^2.5.1
flutter_riverpod: ^2.6.1
intl: ^0.19.0
riverpod: ^2.5.1
riverpod_annotation: ^2.3.5
two_dimensional_scrollables: ^0.3.1
riverpod: ^2.6.1
riverpod_annotation: ^2.6.1
two_dimensional_scrollables: ^0.3.3

dev_dependencies:
flutter_test:
sdk: flutter
flutter_lints: ^4.0.0
build_runner: ^2.4.12
build_runner: ^2.4.13
built_value_generator: ^8.9.2
custom_lint: ^0.6.5
riverpod_generator: ^2.4.3
riverpod_lint: ^2.3.13
custom_lint: ^0.6.8
riverpod_generator: ^2.6.1
riverpod_lint: ^2.6.1

flutter:
uses-material-design: true
2 changes: 2 additions & 0 deletions generate_crossword/step_03/analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ include: ../../analysis_options.yaml
analyzer:
language:
strict-inference: false
exclude:
- lib/*.g.dart

linter:
rules:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.3-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-all.zip
4 changes: 2 additions & 2 deletions generate_crossword/step_03/android/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ pluginManagement {

plugins {
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
id "com.android.application" version "7.3.0" apply false
id "org.jetbrains.kotlin.android" version "1.7.10" apply false
id "com.android.application" version "8.1.0" apply false
id "org.jetbrains.kotlin.android" version "1.8.22" apply false
}

include ":app"
3 changes: 2 additions & 1 deletion generate_crossword/step_03/lib/providers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@ import 'dart:convert';

import 'package:built_collection/built_collection.dart';
import 'package:flutter/services.dart';
import 'package:riverpod/riverpod.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';

part 'providers.g.dart';

/// A provider for the wordlist to use when generating the crossword.
@riverpod
Future<BuiltSet<String>> wordList(WordListRef ref) async {
Future<BuiltSet<String>> wordList(Ref ref) async {
// This codebase requires that all words consist of lowercase characters
// in the range 'a'-'z'. Words containing uppercase letters will be
// lowercased, and words containing runes outside this range will
Expand Down
6 changes: 4 additions & 2 deletions generate_crossword/step_03/lib/providers.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 9 additions & 9 deletions generate_crossword/step_03/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,29 @@ publish_to: 'none'
version: 0.1.0

environment:
sdk: ^3.5.1
sdk: ^3.5.3

dependencies:
flutter:
sdk: flutter
built_collection: ^5.1.1
built_value: ^8.9.2
characters: ^1.3.0
flutter_riverpod: ^2.5.1
flutter_riverpod: ^2.6.1
intl: ^0.19.0
riverpod: ^2.5.1
riverpod_annotation: ^2.3.5
two_dimensional_scrollables: ^0.3.1
riverpod: ^2.6.1
riverpod_annotation: ^2.6.1
two_dimensional_scrollables: ^0.3.3

dev_dependencies:
flutter_test:
sdk: flutter
flutter_lints: ^4.0.0
build_runner: ^2.4.12
build_runner: ^2.4.13
built_value_generator: ^8.9.2
custom_lint: ^0.6.5
riverpod_generator: ^2.4.3
riverpod_lint: ^2.3.13
custom_lint: ^0.6.8
riverpod_generator: ^2.6.1
riverpod_lint: ^2.6.1

flutter:
uses-material-design: true
Expand Down
Loading