in flutter-idea/src/io/flutter/FlutterInitializer.java [68:214]
public void runActivity(@NotNull Project project) {
// Convert all modules of deprecated type FlutterModuleType.
if (FlutterModuleUtils.convertFromDeprecatedModuleType(project)) {
// If any modules were converted over, create a notification
FlutterMessages.showInfo(
FlutterBundle.message("flutter.initializer.module.converted.title"),
"Converted from '" + FlutterModuleUtils.DEPRECATED_FLUTTER_MODULE_TYPE_ID +
"' to '" + FlutterModuleUtils.getModuleTypeIDForFlutter() + "'.",
project);
}
// Disable the 'Migrate Project to Gradle' notification.
FlutterUtils.disableGradleProjectMigrationNotification(project);
// Start watching for devices.
DeviceService.getInstance(project);
// Start a DevTools server
DevToolsService.getInstance(project);
// If the project declares a Flutter dependency, do some extra initialization.
boolean hasFlutterModule = false;
for (Module module : ModuleManager.getInstance(project).getModules()) {
final boolean declaresFlutter = FlutterModuleUtils.declaresFlutter(module);
hasFlutterModule = hasFlutterModule || declaresFlutter;
if (!declaresFlutter) {
continue;
}
// Ensure SDKs are configured; needed for clean module import.
FlutterModuleUtils.enableDartSDK(module);
for (PubRoot root : PubRoots.forModule(module)) {
// Set Android SDK.
if (root.hasAndroidModule(project)) {
ensureAndroidSdk(project);
}
// Setup a default run configuration for 'main.dart' (if it's not there already and the file exists).
FlutterModuleUtils.autoCreateRunConfig(project, root);
// If there are no open editors, show main.
if (FileEditorManager.getInstance(project).getOpenFiles().length == 0) {
FlutterModuleUtils.autoShowMain(project, root);
}
}
}
if (hasFlutterModule || WorkspaceCache.getInstance(project).isBazel()) {
initializeToolWindows(project);
} else {
project.getMessageBus().connect().subscribe(ProjectTopics.MODULES, new ModuleListener() {
@Override
public void moduleAdded(@NotNull Project project, @NotNull Module module) {
if (!toolWindowsInitialized && FlutterModuleUtils.isFlutterModule(module)) {
initializeToolWindows(project);
}
}
});
}
if (hasFlutterModule) {
// Ensure a run config is selected and ready to go.
FlutterModuleUtils.ensureRunConfigSelected(project);
}
if (hasFlutterModule) {
// Check to see if we're on a supported version of Android Studio; warn otherwise.
performAndroidStudioCanaryCheck(project);
}
FlutterRunNotifications.init(project);
// Start watching for survey triggers.
FlutterSurveyNotifications.init(project);
// Start the widget perf manager.
FlutterWidgetPerfManager.init(project);
// Watch save actions for reload on save.
FlutterReloadManager.init(project);
// Watch save actions for format on save.
FlutterSaveActionsManager.init(project);
// Start watching for project structure and .packages file changes.
final FlutterPluginsLibraryManager libraryManager = new FlutterPluginsLibraryManager(project);
libraryManager.startWatching();
// Initialize the analytics notification group.
NotificationsConfiguration.getNotificationsConfiguration().register(
Analytics.GROUP_DISPLAY_ID,
NotificationDisplayType.STICKY_BALLOON,
false);
// Set our preferred settings for the run console.
FlutterConsoleLogManager.initConsolePreferences();
// Initialize analytics.
final PropertiesComponent properties = PropertiesComponent.getInstance();
if (!properties.getBoolean(analyticsToastShown)) {
properties.setValue(analyticsToastShown, true);
final Notification notification = new Notification(
Analytics.GROUP_DISPLAY_ID,
"Welcome to Flutter!",
FlutterBundle.message("flutter.analytics.notification.content"),
NotificationType.INFORMATION,
(notification1, event) -> {
if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
if ("url".equals(event.getDescription())) {
BrowserUtil.browse("https://www.google.com/policies/privacy/");
}
}
});
//noinspection DialogTitleCapitalization
notification.addAction(new AnAction("Sounds good!") {
@Override
public void actionPerformed(@NotNull AnActionEvent event) {
notification.expire();
final Analytics analytics = getAnalytics();
// We only track for flutter projects.
if (FlutterModuleUtils.declaresFlutter(project)) {
ToolWindowTracker.track(project, analytics);
}
}
});
//noinspection DialogTitleCapitalization
notification.addAction(new AnAction("No thanks") {
@Override
public void actionPerformed(@NotNull AnActionEvent event) {
notification.expire();
setCanReportAnalytics(false);
}
});
Notifications.Bus.notify(notification, project);
}
else {
// We only track for flutter projects.
if (FlutterModuleUtils.declaresFlutter(project)) {
ToolWindowTracker.track(project, getAnalytics());
}
}
}