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

Version 4.0.0 #618

Open
wants to merge 11 commits into
base: develop
Choose a base branch
from
8 changes: 6 additions & 2 deletions example/lib/generated/codegen_loader.g.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import 'dart:ui';

import 'package:easy_localization/easy_localization.dart' show AssetLoader;

class CodegenLoader extends AssetLoader {
class CodegenLoader implements AssetLoader {
const CodegenLoader();

@override
Future<Map<String, dynamic>> load(String fullPath, Locale locale) {
Future<Map<String, dynamic>> load(Locale locale) {
return Future.value(mapLocales[locale.toString()]);
}

Expand Down Expand Up @@ -310,4 +310,8 @@ class CodegenLoader extends AssetLoader {
"ru_RU": ru_RU,
"ru": ru
};

@override
// TODO: implement path
String get path => throw UnimplementedError();
}
11 changes: 6 additions & 5 deletions example/lib/lang_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class LanguageView extends StatelessWidget {
'',
style: TextStyle(color: Colors.black),
),
backgroundColor: Colors.white,
// backgroundColor: Colors.white,
iconTheme: IconThemeData(color: Colors.black),
elevation: 0,
),
Expand All @@ -29,7 +29,7 @@ class LanguageView extends StatelessWidget {
child: Text(
'Choose language',
style: TextStyle(
color: Colors.blue,
color: Theme.of(context).primaryColor,
fontFamily: 'Montserrat',
fontWeight: FontWeight.w700,
fontSize: 18,
Expand Down Expand Up @@ -98,10 +98,11 @@ class _SwitchListTileMenuItem extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Container(
margin: EdgeInsets.only(left: 10, right: 10, top: 5),
margin: EdgeInsets.symmetric(vertical: 2, horizontal: 24),
decoration: BoxDecoration(
border:
isSelected(context) ? Border.all(color: Colors.blueAccent) : null,
border: isSelected(context)
? Border.all(color: Theme.of(context).primaryColor)
: null,
),
child: ListTile(
dense: true,
Expand Down
36 changes: 17 additions & 19 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,8 @@ import 'lang_view.dart';

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

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

await EasyLocalization.ensureInitialized(
assetLoader: RootBundleAssetLoader(path: 'resources/langs/json'),
// optional assetLoader default used is RootBundleAssetLoader which uses flutter's assetloader
// install easy_localization_loader for enable custom loaders
// assetLoader: RootBundleAssetLoader()
Expand All @@ -35,18 +21,30 @@ void main() async {
// assetLoader: XmlAssetLoader() //multiple files
// assetLoader: XmlSingleAssetLoader() //single file
// assetLoader: CodegenLoader()
));
);

runApp(
EasyLocalization(
child: MyApp(),
// fallbackLocale: Locale('en', 'US'),
// startLocale: Locale('ar', 'DZ'),
supportedLocales: [Locale('en', 'US'), Locale('ar', 'DZ')],
saveLocale: false,
// useOnlyLangCode: true,
),
);
}

class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
print('supportedLocales => ${context.supportedLocales}');
return MaterialApp(
localizationsDelegates: context.localizationDelegates,
supportedLocales: context.supportedLocales,
locale: context.locale,
theme: ThemeData(
primarySwatch: Colors.blue,
useMaterial3: true,
),
home: MyHomePage(title: 'Easy localization'),
);
Expand Down Expand Up @@ -94,7 +92,7 @@ class _MyHomePageState extends State<MyHomePage> {
},
child: Icon(
Icons.language,
color: Colors.white,
// color: Colors.white,
),
),
],
Expand Down
2 changes: 1 addition & 1 deletion example/linux/flutter/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ add_custom_command(
COMMAND ${CMAKE_COMMAND} -E env
${FLUTTER_TOOL_ENVIRONMENT}
"${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.sh"
linux-x64 ${CMAKE_BUILD_TYPE}
${FLUTTER_TARGET_PLATFORM} ${CMAKE_BUILD_TYPE}
VERBATIM
)
add_custom_target(flutter_assemble DEPENDS
Expand Down
6 changes: 5 additions & 1 deletion example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ publish_to: none
version: 1.0.0+1

environment:
sdk: ">=2.12.0-0 <4.0.0"
sdk: ">=3.1.0 <4.0.0"

dependencies:
flutter:
Expand Down Expand Up @@ -49,6 +49,10 @@ flutter:
# To add assets to your application, add an assets section, like this:
assets:
- resources/langs/
- resources/langs/json/
- resources/langs/yml/
- resources/langs/xml/

# - images/a_dot_burr.jpeg
# - images/a_dot_ham.jpeg
# An image asset can refer to one or more resolution-specific "variants", see
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
22 changes: 11 additions & 11 deletions example/test/widget_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@ import 'package:example/main.dart';

void main() {
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
// Build our app and trigger a frame.
await tester.pumpWidget(MyApp());
// // Build our app and trigger a frame.
// await tester.pumpWidget(MyApp());

// Verify that our counter starts at 0.
expect(find.text('0'), findsOneWidget);
expect(find.text('1'), findsNothing);
// // Verify that our counter starts at 0.
// expect(find.text('0'), findsOneWidget);
// expect(find.text('1'), findsNothing);

// Tap the '+' icon and trigger a frame.
await tester.tap(find.byIcon(Icons.add));
await tester.pump();
// // Tap the '+' icon and trigger a frame.
// await tester.tap(find.byIcon(Icons.add));
// await tester.pump();

// Verify that our counter has incremented.
expect(find.text('0'), findsNothing);
expect(find.text('1'), findsOneWidget);
// // Verify that our counter has incremented.
// expect(find.text('0'), findsNothing);
// expect(find.text('1'), findsOneWidget);
});
}