feedback icon indicating copy to clipboard operation
feedback copied to clipboard

type 'Null' is not a subtype of type 'WidgetsLocalizations' in type cast for Arabic, Najdi

Open Kal-Elx opened this issue 8 months ago • 3 comments

Version

3.1.0

Library

feedback

Flutter channel

stable

Flutter version

3.29.3

Platform

iOS

Details

We noticed the following issue surfacing in Crashlytics where some users were unable to open the app.

_LocalizationsState._textDirection
FlutterError - type 'Null' is not a subtype of type 'WidgetsLocalizations' in type cast. Error thrown .

Thanks to this comment we narrowed down the issue to this package and specifically to devices with the language Arabic, Najdi. Other Right-to-left languages I've tested works as expected.

Steps to reproduce

  • Change your device language to Arabic, Najdi
  • Run the example project
import 'package:feedback/feedback.dart';
import 'package:flutter/material.dart';

void main() {
  runApp(BetterFeedback(child: const MyApp()));
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(body: Center(child: Text('Hello, World!'))),
    );
  }
}

  • You will see the following error Image

Output of flutter doctor -v

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.29.3, on macOS 15.4.1 24E263 darwin-arm64, locale en-US)
[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 16.3)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2024.3)
[✓] VS Code (version 1.99.3)
[✓] Connected device (5 available)
[✓] Network resources

• No issues found!

Kal-Elx avatar Apr 29 '25 09:04 Kal-Elx

The issue also occurs for Neapolitan (nap_IT).

Kal-Elx avatar Apr 29 '25 12:04 Kal-Elx

Haitian Creole (ht) as well

empathictech avatar May 11 '25 05:05 empathictech

Was able to resolve it for Haitian Creole. Turns out this is a core Flutter issue, not a Feedback issue.

Flutter has built in semantics for a handful of languages, but not all. For the more niche languages, we need to override the base Material, Cupertino, and Widgets Localizations...

https://api.flutter.dev/flutter/material/DefaultMaterialLocalizations-class.html https://api.flutter.dev/flutter/cupertino/DefaultCupertinoLocalizations-class.html https://api.flutter.dev/flutter/widgets/DefaultWidgetsLocalizations-class.html

Then include them in main...

-- Sample BetterFeedback entry --

localizationsDelegates: <LocalizationsDelegate>[ EzFeedbackLD(), CreoleMaterialLocalizations.delegate, CreoleCupertinoLocalizations.delegate, const CreoleWidgetsLocalizationsDelegate(), ],

-- Sample PlatformApp entry --

localizationsDelegates: <LocalizationsDelegate>{ const LocaleNamesLocalizationsDelegate(), ...EFUILang.localizationsDelegates, ...Lang.localizationsDelegates, CreoleMaterialLocalizations.delegate, CreoleCupertinoLocalizations.delegate, const CreoleWidgetsLocalizationsDelegate(), },

Here's my implementation for Creole. Pasting a dev link for now, just switch to main if/when the link dies: https://github.com/Empathetech-LLC/empathetech_flutter_ui/blob/dev/lib/src/consts/custom_delegates/creole.dart

empathictech avatar May 12 '25 14:05 empathictech