Flutter/Android Studio :错误:URI的目标不存在:'软件包:flutter_gen/gen_l10n/应用程序本地化.dart'

92dk7w1h  于 2023-01-21  发布在  Android
关注(0)|答案(1)|浏览(461)

Android Studio 大黄蜂

| 2021.1.1 Patch 2
Build #AI-211.7628.21.2111.8193401, built on February 17, 2022
Runtime version: 11.0.11+0-b60-7772763 aarch64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
macOS 12.3
GC: G1 Young Generation, G1 Old Generation
Memory: 1280M
Cores: 8
Registry: external.system.auto.import.disabled=true
Non-Bundled Plugins: com.bloc.intellij_generator_plugin (3.3.0), Dart (211.7811), org.jetbrains.kotlin (211-1.6.10-release-923-AS7442.40), io.flutter (65.2.2), org.intellij.plugins.markdown (211.7142.37)

Flutter-版本

Flutter 2.10.4 • channel stable • https://github.com/flutter/flutter.git
Framework • revision c860cba910 (10 days ago) • 2022-03-25 00:23:12 -0500
Engine • revision 57d3bac3dd
Tools • Dart 2.16.2 • DevTools 2.9.2

本地化
pubspec.yaml

...
  flutter_gen: ^4.1.6
  flutter_localizations:
    sdk: flutter
  intl: ^0.17.0

flutter:
  uses-material-design: true
  generate: true
...

l10n.yaml(在项目根目录中):

arb-dir: lib/l10n/arb
template-arb-file: app_en.arb
output-localization-file: app_localizations.dart
nullable-getter: false

正在尝试导入:

import 'package:flutter_gen/gen_l10n/app_localizations.dart';

但得到错误:

error: Target of URI doesn't exist: 'package:flutter_gen/gen_l10n/app_localizations.dart'

以下SO均未起作用:
one

f1tvaqid

f1tvaqid1#

如果您的代码编辑器(Android Studio)中有intl插件,那么您应该有这个生成的文件夹(lib/generated/l10n.dart)。
在您的终端中运行以下命令' flutter pub run intl_utils:generate'
在检查pubspec.yaml文件时,

dependencies:
    
    flutter:
        sdk: flutter
    flutter_localizations:
        sdk: flutter
    intl_utils: ^2.6.1

flutter_intl:
  enabled: true

那以后就可以了,请试试吧。

相关问题