MCPcopy Create free account
hub / github.com/Dart-Code/Dart-Code / createFlutterSampleInTempFolder

Function createFlutterSampleInTempFolder

src/shared/vscode/flutter_samples.ts:10–28  ·  view source on GitHub ↗
(flutterCapabilities: FlutterCapabilities, sampleID: string, flutterSdkOverride?: string)

Source from the content-addressed store, hash-verified

8import { writeFlutterSdkSettingIntoProject, writeFlutterTriggerFile } from "../utils/projects";
9
10export function createFlutterSampleInTempFolder(flutterCapabilities: FlutterCapabilities, sampleID: string, flutterSdkOverride?: string): vs.Uri | undefined {
11 // Create a temp folder for the sample.
12 const tempSamplePath = path.join(os.tmpdir(), dartCodeExtensionIdentifier, "flutter", "sample", sampleID, getRandomInt(0x1000, 0x10000).toString(16));
13
14 // Create the empty folder so we can open it.
15 mkDirRecursive(tempSamplePath);
16
17 const triggerData: FlutterCreateTriggerData = { sample: sampleID };
18 writeFlutterTriggerFile(tempSamplePath, triggerData);
19
20 // If we're using a custom SDK, we need to apply it to the new project too.
21 if (flutterSdkOverride)
22 writeFlutterSdkSettingIntoProject(flutterSdkOverride, tempSamplePath);
23
24 const folderUri = vs.Uri.file(tempSamplePath);
25 void vs.commands.executeCommand("vscode.openFolder", folderUri);
26
27 return folderUri;
28}

Callers 2

handleMethod · 0.90

Calls 6

getRandomIntFunction · 0.90
mkDirRecursiveFunction · 0.90
writeFlutterTriggerFileFunction · 0.90
executeCommandMethod · 0.65
toStringMethod · 0.45

Tested by

no test coverage detected