Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Execute DateFormat.format on compute throws LocaleDataException. #441

Open
keisuke-kiriyama opened this issue Nov 18, 2022 · 0 comments
Open
Labels
P3 A lower priority bug or feature request package:intl type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@keisuke-kiriyama
Copy link

Executing DateFormat.format on compute throws a LocaleDataException, is this expected behavior?

repro code
Future<void> main() async {
  await initializeDateFormatting('ja_JP');
  runApp(const MyApp());
}

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: const MyHomePage(),
    );
  }


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

  static final DateFormat _formatter = DateFormat.yMd('ja');

  void _convert(String date) {
    print(_formatter.parse(date));
  }

  Future<void> _compute() async {
    // _convert('2022/01/01 00:00'); <- work correctly
    compute(_convert, '2022/01/01 00:00'); <- throw LocaleDataException
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('compute'),
      ),
      body: Center(child: Text('compute test')),
      floatingActionButton: FloatingActionButton(
        onPressed: _compute,
        child: const Icon(Icons.add),
      ), // This trailing comma makes auto-formatting nicer for build methods.
    );
  }
% flutter --version
Flutter 3.3.4 • channel stable • https://github.com/flutter/flutter.git
Framework • revision eb6d86ee27 (6 weeks ago) • 2022-10-04 22:31:45 -0700
Engine • revision c08d7d5efc
Tools • Dart 2.18.2 • DevTools 2.15.0
intl: ^0.17.0
@mosuem mosuem added type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) P3 A lower priority bug or feature request labels Dec 12, 2022
@mosuem mosuem transferred this issue from dart-archive/intl Apr 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P3 A lower priority bug or feature request package:intl type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

2 participants