【解决方式】删除.dart_tool文件夹后重新build
在example中,第一次build失败。删除app.route.dart文件后,build成功。再次删除app.route.dart文件后,build生成的文件不完整,内容如下
// GENERATED CODE - DO NOT MODIFY BY HAND
// **************************************************************************
// RouteGenerator
// **************************************************************************
import 'package:flutter/material.dart';
RouteFactory onGenerateRoute =
(settings) => Map.fromEntries([])settings.name;
==========================第一次======================
D:\a_test\flutter\route_generator_repo\example>flutter pub run build_runner build
[INFO] Generating build script...
[INFO] Generating build script completed, took 250ms
[INFO] Creating build script snapshot......
[INFO] Creating build script snapshot... completed, took 8.2s
[INFO] Initializing inputs
[INFO] Building new asset graph...
[INFO] Building new asset graph completed, took 854ms
[INFO] Checking for unexpected pre-existing outputs....
[INFO] Found 1 declared outputs which already exist on disk. This is likely because the.dart_tool/build
folder was deleted, or you are submitting generated files to your source repository.
[SEVERE] Conflicting outputs were detected and the build is unable to prompt for permission to remove them. These outputs must be removed manually or the build can be run with --delete-conflicting-outputs
. The outputs are: lib/app.route.dart
pub failed (78)
==========================第二次======================
D:\a_test\flutter\route_generator_repo\example>flutter pub run build_runner build
[INFO] Generating build script...
[INFO] Generating build script completed, took 251ms
[WARNING] Deleted previous snapshot due to missing asset graph.
[INFO] Creating build script snapshot......
[INFO] Creating build script snapshot... completed, took 8.3s
[INFO] Initializing inputs
[INFO] Building new asset graph...
[INFO] Building new asset graph completed, took 808ms
[INFO] Checking for unexpected pre-existing outputs....
[INFO] Checking for unexpected pre-existing outputs. completed, took 1ms
[INFO] Running build...
[INFO] 1.0s elapsed, 43/56 actions completed.
[INFO] 2.0s elapsed, 169/184 actions completed.
[INFO] 4.5s elapsed, 259/275 actions completed.
[INFO] 5.5s elapsed, 358/374 actions completed.
[INFO] 6.6s elapsed, 586/602 actions completed.
[INFO] 7.7s elapsed, 846/858 actions completed.
[INFO] 8.7s elapsed, 940/956 actions completed.
[INFO] 9.9s elapsed, 1160/1176 actions completed.
[INFO] 10.9s elapsed, 1160/1176 actions completed.
[INFO] 12.0s elapsed, 1160/1176 actions completed.
[INFO] 13.0s elapsed, 1249/1265 actions completed.
[INFO] 14.1s elapsed, 1368/1384 actions completed.
[INFO] 15.2s elapsed, 1492/1504 actions completed.
[INFO] 16.2s elapsed, 1652/1667 actions completed.
[INFO] 17.2s elapsed, 1933/1949 actions completed.
[INFO] 18.2s elapsed, 2061/2070 actions completed.
[INFO] Running build completed, took 18.6s
[INFO] Caching finalized dependency graph...
[INFO] Caching finalized dependency graph completed, took 86ms
[INFO] Succeeded after 18.7s with 1 outputs (2094 actions)
==========================第三次======================
D:\a_test\flutter\route_generator_repo\example>flutter pub run build_runner build
[INFO] Generating build script...
[INFO] Generating build script completed, took 261ms
[INFO] Initializing inputs
[INFO] Reading cached asset graph...
[INFO] Reading cached asset graph completed, took 234ms
[INFO] Checking for updates since last build...
[INFO] Checking for updates since last build completed, took 751ms
[INFO] Running build...
[INFO] 4.2s elapsed, 0/1 actions completed.
[INFO] Running build completed, took 4.2s
[INFO] Caching finalized dependency graph...
[INFO] Caching finalized dependency graph completed, took 86ms
[INFO] Succeeded after 4.3s with 1 outputs (1 actions)