当前位置: 首页 > 知识库问答 >
问题:

颤振本地化SDK

孟俊晖
2023-03-14

我有这个问题,索门能帮我吗?因为seet依赖于flutter_localizations,而SDK依赖于intl0.17.0,所以intl0.17.0是必需的。因此,由于seet依赖于intl^0.16.0,版本解决失败。pub get失败(1;因此,由于seet依赖于intl^0.16.0,版本解决失败。)

共有1个答案

卢黎明
2023-03-14

用这个

dependencies:
  easy_localization: ^3.0.0
import 'dart:ui';

import 'package:easy_localization/easy_localization.dart';
//import 'package:easy_localization_loader/easy_localization_loader.dart'; // import custom loaders
import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';

import 'generated/locale_keys.g.dart';
import 'lang_view.dart';

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await EasyLocalization.ensureInitialized();

  runApp(EasyLocalization(
    child: MyApp(),
    supportedLocales: [
      Locale('en', 'US'),
      Locale('ar', 'DZ'),
      Locale('de', 'DE'),
      Locale('ru', 'RU')
    ],
    path: 'resources/langs',
    // fallbackLocale: Locale('en', 'US'),
    // startLocale: Locale('de', 'DE'),
    // saveLocale: false,
    // useOnlyLangCode: true,

    // optional assetLoader default used is RootBundleAssetLoader which uses flutter's assetloader
    // install easy_localization_loader for enable custom loaders
    // assetLoader: RootBundleAssetLoader()
    // assetLoader: HttpAssetLoader()
    // assetLoader: FileAssetLoader()
    // assetLoader: CsvAssetLoader()
    // assetLoader: YamlAssetLoader() //multiple files
    // assetLoader: YamlSingleAssetLoader() //single file
    // assetLoader: XmlAssetLoader() //multiple files
    // assetLoader: XmlSingleAssetLoader() //single file
    // assetLoader: CodegenLoader()
  ));
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      localizationsDelegates: context.localizationDelegates,
      supportedLocales: context.supportedLocales,
      locale: context.locale,
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(title: 'Easy localization'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key? key, required this.title}) : super(key: key);

  final String title;

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  int counter = 0;
  bool _gender = true;

  void incrementCounter() {
    setState(() {
      counter++;
    });
  }

  void switchGender(bool val) {
    setState(() {
      _gender = val;
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(LocaleKeys.title).tr(),
        actions: <Widget>[
          TextButton(
            child: Icon(
              Icons.language,
              color: Colors.white,
            ),
            onPressed: () {
              Navigator.push(
                context,
                MaterialPageRoute(
                    builder: (_) => LanguageView(), fullscreenDialog: true),
              );
            },
          ),
        ],
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Spacer(
              flex: 1,
            ),
            Text(
              LocaleKeys.gender_with_arg,
              style: TextStyle(
                  color: Colors.grey.shade600,
                  fontSize: 19,
                  fontWeight: FontWeight.bold),
            ).tr(args: ['aissat'], gender: _gender ? 'female' : 'male'),
            Text(
              tr(LocaleKeys.gender, gender: _gender ? 'female' : 'male'),
              style: TextStyle(
                  color: Colors.grey.shade600,
                  fontSize: 15,
                  fontWeight: FontWeight.bold),
            ),
            Row(
              mainAxisAlignment: MainAxisAlignment.center,
              children: <Widget>[
                FaIcon(FontAwesomeIcons.male),
                Switch(value: _gender, onChanged: switchGender),
                FaIcon(FontAwesomeIcons.female),
              ],
            ),
            Spacer(
              flex: 1,
            ),
            Text(LocaleKeys.msg).tr(args: ['aissat', 'Flutter']),
            Text(LocaleKeys.msg_named)
                .tr(namedArgs: {'lang': 'Dart'}, args: ['Easy localization']),
            Text(LocaleKeys.clicked).plural(counter),
            TextButton(
              onPressed: () {
                incrementCounter();
              },
              child: Text(LocaleKeys.clickMe).tr(),
            ),
            SizedBox(
              height: 15,
            ),
            Text(
                plural(LocaleKeys.amount, counter,
                    format: NumberFormat.currency(
                        locale: Intl.defaultLocale, symbol: '€')),
                style: TextStyle(
                    color: Colors.grey.shade900,
                    fontSize: 18,
                    fontWeight: FontWeight.bold)),
            SizedBox(
              height: 20,
            ),
            ElevatedButton(
              onPressed: () {
                context.resetLocale();
              },
              child: Text(LocaleKeys.reset_locale).tr(),
            ),
            Spacer(
              flex: 1,
            ),
          ],
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: incrementCounter,
        child: Text('+1'),
      ),
    );
  }
}
 类似资料:
  • 在谷歌Play上部署我的Flitter应用程序后,它在启动时崩溃。它为2台设备(Google Test devices on Play)工作,并为其他设备提供以下错误。 问题:java.lang.不满意LinkError:dalvik.system.PathClassLoader[DexPathList[[[zip file"/data/app/abc.pota.tallxy-1/base.apk

  • 我可以使用“startAfter”和“limit”进行分页,但它有错误。 例如,在Firestore DB中,我有7条记录: 当页面大小为5时,第一页就可以了,因为我使用了: 它给了我1-5项。 当它加载第二页时,我使用了: 问题是第二页结果只有item7,item6消失了。“开始”也有同样的问题。 真希望它有“抵消”功能,有人有解决办法吗?

  • Xcode的输出:在文件中包含从 /Users/dani/development/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher-6.0.3/ios/Classes/FLTURLLauncherPlugin.m: 7: /Users/dani/development/flutter/.pub-cache/hosted/pub.dart

  • 当我试图添加google_sign_in时,flutter_authcloud_firestore它给我带来了一个错误:” [✓] 颤振(通道稳定,v1.5.4-hotfix.2,Linux上,locale en_US.UTF-8)•颤振版本1.5。4-hotfix。2 at/home/ramu/Downloads/tools/颤振•框架版本7a4c33425d(4周前),2019-04-29 1

  • 我想问一下IOS的实施情况 当前场景:基本上,我已经在android平台上开发了该应用程序,现在我想将其转换为IOS平台。由于这是我的第一个应用程序,我真的需要一些有经验的声音来解决我面临的一些问题。 问题: 1-是否有任何简单的方法来检测当前使用的Widget是Android/IOS平台?我们如何才能确定特定的小部件是Android平台的,并且在IOS平台上不工作,反之亦然。 2 -如果我们以某