0

I am trying to create a view with a CupertinoSliverNavigationBar in Flutter.

child: CustomScrollView(
          slivers: [
            const CupertinoSliverNavigationBar(
              largeTitle: Text("captureSelectionView.viewTitle").tr(),
            ),
            SliverToBoxAdapter( ...

To display the UI in multiple languages, I am using the easy_localization package to translate text, which ususally works perfectly. However, the CupertinoSliverNavigationBar largeTitle seems to require a constant because the code above results in an error with VS Code telling me "Invalid constant value.". I can't find that it the docs, but the error is there ...

How can I get a dynamic string aka translated text in the largeTitle Text widget?

Thanks for your help! Best regards, Chris

Md. Yeasin Sheikh
  • 54,221
  • 7
  • 29
  • 56
Christian
  • 217
  • 3
  • 11

1 Answers1

2

Remove const from CupertinoSliverNavigationBar

CupertinoSliverNavigationBar(
  largeTitle: Text("captureSelectionView.viewTitle").tr(),
),
Md. Yeasin Sheikh
  • 54,221
  • 7
  • 29
  • 56