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

GlobalCupertinoLocalizations class is included in two package #42827

Closed
yuzhihang opened this issue Oct 16, 2019 · 5 comments
Closed

GlobalCupertinoLocalizations class is included in two package #42827

yuzhihang opened this issue Oct 16, 2019 · 5 comments
Labels
a: first hour The first hour of using Flutter a: internationalization Supporting other languages or locales. (aka i18n) d: examples Sample code and demos f: cupertino flutter/packages/flutter/cupertino repository framework flutter/packages/flutter repository. See also f: labels. P2 Important issues not at the top of the work list

Comments

@yuzhihang
Copy link

yuzhihang commented Oct 16, 2019

in the Internation­alizing Flutter apps tutorial
https://flutter.dev/docs/development/accessibility-and-localization/internationalization
two libs are imported
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:flutter_cupertino_localizations/flutter_cupertino_localizations.dart';

but they both have GlobalCupertinoLocalizations

flutter version

[✓] Flutter (Channel stable, v1.9.1+hotfix.4)

import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:flutter_cupertino_localizations/flutter_cupertino_localizations.dart';

MaterialApp(
 localizationsDelegates: [
   // ... app-specific localization delegate[s] here
   GlobalMaterialLocalizations.delegate,
   GlobalWidgetsLocalizations.delegate,
   GlobalCupertinoLocalizations.delegate,  //class conflict here

 ],
 supportedLocales: [
    const Locale('en'), // English
    const Locale('he'), // Hebrew
    const Locale.fromSubtags(languageCode: 'zh'), // Chinese *See Advanced Locales below*
    // ... other locales the app supports
  ],
  // ...
)
@BondarenkoStas BondarenkoStas added d: examples Sample code and demos framework flutter/packages/flutter repository. See also f: labels. labels Oct 16, 2019
@HansMuller HansMuller added a: internationalization Supporting other languages or locales. (aka i18n) f: cupertino flutter/packages/flutter/cupertino repository labels Oct 16, 2019
@ferrazrx
Copy link

ferrazrx commented Nov 1, 2019

same problem

@Hixie Hixie added this to the Goals milestone Jan 6, 2020
@Hixie Hixie added the a: first hour The first hour of using Flutter label Jan 6, 2020
@jmagman jmagman added this to Awaiting triage in Tools - installer / upgrade review Jan 10, 2020
@jmagman jmagman removed this from Awaiting triage in Tools - installer / upgrade review Jan 10, 2020
@BassamxMednini
Copy link

I get this error:

The name 'GlobalCupertinoLocalizations' is defined in the libraries 'package:flutter_cupertino_localizations/src/cupertino_localizations.dart (via package:flutter_cupertino_localizations/flutter_cupertino_localizations.dart)' and 'package:flutter_localizations/src/cupertino_localizations.dart (via package:flutter_localizations/flutter_localizations.dart)'.
Try using 'as prefix' for one of the import directives, or hiding the name from all but one of the imports.

@SaloGala
Copy link

SaloGala commented Jan 27, 2020

Well, seems like the GlobalCupertinoLocalizations package is no longer needed for Cupertino localizations.

Errors related to missing implementations were fixed on this PR, however, the author stated that is no longer needed.

So we should use the one from:

import 'package:flutter_localizations/flutter_localizations.dart';

@jmagman jmagman added this to Awaiting Triage in Mobile - localization & intl Feb 25, 2020
@GaryQian GaryQian moved this from Awaiting Triage to Engineer Reviewed in Mobile - localization & intl Mar 23, 2020
@kf6gpe kf6gpe added the P2 Important issues not at the top of the work list label May 29, 2020
@Hixie Hixie removed this from the None. milestone Aug 17, 2020
@pedromassangocode
Copy link

Hi @yuzhihang
The tutorial you mentioned is now updated and now you just need to import on file:

import 'package:flutter_localizations/flutter_localizations.dart';

This file will give you all required localization delegates to use in your app:

import 'package:flutter_localizations/flutter_localizations.dart';

MaterialApp(
 localizationsDelegates: [
   // ... app-specific localization delegate[s] here
   GlobalMaterialLocalizations.delegate,
   GlobalWidgetsLocalizations.delegate,
   GlobalCupertinoLocalizations.delegate,
 ],
 supportedLocales: [
    const Locale('en'), // English
    const Locale('he'), // Hebrew
    const Locale.fromSubtags(languageCode: 'zh'), // Chinese *See Advanced Locales below*
    // ... other locales the app supports
  ],
  // ...
)

Closing this as fixed. If you disagree please feel free to write a comment bellow and I will reopen it.
Thank you

@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
a: first hour The first hour of using Flutter a: internationalization Supporting other languages or locales. (aka i18n) d: examples Sample code and demos f: cupertino flutter/packages/flutter/cupertino repository framework flutter/packages/flutter repository. See also f: labels. P2 Important issues not at the top of the work list
Projects
Mobile - localization & intl
  
Engineer Reviewed
Development

No branches or pull requests

9 participants