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

Migrating from 2.2.2 to 3.0.2 not working #12

Closed
RYOKSEC opened this issue Sep 3, 2020 · 2 comments
Closed

Migrating from 2.2.2 to 3.0.2 not working #12

RYOKSEC opened this issue Sep 3, 2020 · 2 comments

Comments

@RYOKSEC
Copy link
Contributor

RYOKSEC commented Sep 3, 2020

when i run the app it throws this error

I/flutter (31556): --LocalizeAndTranslate : deviceLocale(ar)
E/flutter (31556): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: FormatException: Unexpected character (at line 53, character 1)
E/flutter (22483): }
E/flutter (22483): ^
E/flutter (22483): 
E/flutter (22483): #0      _ChunkedJsonParser.fail (dart:convert-patch/convert_patch.dart:1394:5)
E/flutter (22483): #1      _ChunkedJsonParser.parse (dart:convert-patch/convert_patch.dart:918:20)
E/flutter (22483): #2      _parseJson (dart:convert-patch/convert_patch.dart:31:10)
E/flutter (22483): #3      JsonDecoder.convert (dart:convert/json.dart:505:36)
E/flutter (22483): #4      JsonCodec.decode (dart:convert/json.dart:153:41)
E/flutter (22483): #5      LocalizeAndTranslate.initLanguage (package:localize_and_translate/src/main.class.dart:107:20)
E/flutter (22483): <asynchronous suspension>
E/flutter (22483): #6      LocalizeAndTranslate.init (package:localize_and_translate/src/main.class.dart:87:13)
E/flutter (22483): <asynchronous suspension>
E/flutter (22483): #7      main (package:system/main.dart:17:20)
E/flutter (22483): #8      _runMainZoned.<anonymous closure>.<anonymous closure> (dart:ui/hooks.dart:241:25)
E/flutter (22483): #9      _rootRun (dart:async/zone.dart:1184:13)
E/flutter (22483): #10     _CustomZone.run (dart:async/zone.dart:1077:19)
E/flutter (22483): #11     _runZoned (dart:async/zone.dart:1619:10)
E/flutter (22483): #12     runZonedGuarded (dart:async/zone.dart:1608:12)
E/flutter (22483): #13     _runMainZoned.<anonymous closure> (dart:ui/hooks.dart:233:5)
E/flutter (22483): #14     _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:301:19)
E/flutter (22483): #15     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:168:12)
E/flutter (22483): 

here is how i am initializing it

void main() async{
  WidgetsFlutterBinding.ensureInitialized();
  await translator.init(
    localeDefault: LocalizationDefaultType.device,
    languagesList: <String>['ar', 'en'],
    assetsDirectory: 'assets/langs/',
  );


  SystemChrome.setPreferredOrientations(
      [DeviceOrientation.portraitUp , DeviceOrientation.portraitDown])
      .then((_) => runApp(
     Phoenix(
      child: LocalizedApp(
        child: BillingSystem(),
        ),
      )
    ),
  );
}

class BillingSystem extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      localizationsDelegates: translator.delegates, // Android + iOS Delegates
      locale: translator.locale, // Active locale
      supportedLocales: translator.locals(),
      title: 'Billing System',
      theme: ThemeData(
        primaryColor: Color(0xff146eb4),
          textTheme:
          TextTheme(
              headline6: TextStyle(color: Colors.black , fontSize: 22.0 , fontWeight: FontWeight.w500),
              bodyText1: TextStyle(color: Colors.black , fontSize: 16) ,
          )
      ),
      home: AuthenticationPage(),
    );
  }
}

@RYOKSEC
Copy link
Contributor Author

RYOKSEC commented Sep 3, 2020

It was working perfectly in 2.2.2 until suddenly it threw the same error so that i had to upgrade but its not working either

@RYOKSEC RYOKSEC closed this as completed Sep 3, 2020
@RYOKSEC RYOKSEC reopened this Sep 3, 2020
@RYOKSEC
Copy link
Contributor Author

RYOKSEC commented Sep 4, 2020

the problem was caused by the translation files so i checked them and i found that each of them ends with , when removed this fixed the problem it was an error caused by my IDE because it usually inserts a comma at the end of the line when you insert new line in json files

problem example :
"cart" : "Cart",
"add_to_cart" : "Add To Cart",
}

Fix :
"cart" : "Cart",
"add_to_cart" : "Add To Cart" <--here just remove the comma
}

@RYOKSEC RYOKSEC closed this as completed Sep 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant