Skip to content

πŸ› Crash when using NavigationView with an unsupported localeΒ #371

@xmine64

Description

@xmine64

Describe the bug
When you set locale to an unsupported language, NavigationView causes a crash.

EDIT: looks like it crashes with same error even when I use English locale.

To Reproduce

import 'package:fluent_ui/fluent_ui.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return const FluentApp(
      title: 'Fluent UI Test',
      supportedLocales: [
        Locale('fa'),
      ],
      locale: Locale('fa'),
      home: MyHomePage(title: 'Ψ΄Ω…Ψ§Ψ±Ω†Ψ―Ω‡'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({Key? key, required this.title}) : super(key: key);

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  int _counter = 0;

  void _incrementCounter() {
    setState(() {
      _counter++;
    });
  }

  @override
  Widget build(BuildContext context) {
    return NavigationView(
      appBar: const NavigationAppBar(
        title: Text('Ψ΄Ω…Ψ§Ψ±Ω†Ψ―Ω‡'),
      ),
      content: NavigationBody(
        index: 0,
        children: [
          ScaffoldPage(
            header: PageHeader(
              title: Text(widget.title),
              commandBar: CommandBar(
                primaryItems: [
                  CommandBarButton(
                    onPressed: () {
                      _incrementCounter();
                    },
                    icon: const Icon(FluentIcons.add),
                  ),
                ],
              ),
            ),
            content: Center(
              child: Column(
                mainAxisAlignment: MainAxisAlignment.center,
                children: <Widget>[
                  const Text(
                    'Ψ΄Ω…Ψ§ Ψ§ΫŒΩ† Ψ―Ϊ©Ω…Ω‡ Ψ±Ψ§ Ψ§ΫŒΩ† ΨͺΨΉΨ―Ψ§Ψ― دفعه فشار Ψ―Ψ§Ψ―Ω‡β€ŒΨ§ΫŒΨ―:',
                  ),
                  Text(
                    '$_counter',
                    style: FluentTheme.of(context).typography.bodyLarge,
                  ),
                ],
              ),
            ),
          ),
        ],
      ),
    );
  }
}

Screenshots
image

Additional context

════════ Exception caught by widgets ═══════════════════════════════════════════
The following message was thrown:
Warning: This application's locale, fa, is not supported by all of its localization delegates.

β€’ A FluentLocalizations delegate that supports the fa locale was not found.

The declared supported locales for this app are: fa

See https://flutter.dev/tutorials/internationalization/ for more information about configuring an app's locale, supportedLocales, and localizationsDelegates parameters.
════════════════════════════════════════════════════════════════════════════════

════════ Exception caught by widgets library ═══════════════════════════════════
No FluentLocalizations found.
The ancestors of this widget were
    MyHomePage
        dependencies: [_FluentTheme]
        state: _MyHomePageState#c21c1
    ScaleTransition
        animation: AnimationController#b5b2d(⏭ 1.000; paused; for FluentPageRoute<dynamic>)➩ProxyAnimation➩Cubic(0.42, 0.00, 0.58, 1.00)➩Tween<double>(0.88 β†’ 1.0)➩1.0
        state: _AnimatedState#1af73
    FadeTransition
        opacity: AnimationController#b5b2d(⏭ 1.000; paused; for FluentPageRoute<dynamic>)➩ProxyAnimation➩Cubic(0.42, 0.00, 0.58, 1.00)
        renderObject: RenderAnimatedOpacity#f4f2c NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
    DrillInPageTransition
        animationValue: 100.0%
    Semantics
        container: false
        properties: SemanticsProperties
        renderObject: RenderSemanticsAnnotations#e5e80 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
    AnimatedDefaultTextStyle
        duration: 200ms
        inherit: true
        color: Color(0xe4000000)
        size: 14.0
        weight: 400
        softWrap: wrapping at box width
        overflow: clip
        state: _AnimatedDefaultTextStyleState#bd2cd(ticker inactive)
    IconTheme
        color: Color(0xff000000)
        size: 18.0
    _FluentTheme
    FluentTheme
    AnimatedFluentTheme
        duration: 200ms
        state: _AnimatedFluentThemeState#01a2a(ticker inactive, ThemeDataTween(ThemeData#f3cdd(accentColor: AccentColor(primary value: Color(0xff0078d4)), activeColor: Color(0xffffffff), inactiveColor: Color(0xff000000), inactiveBackgroundColor: Color(0xffd6d6d6), disabledColor: Color(0xff838383), shadowColor: Color(0xff000000), scaffoldBackgroundColor: Color(0xffffffff), acrylicBackgroundColor: Color(0xccffffff), micaBackgroundColor: Color(0xfff3f3f3), menuColor: Color(0xfff9f9f9), cardColor: Color(0xfff3f3f3), brightness: light, slowAnimationDuration: 0:00:00.358000, mediumAnimationDuration: 0:00:00.250000, fastAnimationDuration: 0:00:00.167000, fasterAnimationDuration: 0:00:00.083000, animationCurve: Cubic(0.42, 0.00, 0.58, 1.00)) β†’ null))
    AnimatedTheme
        duration: 200ms
        state: _AnimatedThemeState#43a93(ticker inactive, ThemeDataTween(ThemeData#52c40 β†’ null))
    WidgetsApp-[GlobalObjectKey _FluentAppState#3e953]
        state: _WidgetsAppState#06c46
    HeroControllerScope
    ScrollConfiguration
        behavior: FluentScrollBehavior
    FluentApp
        state: _FluentAppState#3e953
    MyApp
    ...
The relevant error-causing widget was
NavigationView
════════════════════════════════════════════════════════════════════════════════

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentation

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions