<commit_before>import 'dart:ui';

import 'package:flutter/material.dart';
import 'package:dynamic_color_tools/dynamic_color_tools.dart';

/// Shifts color [from] towards color [to].
Color _harmonizeColor(Color from, Color to) {
  if (from == to) return from;
  return Color(Blend.harmonize(from.value, to.value));
}

extension ColorHarmonization on Color {
  /// Harmonizes this color with [color].
  ///
  /// [color] will typically be a dynamic [ColorScheme.primary] color.
  Color harmonizeWith(Color color) => _harmonizeColor(this, color);
}

extension ColorSchemeHarmonization on ColorScheme {
  /// Harmonizes [color] with this [ColorScheme]'s [primary].
  Color _harmonizeWithPrimary(Color color) => _harmonizeColor(color, primary);

  /// Harmonizes semantic [ColorScheme] colors with its [primary] color.
  ///
  /// TODO(guidezpl): link to spec
  ///
  /// Semantic colors (i.e. colors with meaning) are [error] and [onError]. Not
  /// harmonizing them would cause semantic colors to look out of place next to
  /// dynamic colors.
  ///
  /// Subclasses of [ColorScheme] with additional semantic colors should
  /// re-implement [harmonized]. For example:
  /// import 'package:dynamic_color/harmonization.dart';
  ///
  /// class CustomColorScheme extends ColorScheme {<commit_msg>Fix dartdoc import<commit_after>import 'dart:ui';

import 'package:flutter/material.dart';
import 'package:dynamic_color_tools/dynamic_color_tools.dart';

/// Shifts color [from] towards color [to].
Color _harmonizeColor(Color from, Color to) {
  if (from == to) return from;
  return Color(Blend.harmonize(from.value, to.value));
}

extension ColorHarmonization on Color {
  /// Harmonizes this color with [color].
  ///
  /// [color] will typically be a dynamic [ColorScheme.primary] color.
  Color harmonizeWith(Color color) => _harmonizeColor(this, color);
}

extension ColorSchemeHarmonization on ColorScheme {
  /// Harmonizes [color] with this [ColorScheme]'s [primary].
  Color _harmonizeWithPrimary(Color color) => _harmonizeColor(color, primary);

  /// Harmonizes semantic [ColorScheme] colors with its [primary] color.
  ///
  /// TODO(guidezpl): link to spec
  ///
  /// Semantic colors (i.e. colors with meaning) are [error] and [onError]. Not
  /// harmonizing them would cause semantic colors to look out of place next to
  /// dynamic colors.
  ///
  /// Subclasses of [ColorScheme] with additional semantic colors should
  /// re-implement [harmonized]. For example:
  /// import 'package:dynamic_color/dynamic_color.dart';
  ///
  /// class CustomColorScheme extends ColorScheme {
{'fraction_non_alphanumeric': 0.12726571538758194, 'fraction_numerical': 0.0, 'mean_word_length': 3.8485981308411215, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, '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': '1176355', 'n_tokens_mistral': 785, 'n_tokens_neox': 773, 'n_words': 238}