简体   繁体   中英

Flutter convert package or dart:convert

I am following a Flutter tutorial . JSON is converted using the dart convert library: import 'dart:convert';
However, I see that a flutter package is available which would also work, using: import 'package:convert/convert.dart'; and adding convert: ^2.1.1 as a dependency in the app pubspec.yaml file.

The convert package readme states "This package contains encoders and decoders for converting between different data representations. It's the external counterpart of the dart:convert core library, and contains less-central APIs and APIs that need more flexible versioning ."

What does " contains less-central APIs and APIs that need more flexible versioning " mean?
Which method is preferable / best practice and why? Are there performance differences between using the dart:convert core library and the Flutter package?

'dart:convert' contains the conversion utility that's built-in to the Dart framework. package:convert on the other hand is the external counterpart. Depending on the API that you need to use, you can use either of the two as needed. If the converter that you need is present on one, you can use that library, and same the other way around.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM