Having just migrated my app (~35K LOC) to null safety, I think support for incremental migration in the tool is essential for the tool to be useful in real-world app scenarios. I found the following to be true:
late keyword), and the tool would make it nullable. In those cases, the tool was doing its job correctly, but the migration of the file required careful scrutiny on my part nonetheless.The combination of these observations meant that I couldn't just add hints, then migrate the whole project in one go. Attempting to do so would violate #1 in that I wouldn't have an easy way to see which files I had already completed the "add hints" pass to, and because of the analysis errors produced, it would mean that the project would be littered with analysis errors once I migrated everything.
Thus, I did the following process manually:
// @dart=2.9 comments to the header of each file.My manual incremental migration worked, but it strikes me that many (I daresay most) apps or packages will want to migrate incrementally as well, so our tools should support this use case better.
/cc @stereotype441 @mit-mit
Do you mean incremental within our own app's source code itself, or incremental in the sense that you wanted to migrate prior to your deps being available in null safety versions?
I mean within the app's source code itself.
Soon (hopefully next week) I'm intending to work on adding a feature to the migration tool that essentially automates @tvolkert's manual process. I'll use this issue to track my progress.
The workflow I currently have in mind is to have a set of checkboxes next to the file view in the migration tool; the user can check or uncheck these boxes to tell the tool whether they wish to migrate the given file during this run. For files/directories that are already migrated, instead of a checkbox we can have some clear indication that the file is already migrated (a green checkmark, perhaps). The first time the migration tool is run, if any files are not being migrated this time, // @dart=2.9 will be automatically added to those files. So the workflow would be:
// @dart=2.9 to the files you don't want to migrate.// @dart=2.9 annotatoins) and leaves the others alone.No need for sed scripts or reverts.
@tvolkert (and anyone else who is interested), feel free to comment if you have other workflow ideas.
That sounds great!
Most helpful comment
I mean within the app's source code itself.