@@ -105,6 +105,16 @@ export class SdkCommands {
105105 DartHoverProvider . clearPackageMapCaches ( ) ;
106106 }
107107 } ) ) ;
108+ context . subscriptions . push ( vs . commands . registerCommand ( "flutter.clean" , async ( selection ) : Promise < number | undefined > => {
109+ if ( ! selection ) {
110+ const path = await this . getFolderToRunCommandIn ( `Select the folder to run "flutter clean" in` , selection , true ) ;
111+ if ( ! path )
112+ return ;
113+ selection = vs . Uri . file ( path ) ;
114+ }
115+
116+ return this . runFlutter ( [ "clean" ] , selection ) ;
117+ } ) ) ;
108118 context . subscriptions . push ( vs . commands . registerCommand ( "_flutter.screenshot.touchBar" , ( args : any ) => vs . commands . executeCommand ( "flutter.screenshot" , args ) ) ) ;
109119 context . subscriptions . push ( vs . commands . registerCommand ( "flutter.screenshot" , async ( ) => {
110120 let shouldNotify = false ;
@@ -304,7 +314,7 @@ export class SdkCommands {
304314 return handler ( folderToRunCommandIn , args , shortPath ) ;
305315 }
306316
307- private async getFolderToRunCommandIn ( placeHolder : string , selection ?: vs . Uri ) : Promise < string | undefined > {
317+ private async getFolderToRunCommandIn ( placeHolder : string , selection ?: vs . Uri , flutterOnly = false ) : Promise < string | undefined > {
308318 // Attempt to find a project based on the supplied folder of active file.
309319 let file = selection && fsPath ( selection ) ;
310320 file = file || ( vs . window . activeTextEditor && fsPath ( vs . window . activeTextEditor . document . uri ) ) ;
@@ -316,17 +326,20 @@ export class SdkCommands {
316326 // Otherwise look for what projects we have.
317327 const rootFolders = util . getDartWorkspaceFolders ( ) . map ( ( wf ) => fsPath ( wf . uri ) ) ;
318328 const nestedProjectFolders = flatMap ( rootFolders , getChildFolders ) ;
319- const selectableFolders = rootFolders . concat ( nestedProjectFolders ) . filter ( hasPubspec ) ;
329+ const selectableFolders = rootFolders . concat ( nestedProjectFolders )
330+ . filter ( hasPubspec )
331+ . filter ( flutterOnly ? util . isFlutterProjectFolder : ( ) => true ) ;
332+
333+ if ( ! selectableFolders || ! selectableFolders . length ) {
334+ const projectTypes = flutterOnly ? "Flutter" : "Dart/Flutter" ;
335+ vs . window . showWarningMessage ( `No ${ projectTypes } projects were found.` ) ;
336+ return undefined ;
337+ }
320338
321339 return this . showFolderPicker ( selectableFolders , placeHolder ) ; // TODO: What if the user didn't pick anything?
322340 }
323341
324342 private async showFolderPicker ( folders : string [ ] , placeHolder : string ) : Promise < string | undefined > {
325- if ( ! folders || ! folders . length ) {
326- vs . window . showWarningMessage ( "No Dart/Flutter projects were found." ) ;
327- return undefined ;
328- }
329-
330343 // No point asking the user if there's only one.
331344 if ( folders . length === 1 ) {
332345 return folders [ 0 ] ;
0 commit comments