0

I want to show double numbers with "," as decimal separator and have to convert strings to double considering the same issue. I do this using the intl package.

Get Locale: String myLocale = await findSystemLocale()
Define Numberformat: myNumberFormat = NumberFormat("##0.00", myLocale);
Read: numberFormat.parse(value.text).toDouble()
Show: numberFormat.format(item.price)

That works fine until I debug it not using "Chrome - web" but "Linux - desktop". Then I get this error:

Invalid depfile: /home/User/Repositories/Cashier/.dart_tool/flutter_build/19fc9eb7bd361f82815989439418e9d9/kernel_snapshot_program.d
ERROR: ../../.pub-cache/hosted/pub.dev/intl-0.20.2/lib/src/web.dart:9:8: Error: Dart library 'dart:js_interop' is not available on this platform.
web.dart:9
ERROR: import 'dart:js_interop';
ERROR:        ^
ERROR: Context: The unavailable library 'dart:js_interop' is imported through these packages:
ERROR:     package:calculator => package:intl => dart:js_interop
ERROR: Detailed import paths for (some of) the these imports:
ERROR:     package:calculator/main.dart => package:intl/intl_browser.dart => package:intl/src/web.dart => dart:js_interop
(a lot more lines)
ERROR: Unhandled exception:
ERROR: Target kernel_snapshot_program failed: Exception
Error: Build process failed

Is this trying to tell me that intl is not available on Linux Mint 22.2? What else can I do to get the locale and convert double to strings back and forth?

6
  • 1
    what are your imports? Commented Oct 21 at 13:53
  • You mean the pubspac.yaml? environment: sdk: ^3.9.0 dependencies: flutter_bloc: ^9.0.0 bloc: ^9.0.0 flutter: sdk: flutter provider: ^6.1.5+1 hive_ce: hive_ce_flutter: intl: ^0.20.2 dev_dependencies: flutter_test: sdk: flutter flutter_lints: ^5.0.0 hive_ce_generator: build_runner: flutter: uses-material-design: true Commented Oct 21 at 16:00
  • If you really mean the imports: ` import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'package:intl/intl_browser.dart'; import 'package:intl/intl.dart'; import 'package:calculator/db.dart'; import 'package:hive_ce_flutter/adapters.dart'; import 'hive/hive_adapters.dart';` Commented Oct 21 at 17:44
  • 1
    is import 'package:intl/intl_browser.dart' a culprit? tried to remove that just for test? Commented Oct 21 at 17:58
  • You are right! intl_browser is causing the issue. I used that for getting the locale. I now used intl/find_localeinstead. Can you explain the issue to a dart beginner like me? And how did you know that this might be the issue? Commented Oct 21 at 18:59

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.