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

YaruTitleBar: null check operator used on a null value #518

Closed
jpnurmi opened this issue Jan 14, 2023 · 4 comments · Fixed by #535
Closed

YaruTitleBar: null check operator used on a null value #518

jpnurmi opened this issue Jan 14, 2023 · 4 comments · Fixed by #535

Comments

@jpnurmi
Copy link
Member

jpnurmi commented Jan 14, 2023

AppBarTheme.titleTextStyle is null by default (when not using the Yaru theme).

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

void main() {
  runApp(
    const MaterialApp(
      home: Scaffold(
        appBar: YaruWindowTitleBar(),
      ),
    ),
  );
}
Launching lib/main.dart on Linux in debug mode...
Connecting to VM Service at ws://127.0.0.1:44129/YaaNpS86WYE=/ws

════════ Exception caught by widgets library ═══════════════════════════════════
The following _CastError was thrown building YaruTitleBar(dirty, dependencies: [_InheritedTheme, _LocalizationsScope-[GlobalKey#eff3e]]):
Null check operator used on a null value

The relevant error-causing widget was
YaruTitleBar
When the exception was thrown, this was the stack
#0      YaruTitleBar.build
#1      StatelessElement.build
#2      ComponentElement.performRebuild
#3      Element.rebuild
#4      ComponentElement._firstBuild
#5      ComponentElement.mount
...     Normal element mounting (36 frames)
#41     Element.inflateWidget
#42     MultiChildRenderObjectElement.inflateWidget
#43     MultiChildRenderObjectElement.mount
...     Normal element mounting (379 frames)
#422    Element.inflateWidget
#423    MultiChildRenderObjectElement.inflateWidget
#424    MultiChildRenderObjectElement.mount
...     Normal element mounting (416 frames)
#840    Element.inflateWidget
#841    Element.updateChild
#842    RenderObjectToWidgetElement._rebuild
#843    RenderObjectToWidgetElement.mount
#844    RenderObjectToWidgetAdapter.attachToRenderTree.<anonymous closure>
#845    BuildOwner.buildScope
#846    RenderObjectToWidgetAdapter.attachToRenderTree
#847    WidgetsBinding.attachRootWidget
#848    WidgetsBinding.scheduleAttachRootWidget.<anonymous closure>
(elided 4 frames from class _RawReceivePortImpl, class _Timer, and dart:async-patch)
════════════════════════════════════════════════════════════════════════════════

════════ Exception caught by widgets library ═══════════════════════════════════
Null check operator used on a null value
The relevant error-causing widget was
YaruTitleBar
════════════════════════════════════════════════════════════════════════════════
@jpnurmi
Copy link
Member Author

jpnurmi commented Jan 14, 2023

What is a reasonable fallback text style? Every single property in TextTheme is nullable. 👀

@d-loose
Copy link
Member

d-loose commented Jan 16, 2023

Material's AppBar still uses TextTheme.headline6 as a fallback, which would be TextTheme.titleLarge in 2021 terms. The docstring sounds quite sensible too

  /// Used for the primary text in app bars and dialogs (e.g., [AppBar.title]
  /// and [AlertDialog.title]).
  TextStyle? get headline6 => titleLarge;

As far as I know TextTheme properties are always filled with non-null values in a MaterialApp.

@Feichtmeier
Copy link
Member

labelLarge should match

@jpnurmi
Copy link
Member Author

jpnurmi commented Jan 16, 2023

As far as I know TextTheme properties are always filled with non-null values in a MaterialApp.

Ah, that's good so we don't need more fallbacks after this fallback. :)

Feichtmeier pushed a commit that referenced this issue Jan 18, 2023
When AppBarTheme.titleTextStyle is null.

Close: #518
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants