Home > Blockchain >  Flutter CupertinoSliverNavigationBar with translated / non constant text?
Flutter CupertinoSliverNavigationBar with translated / non constant text?

Time:09-04

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

CodePudding user response:

Remove const from CupertinoSliverNavigationBar

CupertinoSliverNavigationBar(
  largeTitle: Text("captureSelectionView.viewTitle").tr(),
),
  • Related