rydmike / flex_color_scheme

A Flutter package to make and use beautiful color scheme based themes.
Other
948 stars 106 forks source link

Colored text does not work in flutter 3.7 #112

Closed bksubhuti closed 1 year ago

bksubhuti commented 1 year ago

I get this error on startup Exception has occurred. FlutterError (DefaultTextHeightBehavior.of() was called with a context that does not contain a DefaultTextHeightBehavior widget. No DefaultTextHeightBehavior widget ancestor could be found starting from the context that was passed to DefaultTextHeightBehavior.of(). This can happen because you are using a widget that looks for a DefaultTextHeightBehavior ancestor, but no such ancestor exists. The context used was: ColoredText("English", color: Color(0xff4e0029), inherit: true, size: 14.0, weight: 700, dirty, dependencies: [DefaultTextStyle, MediaQuery]))

rydmike commented 1 year ago

Hi @bksubhuti thanks for the report.

Could you provide a code sample that can be used to reproduce the error so I can investigate further?

I'm still at Flutter Forward event, will be all week, but will look into asap when I get back to the office on Monday.

Meanwhile if you can get me reproduction sample that would help.

rydmike commented 1 year ago

I think I recall a bit now, this ColoredText was the example widget I used as in another discussion with you? I might have a repo with it around somewhere. Need to check.

bksubhuti commented 1 year ago

yes.. good memory.. i guess it is not your framework.. but from your sample.

