@@ -183,7 +183,7 @@ class _MigrationTestEmitter {
183183
184184 /// Whether the core test package is unavailable and needs to be replaced with
185185 /// `flutter_test` .
186- final bool needsToUseFlutterTest ;
186+ final bool shouldUseFlutterTest ;
187187
188188 final File ? dumpGeneratedSchemaCode;
189189
@@ -220,7 +220,7 @@ class _MigrationTestEmitter {
220220 required this .db,
221221 required this .driftElements,
222222 required this .dumpGeneratedSchemaCode,
223- required this .needsToUseFlutterTest });
223+ required this .shouldUseFlutterTest });
224224
225225 static Future <_MigrationTestEmitter > create ({
226226 required DriftDevCli cli,
@@ -261,9 +261,11 @@ class _MigrationTestEmitter {
261261 }
262262
263263 final config = await cli.project.packageConfig;
264+ final hasFlutter = config? .packages.any ((e) => e.name == 'flutter' ) == true ;
264265 final hasTest = config? .packages.any ((e) => e.name == 'test' ) == true ;
265266 final hasFlutterTest =
266267 config? .packages.any ((e) => e.name == 'flutter_test' ) == true ;
268+
267269 if (! hasTest && ! hasFlutterTest) {
268270 cli.logger.warning ('No test package found for project, please add a'
269271 'dependency on flutter_test or test.' );
@@ -283,7 +285,9 @@ class _MigrationTestEmitter {
283285 testDatabasesDir: testDatabasesDir,
284286 schemaVersion: schemaVersion,
285287 dumpGeneratedSchemaCode: dumpGeneratedSchemaCode,
286- needsToUseFlutterTest: ! hasTest,
288+ // For packages depending on flutter, suggest running tests with `flutter
289+ // test` instead of `dart test`.
290+ shouldUseFlutterTest: hasFlutter,
287291 );
288292 await emitter._readSchemas ();
289293 return emitter;
@@ -382,7 +386,7 @@ ${blue.wrap("class")} ${green.wrap(dbClassName)} ${blue.wrap("extends")} ${green
382386 final packageName = cli.project.buildConfig.packageName;
383387 final relativeDbPath = p.posix.relative (dbClassFile.path,
384388 from: p.join (cli.project.directory.path, 'lib' ));
385- final testPackageName = needsToUseFlutterTest ? 'flutter_test' : 'test' ;
389+ final testPackageName = shouldUseFlutterTest ? 'flutter_test' : 'test' ;
386390
387391 final code = """
388392// ignore_for_file: unused_local_variable, unused_import
@@ -434,7 +438,7 @@ void main() {
434438}
435439""" ;
436440
437- final testCommand = needsToUseFlutterTest ? 'flutter' : 'dart' ;
441+ final testCommand = shouldUseFlutterTest ? 'flutter' : 'dart' ;
438442 cli.logger.info (
439443 '$dbName : Generated test in ${blue .wrap (p .relative (testFile .path ))}.\n '
440444 'Run this test to validate that your migrations are written correctly. ${yellow .wrap ("$testCommand test ${p .relative (testFile .path )}" )}' );
0 commit comments