Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate framework_core to null safety. #3743

Merged
merged 3 commits into from
Mar 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ import '_framework_initialize_stub.dart'

Future initializeFramework() async {
FrameworkCore.initGlobals();
final url = await initializePlatform();
FrameworkCore.init(url: url);
await initializePlatform();
FrameworkCore.init();
}
28 changes: 11 additions & 17 deletions packages/devtools_app/lib/src/framework/framework_core.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// @dart=2.9
// ignore_for_file: import_of_legacy_library_into_null_safe

import 'dart:async';

import 'package:flutter/foundation.dart';

import '../../devtools.dart' as devtools show version;
import '../config_specific/import_export/import_export.dart';
import '../config_specific/logger/logger.dart';
Expand All @@ -32,39 +30,35 @@ class FrameworkCore {
setGlobal(OfflineModeController, OfflineModeController());
}

static void init({String url}) {
static void init() {
// Print the version number at startup.
log('DevTools version ${devtools.version}.');
}

/// Returns true if we're able to connect to a device and false otherwise.
static Future<bool> initVmService(
String url, {
Uri explicitUri,
@required ErrorReporter errorReporter,
Uri? explicitUri,
required ErrorReporter errorReporter,
}) async {
if (serviceManager.hasConnection) {
// TODO(https://github.com/flutter/devtools/issues/1568): why do we call
// this multiple times?
return true;
}

final Uri uri = explicitUri ?? getServiceUriFromQueryString(url);
final Uri? uri = explicitUri ?? getServiceUriFromQueryString(url);
if (uri != null) {
final finishedCompleter = Completer<void>();

try {
final VmServiceWrapper service = await connect(uri, finishedCompleter);
if (serviceManager != null) {
await serviceManager.vmServiceOpened(
service,
onClosed: finishedCompleter.future,
);
return true;
} else {
errorReporter('Unable to connect to VM service at $uri', null);
return false;
}

await serviceManager.vmServiceOpened(
service,
onClosed: finishedCompleter.future,
);
return true;
} catch (e, st) {
log('$e\n$st', LogLevel.error);

Expand Down