type 'Null' is not a subtype of type 'WidgetsLocalizations' in type cast for Arabic, Najdi
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
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!
The issue also occurs for Neapolitan (nap_IT).
Haitian Creole (ht) as well
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
-- Sample PlatformApp entry --
localizationsDelegates: <LocalizationsDelegate
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