Widget result = RichText( textAlign: textAlign ?? defaultTextStyle.textAlign ?? TextAlign.start, textDirection: textDirection, // RichText uses Directionality.of to obtain a default if this is null. locale: locale, // RichText uses Localizations.localeOf to obtain a default if this is null softWrap: softWrap ?? defaultTextStyle.softWrap, overflow: overflow ?? defaultTextStyle.overflow, textScaleFactor: textScaleFactor ?? MediaQuery.textScaleFactorOf(context), maxLines: maxLines ?? defaultTextStyle.maxLines, strutStyle: strutStyle, textWidthBasis: textWidthBasis ?? defaultTextStyle.textWidthBasis, textHeightBehavior: textHeightBehavior ?? defaultTextStyle.textHeightBehavior ?? DefaultTextHeightBehavior.of(context), text: TextSpan( style: effectiveTextStyle, text: data, children: textSpan != null ? [textSpan!] : null, ), ); if (semanticsLabel != null) { result = Semantics( textDirection: textDirection, label: semanticsLabel, child: ExcludeSemantics( child: result, ), ); } return result; } colored_text.zip

bksubhuti commented 1 year ago

i had to zip the dart file.. ironically attachments of dart are not allowed in github.

bksubhuti commented 1 year ago

It is a beast.. but if you download the db (located on the on readme page) and run the split command in the assets/database/, it should be buildable.. https://github.com/bksubhuti/tipitaka-pali-reader

While running in debug mode, you can click on settings and the assertion will arise.

rydmike commented 1 year ago

Hi @bksubhuti, You are right that this issue has nothing to do with FlexColorScheme.

Regardless of that I think I can fix it for you šŸ˜„

The example I made as demo of way to create a re-implementation of Text with some added convenience properties for colors and a a few other properties, called ColoredText no longer work in Flutter 3.7.

The internals of the Text widget have changed in Flutter 3.7 in a way that make this older example no longer viable. The fix is easy though, we just need to copy the latest Text code from Flutter 3.7 Text to ColoredText, keeping our mods intact.

I did so in this Pull Request: https://github.com/bksubhuti/tipitaka-pali-reader/pull/139 after it your app builds again:

Check it out, hope it helps, since I don't fully know your app it was a bit hard for me to be 100% sure, but without the fix you app did indeed not build, with it, it builds again and seemed to work.

Kind regards, Mike

bksubhuti commented 1 year ago

Your enthusiasm for helping is so wonderful and appreciated. Because it will break my build as you say, I will try to upgrade (again) to 3.7 and manually build locally. I'll try to get on it later today. I appreciate your promptness. I'm slowly testing the 3.7 and if there are no further problems, I accept the pr. You may have built when I forgot to add one file to git, but it should be there now. I'm an old school baby and write directly to git.
I'll keep you posted and close the issue after the pr acceptance.

rydmike commented 1 year ago

I hope it helps, and I am curious to hear if it works, let me know when you have tested it šŸ™šŸ’™

bksubhuti commented 1 year ago

I'm not so git fluent.. but what I did was upgrade.. but what I did was copy the text from the link below into my colored text https://github.com/bksubhuti/tipitaka-pali-reader/blob/e952869cba11bed41d40f2e1113e60301032b3c8/lib/ui/widgets/colored_text.dart I'm getting many build errors... the image below shows most of them.

image

bksubhuti commented 1 year ago

sorry for the delay to upgrade, I only have one machine and needed to release 3 platforms today before upgrading and testing 3.7 again.

bksubhuti commented 1 year ago

hopefully i copied the text correctly. I only changed.. colored text file. Here it is renamed as dart.txt to avoid upload checks on github. colored_text.dart.txt

bksubhuti commented 1 year ago

the error of dot-.build seems strange.. do i need to update the flexcolor or perhaps, I need to do a clean and pub get. I'll try again later..

rydmike commented 1 year ago

After fixing the ColoredText error when using Flutter 3.7, I did do:

To ensure all dependencies are as up to date as your current constraints can take them. The upgrade updates your packages to newer versions as far as their shared contsraints enables it, without actually changing your pubspec.yaml file to them. This is what it resolved to, for all direct and transitive dependencies:

  _fe_analyzer_shared 52.0.0
  analyzer 5.4.0
  archive 3.3.6
  args 2.3.2
  async 2.10.0
  beautiful_soup_dart 0.3.0
  boolean_selector 2.1.1
  build 2.3.1
  build_config 1.1.1
  build_daemon 3.1.0
  build_resolvers 2.1.0
  build_runner 2.3.3 (2.4.0 available)
  build_runner_core 7.2.7
  built_collection 5.1.1
  built_value 8.4.3
  characters 1.2.1
  checked_yaml 2.0.2
  cli_util 0.3.5
  clock 1.1.1
  code_builder 4.4.0
  collection 1.17.0 (1.17.1 available)
  console 4.1.0
  convert 3.1.1
  cross_file 0.3.3+2
  crypto 3.0.2
  csslib 0.17.2
  cupertino_icons 1.0.5
  dart_style 2.2.4
  devicelocale 0.5.5
  dio 4.0.6
  fake_async 1.3.1
  ffi 2.0.1
  file 6.1.4
  fixnum 1.0.1
  flex_color_scheme 6.1.2
  flex_seed_scheme 1.2.1
  flutter 0.0.0 from sdk flutter
  flutter_keyboard_visibility 5.4.0
  flutter_keyboard_visibility_linux 1.0.0
  flutter_keyboard_visibility_macos 1.0.0
  flutter_keyboard_visibility_platform_interface 2.0.0
  flutter_keyboard_visibility_web 2.0.0
  flutter_keyboard_visibility_windows 1.0.0
  flutter_lints 2.0.1
  flutter_localizations 0.0.0 from sdk flutter
  flutter_slidable 2.0.0
  flutter_test 0.0.0 from sdk flutter
  flutter_typeahead 3.3.0 from git https://github.com/pndaza/flutter_typeahead.git at 1511c9
  flutter_web_plugins 0.0.0 from sdk flutter
  flutter_widget_from_html_core 0.9.1
  freezed 2.3.2
  freezed_annotation 2.2.0
  from_css_color 2.0.0
  frontend_server_client 3.2.0
  fwfh_text_style 2.22.08+1
  get_it 7.2.0
  glob 2.1.1
  graphs 2.2.0
  html 0.15.1
  http 0.13.5
  http_multi_server 3.2.1
  http_parser 4.0.2
  huge_listview 2.0.4
  image 3.3.0 (4.0.12 available)
  internet_connection_checker 1.0.0+1
  intl 0.17.0 (0.18.0 available)
  io 1.0.4
  js 0.6.5 (0.6.7 available)
  json_annotation 4.8.0
  lints 2.0.1
  logger 1.1.0
  logging 1.1.1
  matcher 0.12.13 (0.12.14 available)
  material_color_utilities 0.2.0
  meta 1.8.0
  mime 1.0.4
  ms_material_color 1.0.0
  msix 3.7.0
  multi_split_view 2.2.0
  nested 1.0.0
  package_config 2.1.0
  path 1.8.2 (1.8.3 available)
  path_provider 2.0.12
  path_provider_android 2.0.22
  path_provider_foundation 2.1.1
  path_provider_linux 2.1.7
  path_provider_platform_interface 2.0.5
  path_provider_windows 2.1.3
  petitparser 5.1.0
  platform 3.1.0
  plugin_platform_interface 2.1.3
  pointycastle 3.6.2
  pool 1.5.1
  process 4.2.4
  provider 6.0.5
  pub_semver 2.1.3
  pubspec_parse 1.2.1
  quiver 3.2.1
  scrollable_positioned_list 0.3.5
  share_plus 6.3.0
  share_plus_platform_interface 3.2.0
  shared_preferences 2.0.17
  shared_preferences_android 2.0.15
  shared_preferences_foundation 2.1.2
  shared_preferences_linux 2.1.3
  shared_preferences_platform_interface 2.1.0
  shared_preferences_web 2.0.4
  shared_preferences_windows 2.1.3
  shelf 1.4.0
  shelf_web_socket 1.0.3
  sky_engine 0.0.99 from sdk flutter
  slidable_bar 1.1.1 from path packages/slidable_bar
  sliding_sheet 0.5.4 from git https://github.com/pndaza/sliding_sheet_bxqm.git at 76c28c
  source_gen 1.2.6
  source_span 1.9.1
  sqflite 2.2.4+1
  sqflite_common 2.4.2+2
  sqflite_common_ffi 2.2.1+1
  sqlite3 1.9.1
  stack_trace 1.11.0
  stream_channel 2.1.1
  stream_transform 2.1.0
  streaming_shared_preferences 2.0.0
  string_scanner 1.2.0
  styled_text 6.0.0 (7.0.0 available)
  substring_highlight 1.0.33
  synchronized 3.0.1
  tabbed_view 1.16.0
  term_glyph 1.2.1
  test_api 0.4.16 (0.4.18 available)
  timing 1.0.1
  toggle_switch 2.0.1
  typed_data 1.3.1
  url_launcher 6.1.8
  url_launcher_android 6.0.23
  url_launcher_ios 6.0.18
  url_launcher_linux 3.0.2
  url_launcher_macos 3.0.2
  url_launcher_platform_interface 2.1.1
  url_launcher_web 2.0.14
  url_launcher_windows 3.0.3
  uuid 3.0.7
  vector_math 2.1.4
  watcher 1.0.2
  web_socket_channel 2.3.0
  win32 3.1.3 (4.1.0 available)
  word_selectable_text 0.2.0
  xdg_directories 0.2.0+3
  xml 6.2.2
  xmlstream 1.0.0
  yaml 3.1.1

After that I did a test build on Android 13 emulator (Pixel6 Pro) and iOS simulator (iPhone 14 Pro Max), shown below:

Screenshot 2023-01-29 at 6 18 18

Since the above dependencies work for the build with Flutter 3.7 you could also update your direct ones to matching ones.

Merging the PR in GitHub would perhaps have been easier, then you could have gotten the same updateD pubspec.lock file too, but running above commands after merging or copying only the complete colored_text.dart should fix that too.

As you can see in the PR, the only code chaNges I did are internal to the colored_text.dart.

You can certainly make a simpler version of it too, or just use standard Text in your app and apply it any needed color in its style instead the standard way.

Yes sure, you can update to latest FlexColorScheme stable 6.1.2, without issues too, since you are on 6.0.0, in fact the pub upgrade I run, did that for the builds I tried, but for your app it should not matter.

On Flutter 3.7 you can also update to FlexColorScheme 7.0.0-dev.2 release if you feel experimental. It is a beta for Flutter 3.7. Despite major version it does not have any breaking APIs, only some minor subtle style changes. What it adds is better and more support for all the new Material 3 features in Flutter 3.7 and some new themes as well.

However, since it is still in beta, and your app is not using Material 3, there is no real reason for you to upgrade at this stage. You can jump to FlexColorScheme 7 later when its stable release is out if you want. If you plan to use Material 3 later, you should.

I'm going to close this issue, since it is not related to FlexColorScheme at all. We can still continue communicating on this issue here, even after this issue is closed, if you like.

rydmike commented 1 year ago

A tip, you can post Dart code snippets in GitHub comments too.

You just start with ```dart on one line, and end it with there 3 back ticks without dart, after last line of code.

Here is an example of the entire colored_text.dart file. Github then also adds a handy copy code button to the code snippet, that is shown in upper right cornet when you hover the block with your mouse.

import 'dart:ui' as ui show TextHeightBehavior;

import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:tipitaka_pali/services/prefs.dart';

// ignore_for_file: comment_references

/// A run of colored text with a single style.
///
/// The [ColoredText] widget displays a string of text with single style. The string
/// might break across multiple lines or might all be displayed on the same line
/// depending on the layout constraints.
///
/// The [ColoredText] defaults to using Theme.of(context).colorScheme.primary
/// as its text color. It also exposes the [color], [fontWeight] and [fontSize]
/// as direct properties in the widget, without need to provide them via
/// a [TextStyle] in [style]. A [style] may also be provided, if given then
/// the [color], [fontWeight] and [fontSize] given via direct properties
/// override the same properties in the [style].
///
/// The [color] property gets a default of [primary] if null before merging
/// with [style], so if [color] is null, but a [style] is given, with or
/// without [color] set in it, it will always be [primary] colored anyway, this
/// is an always colored text widget after all and one design goal was for it
/// to always default to primary color.
///
/// The [ColoredText] is a simple modified version of Flutter SDK [Text]. The
/// rest of the comments are straight copies from the SDK.
///
/// The [style] argument is optional. When omitted, the text will use the style
/// from the closest enclosing [DefaultTextStyle]. If the given style's
/// [TextStyle.inherit] property is true (the default), the given style will
/// be merged with the closest enclosing [DefaultTextStyle]. This merging
/// behavior is useful, for example, to make the text bold while using the
/// default font family and size.
///
/// {@tool snippet}
///
/// This example shows how to display text using the [ColoredText] widget with the
/// [overflow] set to [TextOverflow.ellipsis].
///
/// ![If the text is shorter than the available space, it is displayed in full without an ellipsis.](https://flutter.github.io/assets-for-api-docs/assets/widgets/text.png)
///
/// ![If the text overflows, the Text widget displays an ellipsis to trim the overflowing text](https://flutter.github.io/assets-for-api-docs/assets/widgets/text_ellipsis.png)
///
/// ```dart
/// Text(
///   'Hello, $_name! How are you?',
///   textAlign: TextAlign.center,
///   overflow: TextOverflow.ellipsis,
///   style: const TextStyle(fontWeight: FontWeight.bold),
/// )
/// ```
/// {@end-tool}
///
/// Using the [Text.rich] constructor, the [ColoredText] widget can
/// display a paragraph with differently styled [TextSpan]s. The sample
/// that follows displays "Hello beautiful world" with different styles
/// for each word.
///
/// {@tool snippet}
///
/// ![The word "Hello" is shown with the default text styles. The word "beautiful" is italicized. The word "world" is bold.](https://flutter.github.io/assets-for-api-docs/assets/widgets/text_rich.png)
///
/// ```dart
/// const Text.rich(
///   TextSpan(
///     text: 'Hello', // default text style
///     children: <TextSpan>[
///       TextSpan(text: ' beautiful ', style: TextStyle(fontStyle: FontStyle.italic)),
///       TextSpan(text: 'world', style: TextStyle(fontWeight: FontWeight.bold)),
///     ],
///   ),
/// )
/// ```
/// {@end-tool}
///
/// ## Interactivity
///
/// To make [ColoredText] react to touch events, wrap it in a [GestureDetector] widget
/// with a [GestureDetector.onTap] handler.
///
/// In a material design application, consider using a [TextButton] instead, or
/// if that isn't appropriate, at least using an [InkWell] instead of
/// [GestureDetector].
///
/// To make sections of the text interactive, use [RichText] and specify a
/// [TapGestureRecognizer] as the [TextSpan.recognizer] of the relevant part of
/// the text.
///
/// See also:
///
///  * [RichText], which gives you more control over the text styles.
///  * [DefaultTextStyle], which sets default styles for [ColoredText] widgets.
class ColoredText extends StatelessWidget {
  /// Creates a colored text widget.
  ///
  /// The [ColoredText] defaults to using Theme.of(context).colorScheme.primary
  /// as its text color. It also exposes the [color], [fontWeight] and [fontSize]
  /// as direct properties in the widget, without need to provide them via
  /// a [TextStyle] in [style]. A [style] may also be provided, if given then
  /// the [color], [fontWeight] and [fontSize] given via direct properties
  /// override the same properties in the [style].
  ///
  /// The [color] property gets a default of [primary] if null before merging
  /// with [style], so if [color] is null, but a [style] is given, with or
  /// without [color] set in it, it will always be [primary] colored anyway, this
  /// is an always colored text widget after all and one design goal was for it
  /// to always default to primary color.
  ///
  /// If the [style] argument is null, the text will use the style from the
  /// closest enclosing [DefaultTextStyle].
  ///
  /// The [data] parameter must not be null.
  ///
  /// The [overflow] property's behavior is affected by the [softWrap] argument.
  /// If the [softWrap] is true or null, the glyph causing overflow, and those that follow,
  /// will not be rendered. Otherwise, it will be shown with the given overflow option.
  const ColoredText(
    String this.data, {
    Key? key,
    this.color,
    this.fontSize,
    this.fontWeight,
    this.style,
    this.strutStyle,
    this.textAlign,
    this.textDirection,
    this.locale,
    this.softWrap,
    this.overflow,
    this.textScaleFactor,
    this.maxLines,
    this.semanticsLabel,
    this.textWidthBasis,
    this.textHeightBehavior,
    this.selectionColor,
  })  : textSpan = null,
        super(key: key);

  /// Creates a colored text widget with a [InlineSpan].
  ///
  /// The following subclasses of [InlineSpan] may be used to build rich text:
  ///
  /// * [TextSpan]s define text and children [InlineSpan]s.
  /// * [WidgetSpan]s define embedded inline widgets.
  ///
  /// The [textSpan] parameter must not be null.
  ///
  /// See [RichText] which provides a lower-level way to draw text.
  const ColoredText.rich(
    InlineSpan this.textSpan, {
    super.key,
    this.color,
    this.fontSize,
    this.fontWeight,
    this.style,
    this.strutStyle,
    this.textAlign,
    this.textDirection,
    this.locale,
    this.softWrap,
    this.overflow,
    this.textScaleFactor,
    this.maxLines,
    this.semanticsLabel,
    this.textWidthBasis,
    this.textHeightBehavior,
    this.selectionColor,
  }) : data = null;

  /// The text to display.
  ///
  /// This will be null if a [textSpan] is provided instead.
  final String? data;

  /// The text to display as a [InlineSpan].
  ///
  /// This will be null if [data] is provided instead.
  final InlineSpan? textSpan;

  /// The color to use when painting the text.
  ///
  /// The [color] property gets a default of [primary] color if it is null,
  /// before merging with [style], so if [color] is null, but a [style] is
  /// given, with or without [color] set in it, it will always be [primary]
  /// colored anyway. This is an always colored text widget after all and
  /// one design goal was for it to always default to primary color if not
  /// specified in the direct [color] property to use some other color.
  ///
  /// Since this property will always resolve to a none null color value, it
  /// does mean that this widget cannot specify the [foreground] color in
  /// [style] property, doing so will result in an assert informing you of
  /// the conflict.
  ///
  /// In [merge], [apply], and [lerp], conflicts between [color] and [foreground]
  /// specification are resolved in [foreground]'s favor - i.e. if [foreground] is
  /// specified in one place, it will dominate [color] in another.
  final Color? color;

  /// The size of glyphs (in logical pixels) to use when painting the text.
  ///
  /// During painting, the [fontSize] is multiplied by the current
  /// `textScaleFactor` to let users make it easier to read text by increasing
  /// its size.
  ///
  /// [getParagraphStyle] will default to 14 logical pixels if the font size
  /// isn't specified here.
  final double? fontSize;

  /// The typeface thickness to use when painting the text (e.g., bold).
  final FontWeight? fontWeight;

  /// If non-null, the style to use for this text.
  ///
  /// If the style's "inherit" property is true, the style will be merged with
  /// the closest enclosing [DefaultTextStyle]. Otherwise, the style will
  /// replace the closest enclosing [DefaultTextStyle].
  final TextStyle? style;

  /// {@macro flutter.painting.textPainter.strutStyle}
  final StrutStyle? strutStyle;

  /// How the text should be aligned horizontally.
  final TextAlign? textAlign;

  /// The directionality of the text.
  ///
  /// This decides how [textAlign] values like [TextAlign.start] and
  /// [TextAlign.end] are interpreted.
  ///
  /// This is also used to disambiguate how to render bidirectional text. For
  /// example, if the [data] is an English phrase followed by a Hebrew phrase,
  /// in a [TextDirection.ltr] context the English phrase will be on the left
  /// and the Hebrew phrase to its right, while in a [TextDirection.rtl]
  /// context, the English phrase will be on the right and the Hebrew phrase on
  /// its left.
  ///
  /// Defaults to the ambient [Directionality], if any.
  final TextDirection? textDirection;

  /// Used to select a font when the same Unicode character can
  /// be rendered differently, depending on the locale.
  ///
  /// It's rarely necessary to set this property. By default its value
  /// is inherited from the enclosing app with `Localizations.localeOf(context)`.
  ///
  /// See [RenderParagraph.locale] for more information.
  final Locale? locale;

  /// Whether the text should break at soft line breaks.
  ///
  /// If false, the glyphs in the text will be positioned as if there was unlimited horizontal space.
  final bool? softWrap;

  /// How visual overflow should be handled.
  ///
  /// Defaults to retrieving the value from the nearest [DefaultTextStyle] ancestor.
  final TextOverflow? overflow;

  /// The number of font pixels for each logical pixel.
  ///
  /// For example, if the text scale factor is 1.5, text will be 50% larger than
  /// the specified font size.
  ///
  /// The value given to the constructor as textScaleFactor. If null, will
  /// use the [MediaQueryData.textScaleFactor] obtained from the ambient
  /// [MediaQuery], or 1.0 if there is no [MediaQuery] in scope.
  final double? textScaleFactor;

  /// An optional maximum number of lines for the text to span, wrapping if necessary.
  /// If the text exceeds the given number of lines, it will be truncated according
  /// to [overflow].
  ///
  /// If this is 1, text will not wrap. Otherwise, text will be wrapped at the
  /// edge of the box.
  ///
  /// If this is null, but there is an ambient [DefaultTextStyle] that specifies
  /// an explicit number for its [DefaultTextStyle.maxLines], then the
  /// [DefaultTextStyle] value will take precedence. You can use a [RichText]
  /// widget directly to entirely override the [DefaultTextStyle].
  final int? maxLines;

  /// An alternative semantics label for this text.
  ///
  /// If present, the semantics of this widget will contain this value instead
  /// of the actual text. This will overwrite any of the semantics labels applied
  /// directly to the [TextSpan]s.
  ///
  /// This is useful for replacing abbreviations or shorthands with the full
  /// text value:
  ///
  /// ```dart
  /// Text(r'$$', semanticsLabel: 'Double dollars')
  /// ```
  final String? semanticsLabel;

  /// {@macro flutter.painting.textPainter.textWidthBasis}
  final TextWidthBasis? textWidthBasis;

  /// {@macro flutter.dart:ui.textHeightBehavior}
  final ui.TextHeightBehavior? textHeightBehavior;

  /// The color to use when painting the selection.
  ///
  /// This is ignored if [SelectionContainer.maybeOf] returns null
  /// in the [BuildContext] of the [Text] widget.
  ///
  /// If null, the ambient [DefaultSelectionStyle] is used (if any); failing
  /// that, the selection color defaults to [DefaultSelectionStyle.defaultColor]
  /// (semi-transparent grey).
  final Color? selectionColor;

  @override
  Widget build(BuildContext context) {
    final DefaultTextStyle defaultTextStyle = DefaultTextStyle.of(context);
    TextStyle? effectiveTextStyle = style;
    if (style == null || style!.inherit) {
      effectiveTextStyle = defaultTextStyle.style.merge(style);
    }
    effectiveTextStyle = effectiveTextStyle!.merge(
      TextStyle(
        fontWeight: fontWeight,
        fontSize: fontSize,
        color: color ??
            ((!Prefs.darkThemeOn) ? Theme.of(context).primaryColor : null),
      ),
    );
    if (MediaQuery.boldTextOverride(context)) {
      effectiveTextStyle = effectiveTextStyle!
          .merge(const TextStyle(fontWeight: FontWeight.bold));
    }
    final SelectionRegistrar? registrar = SelectionContainer.maybeOf(context);

    Widget result = RichText(
      textAlign: textAlign ?? defaultTextStyle.textAlign ?? TextAlign.start,
      textDirection:
          textDirection, // RichText uses Directionality.of to obtain a default if this is null.
      locale:
          locale, // RichText uses Localizations.localeOf to obtain a default if this is null
      softWrap: softWrap ?? defaultTextStyle.softWrap,
      overflow:
          overflow ?? effectiveTextStyle?.overflow ?? defaultTextStyle.overflow,
      textScaleFactor: textScaleFactor ?? MediaQuery.textScaleFactorOf(context),
      maxLines: maxLines ?? defaultTextStyle.maxLines,
      strutStyle: strutStyle,
      textWidthBasis: textWidthBasis ?? defaultTextStyle.textWidthBasis,
      textHeightBehavior: textHeightBehavior ??
          defaultTextStyle.textHeightBehavior ??
          DefaultTextHeightBehavior.maybeOf(context),
      selectionRegistrar: registrar,
      selectionColor: selectionColor ??
          DefaultSelectionStyle.of(context).selectionColor ??
          DefaultSelectionStyle.defaultColor,
      text: TextSpan(
        style: effectiveTextStyle,
        text: data,
        children: textSpan != null ? <InlineSpan>[textSpan!] : null,
      ),
    );
    if (registrar != null) {
      result = MouseRegion(
        cursor: SystemMouseCursors.text,
        child: result,
      );
    }
    if (semanticsLabel != null) {
      result = Semantics(
        textDirection: textDirection,
        label: semanticsLabel,
        child: ExcludeSemantics(
          child: result,
        ),
      );
    }
    return result;
  }

  @override
  void debugFillProperties(DiagnosticPropertiesBuilder properties) {
    super.debugFillProperties(properties);
    properties.add(StringProperty('data', data, showName: false));
    if (textSpan != null) {
      properties.add(textSpan!.toDiagnosticsNode(
          name: 'textSpan', style: DiagnosticsTreeStyle.transition));
    }
    style?.debugFillProperties(properties);
    properties.add(
        EnumProperty<TextAlign>('textAlign', textAlign, defaultValue: null));
    properties.add(EnumProperty<TextDirection>('textDirection', textDirection,
        defaultValue: null));
    properties
        .add(DiagnosticsProperty<Locale>('locale', locale, defaultValue: null));
    properties.add(FlagProperty('softWrap',
        value: softWrap,
        ifTrue: 'wrapping at box width',
        ifFalse: 'no wrapping except at line break characters',
        showName: true));
    properties.add(
        EnumProperty<TextOverflow>('overflow', overflow, defaultValue: null));
    properties.add(
        DoubleProperty('textScaleFactor', textScaleFactor, defaultValue: null));
    properties.add(IntProperty('maxLines', maxLines, defaultValue: null));
    properties.add(EnumProperty<TextWidthBasis>(
        'textWidthBasis', textWidthBasis,
        defaultValue: null));
    properties.add(DiagnosticsProperty<ui.TextHeightBehavior>(
        'textHeightBehavior', textHeightBehavior,
        defaultValue: null));
    if (semanticsLabel != null) {
      properties.add(StringProperty('semanticsLabel', semanticsLabel));
    }
  }
}
bksubhuti commented 1 year ago

okay.. i'll try again.. so the issue is with a non updated flexcolor package That I need to update..and that is what gives me the compile errors?

I don't have in front of me, because a release failed and I needed to drop back to 3.3.4 .
think it was these that had errors. If we can make colored_text work, it would be good to keep. I also use in the Buddhist Sun app

    this.fontSize,
    this.fontWeight,
    this.style,
    this.strutStyle,
    this.textAlign,
    this.textDirection,
    this.locale,
    this.softWrap,
    this.overflow,
    this.textScaleFactor,
    this.maxLines,
    this.semantic
rydmike commented 1 year ago

The issue is as far as I can see only with the customized version of Text that is called ColoredText (and it is not a part of the FlexColorScheme package), and probably only the line where it gets the context based default that should be a maybeOf instead of is the issue:

DefaultTextHeightBehavior.of(context) -> DefaultTextHeightBehavior.maybeOf(context)

So actually it is the DefaultTextHeightBehavior that has changed in Flutter 3.7, where its of method is now none nullable and one has to use the maybeOf for a nullable version.

The newer Text in it does however also have a few more new features that I also included in the this version of ColoredText. I thought you should have feature parity between Text and ColoredText.

FlexColorScheme package you can run at version 6 or any later 6.x.x version as before. However, many of the package dependencies you have may need to be upgrade for your build to work on Flutter 3.7, thats is what the flutter pub upgrade part did, but only within the version constraints you had specified in your pubspec.yaml file, and those constraints still seemed to be good for a working build in Flutter 3.7. You do however after upgrading to Flutter 3.7 probably need to do a flutter pub upgrade for a successful build.

I did not try the lock file your repo came with, so I am not sure, probably there is an issue with some versions it was using and Flutter 3.7. I automatically just upgraded them to latest constraint after the Flutter 3.7 upgrade.

rydmike commented 1 year ago

I'm still of course curious to learn when and how you manage to solve this issue in your app with Flutter 3.7. So please let me know when you have, or if I can do anything else to assist.

BR Mike šŸ˜„ šŸ™šŸ»

bksubhuti commented 1 year ago

The main programmer monk seems to be able to make it work by sinply upgrading styled_text to 7.0 and changing only that.. no code changes. I will hopefully find time and finally install fvm later today and test. I have been upgrading and downgrading manually for testing hoping it would be the last time.which keeps failing and it is a big deal especially since the Ms windows upload failed and needed a resubmission.

On Sun, Jan 29, 2023, 23:10 Rydmike @.***> wrote:

I'm still of course curious to learn when and how you manage to solve this issue in your app with Flutter 3.7. So please let me know when you have, or if I can do anything else to assist.

BR Mike šŸ˜„ šŸ™šŸ»

ā€” Reply to this email directly, view it on GitHub https://github.com/rydmike/flex_color_scheme/issues/112#issuecomment-1407725552, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEKXQWAACUSAXMFI4EBJJV3WU2TR3ANCNFSM6AAAAAAUHGPP5M . You are receiving this because you were mentioned.Message ID: @.***>

bksubhuti commented 1 year ago

I installed fvm and I'm definitely using 3.7 but I think i still get both problems. problem 1 .. compile errors if I use your code. problem 2 .. failure as original reported here when I open up settings.

bksubhuti commented 1 year ago

My senior Programmer monk helped me.. seems that windows or github has a copy paste limit. I have never encountered this before in linux (but i had to switch to windows due to compatibility with my laptop and space issues). So I saved your code as raw file and that fixed the compile errors. Now I can open the settings without crashing using your code. Your help and timely fix was / is much appreciated.

bksubhuti commented 1 year ago

fyi.. the cut paste limit seems to be in edge and vivaldi (main driver) but not google chrome.

bksubhuti commented 1 year ago

Merged the pr. Because i'm not so good at git, and because you said it would break the Flutter 3.3.4 build I was cautious to do so, which made things worse., I tried manually copying the file to test before merging. Then there was a odd copy paste bug found in vivaldi and edge but not chrome. I thought the compile errors were caused by upgrades or packages. All is well now and the volunteers are on board to upgrade to flutter 3.7 which has some needed fixes for us since we selection_area and tweaked our context menus. The app is used by maybe 2-3000 now.
Best wishes on your flex color. I'm glad we can still use colored_text and you were so kind to write it. We are using FlexColor as well. I think some items on flex color are being used by us, but are phased out.. (I think I saw some strikethrough lines) so I will look into trying to do things right.

rydmike commented 1 year ago

Glad to hear you finally got it fixed. Never noticed any copy paste limits in browsers I use, but I rarely use Edge. I have not seen it in Brave or Chrome, but good to know.

These complications could have been avoided by just merging the PR with the fix in GitHub, but main thing is of course that you now got it working and you can build your application in Flutter 3.7.

Best wishes and good fortune with your app šŸ™

Br Mike

bksubhuti commented 1 year ago

Yes.. sorry about not merging. I was afraid because it would break the legacy flutter build. Then other problems arose. Yes, i never had this problem before. I use vivaldi (it is an amazing browser. I will report this to them. It must be part of the chromium browser and ironically google chrome does not have this limit. ). Everything is a learning experience. Will try differently next time. Roughtly 2000-3000 people use our app and it will grow to 10k in 3 years..

Bhante Subhuti

https://AmericanMonk.org https://withmetta.net

On Tue, 31 Jan 2023 at 07:27, Rydmike @.***> wrote:

Glad to hear you finally got it fixed. Never noticed any copy paste limits in browsers I use, but I rarely use Edge. I have not seen it in Brave or Chrome, but good to know.

These complications could have been avoided by just merging the PR with the fix in GitHub, but main thing is of course that you now got it working and you can build your application in Flutter 3.7.

Best wishes and good fortune with your app šŸ™

Br Mike

ā€” Reply to this email directly, view it on GitHub https://github.com/rydmike/flex_color_scheme/issues/112#issuecomment-1409628314, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEKXQWGHFTAS7G2FCVTBUKDWVBWO5ANCNFSM6AAAAAAUHGPP5M . You are receiving this because you were mentioned.Message ID: @.***>

rydmike commented 1 year ago

Wow that is quite a lot of users already and nice growth projection too. Impressive and congrats.

Where in the world are you located Bhante? I travel quite a bit, who knows, maybe some day we can meet and connect in the real world too šŸ™‚

Btw I think your apps, their story and use cases would be wonderful to share with the Flutter developers' community. I was just at the Flutter Forward event in Nairobi, where I met many talented developers from around the world and obviously from many African countries. It was heart warming to see the apps and better future they strive to create using Flutter.

bksubhuti commented 1 year ago

I'm am in Sri Lanka at a study monastery .Ā  (I was in myanmar) when we first spoke.I'm an american monk and my website is americanomnk.org and by gmail is the bk-sub-huti without the dashes .Ā  You are welcome to contact me by email for further personal contact.

You are welcome to stop by sri lanka and our monastery, it is not easy to get to where I am.Ā  I'm International Institute of Theravada IIT.

The official website is theravado.comĀ There is a fairly recent post about the place on my website.There is always floor space and food and you can stay a few days and learn and volunteer.. I'm sure someone like you has many friends++Ā  .Ā Correction on Totals is:Ā 199 Microsoft store,Ā 1.34K Android store (some use other distribution channels too)Apple is a mystery because they don't give total install analytics.Ā  It might be about 500 total.Ā  I was given some reports by the apple helper, but it is difficult to add up since they have 3 month only reports. I think we might be at 2000 on all OS's (msoft totals were less than I originally thought)The electron app we replaced (Tipitaka Pali Projector) has 1000+ installs on msoft alone.Currently the Linux appimage is broken and not tested.Ā  but we have 5 or 10 installs is my guess since our electron snap had 15 or so installs over 3 years.I think the original pure android java Myanmar language only App version has about 10,000 installs.

I contacted the dev ven pndazza who is also a monk.Ā  He rewrote his android java app in flutter app for iOS.Ā  He had flutter and SQLite already written as a base.Ā  Now that has been forked by me and we work together volunteers on TPR.Ā  He has health limitationsĀ  but has done most of the functional code..Ā  I do the PM stuff, small beginner UI stuff, themes, multi-lang, and some db stuff.

I have a free download book called "Going For Broke: Travelogs on BecomingĀ a buddhist monk" If you travel you might like it.Ā I have a youtube channel tool for the app and my own stuff.I'm not the best programmer.. but i'm making things work.Ā  When the app gets more stable in 6 to 9 months, it will support mm monks who number 300,000 in population.Ā  I'm sure we can get some of that 300k pool as a multilingual multi-scriptĀ program, especially with non commercial merit based philosophy. Ā  Apple Os's are a little behind on releases because I rely on another person.Ā  Msoft and android are fairly recent.Ā  Don't use the downloader on ios.Ā  It will not work and needs the most recent update.

I used to be a contract c++ programmer for pitney bowes, reader's digest, and bayer but only for 5 - 6 years until I left in 1999.Ā  I picked up programming again about 3 years ago due to my wish to make a better pali reading app.Ā  In the early 90's, you could memorize 2 MFC volumes and be a star.Ā  Things have changed and I'm older and things are not so easy to learn. Buddhist Sun App (the original app I contacted you on) has 448 on Android as of today (I checked just now and it grew from 200 last time I checked). and again not sure on the apple store.Ā  I wrote it for myself and a senior monk who is busy, so I gain an extra 446 points.Ā  It might be 750 total.Ā Ā I also wrote paauk tracker which isĀ on github but useless without data it fetches.Ā  It is an attendance sign-in program for meditation interviews at paauk. I also have a 200,000 entry dictionary translation project I manage which shouldĀ reach 100,000 human edited entries in 2 weeks.Ā  The rest was run through google cloud.Ā  It is called PEU on the TPR app.Ā  I would be happy to share the experience remotely by video stream if needed or write something up.Ā  We have a full streaming studio here at the monastery.Ā  Ā I'm sure the category of 5-OS build flutter apps out there with sqlfiteĀ is small considering Flutter-devs just recently put keyboard support in the desktop linux build (at my request).Ā 

gmail is the bk-sub-huti without the dashes

bksubhuti commented 1 year ago

fyi.. the issue of copy paste was a codespace beta issue. https://support.github.com/ticket/personal/0/1993244

If you have code space beta feature turned on and select and paste, you will be limited to 233 lines of colored_text

bksubhuti commented 1 year ago

We are using text themes now. I think you suggested this. It seems like the names of standard styles is changing daily! We also have a big problem with ios16 and our massive use of gesture detector making each word (for a whole book) clickable. A bug was filed for Flutter framwork. ios16 does not work. We will force our mobile phone view as a quick and dirty fix today. I hope you are well.

bksubhuti commented 1 year ago

We just hit 3000 active users today on android. MS win 557 and Appleiosmacos somewhere around 275 (I don't have direct access to know the answers, since I have another person make the Apple stuff for me since we use Path Nirvana account.). Sadhu for your help with ColoredText and the themes. My other app Buddhist Sun has over 500 active devices. I don't pay attention to "downloads".. that is much bigger. We have appimage and even flatpak but flatpack is an older build.

bksubhuti commented 1 year ago

I forgot to post the pic. It is a limited audience, and we have the best app (that was the goal, otherwise we would waste time). So the numbers are flattening out now. I still think we might hit 4500 at the close of 2023 Our app is free from charges or even donations pages. aka totally non-commercial. image