<commit_before>// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'dart:async';

import 'package:meta/meta.dart';
import 'package:vm_service/vm_service.dart';

import '../globals.dart';
import '../service_registrations.dart' as registrations;
import '../version.dart';

// TODO(kenzie): we should listen for flag value updates and update the settings
// screen with the new flag values. See
// https://github.com/flutter/devtools/issues/988.

typedef OnFlutterVersionChanged = void Function(FlutterVersion version);

typedef OnFlagListChanged = void Function(FlagList flagList);

class SettingsController {
  SettingsController({
    @required this.onFlutterVersionChanged,
    @required this.onFlagListChanged,
  });

  final OnFlutterVersionChanged onFlutterVersionChanged;

  final OnFlagListChanged onFlagListChanged;

  final flutterVersionServiceAvailable = Completer();

  Future<void> entering() async {
    onFlagListChanged(await serviceManager.service.getFlagList());
    await _onFlutterVersionChanged();
  }

  Future<void> _onFlutterVersionChanged() async {
    if (await serviceManager.connectedApp.isAnyFlutterApp) {
      serviceManager.hasRegisteredService(
        registrations.flutterVersion.service,
        (bool serviceAvailable) async {
          if (serviceAvailable && !flutterVersionServiceAvailable.isCompleted) {
            flutterVersionServiceAvailable.complete();
            final FlutterVersion version = FlutterVersion.parse(
                (await serviceManager.getFlutterVersion()).json);
            onFlutterVersionChanged(version);
          } else {
            onFlutterVersionChanged(null);
          }
        },
      );
    } else {
      onFlutterVersionChanged(null);
    }
  }
}
<commit_msg>Rename method in settings screen. (#991)<commit_after>// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'dart:async';

import 'package:meta/meta.dart';
import 'package:vm_service/vm_service.dart';

import '../globals.dart';
import '../service_registrations.dart' as registrations;
import '../version.dart';

// TODO(kenzie): we should listen for flag value updates and update the settings
// screen with the new flag values. See
// https://github.com/flutter/devtools/issues/988.

typedef OnFlutterVersionChanged = void Function(FlutterVersion version);

typedef OnFlagListChanged = void Function(FlagList flagList);

class SettingsController {
  SettingsController({
    @required this.onFlutterVersionChanged,
    @required this.onFlagListChanged,
  });

  final OnFlutterVersionChanged onFlutterVersionChanged;

  final OnFlagListChanged onFlagListChanged;

  final flutterVersionServiceAvailable = Completer();

  Future<void> entering() async {
    onFlagListChanged(await serviceManager.service.getFlagList());
    await _listenForFlutterVersionChanges();
  }

  Future<void> _listenForFlutterVersionChanges() async {
    if (await serviceManager.connectedApp.isAnyFlutterApp) {
      serviceManager.hasRegisteredService(
        registrations.flutterVersion.service,
        (bool serviceAvailable) async {
          if (serviceAvailable && !flutterVersionServiceAvailable.isCompleted) {
            flutterVersionServiceAvailable.complete();
            final FlutterVersion version = FlutterVersion.parse(
                (await serviceManager.getFlutterVersion()).json);
            onFlutterVersionChanged(version);
          } else {
            onFlutterVersionChanged(null);
          }
        },
      );
    } else {
      onFlutterVersionChanged(null);
    }
  }
}

{'fraction_non_alphanumeric': 0.09228321400159109, 'fraction_numerical': 0.004508088040307611, 'mean_word_length': 3.697384806973848, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2012252', 'n_tokens_mistral': 1031, 'n_tokens_neox': 1002, 'n_words': 247}