Git Product home page Git Product logo

plist_parser's Introduction

📋 Plist Parser for Flutter

pub package codecov

A Flutter Plugin for Plist parser supporting XML and Binary formats.

The parser is designed to read XML and Binary of plist format on Dart and Flutter.

This was inspired by some libraries. please see below details.

🔧 Installation

dependencies:
  plist_parser: "^0.0.9"

📋 Requirements

Dart SDK

environment:
  sdk: ">=2.16.0 <3.0.0"

🐕 Usage

import 'package:plist_parser/plist_parser.dart';
import 'dart:io';

const xml = '''
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
  <key>string_type</key>
  <string>hello plist</string>
  <key>int_type</key>
  <integer>12345</integer>
  <key>double_type</key>
  <real>12.345</real>
  <key>bool_type_true</key>
  <true/>
  <key>bool_type_false</key>
  <false/>
  <key>date_type</key>
  <date>2022-02-11T18:27:45Z</date>
  <key>data_type</key>
  <data>VGVzdCBWYWx1ZQ==</data>
  <key>dict_type</key>
  <dict>
    <key>key1</key>
    <string>value1</string>
    <key>key2</key>
    <integer>2</integer>
  </dict>
  <key>array_type</key>
  <array>
    <string>array item1</string>
    <string>array item2</string>
  </array>
</dict>
</plist>
''';

void main() async {
  // Parse from xml string.
  //
  // Parse method detects the plist format automatically and use xml or binary parser.
  // Default parameter: typeDetection = true.
  // To disable the detection, use typeDetection = false then it will use xml parser.
  var result = PlistParser().parse(xml);
  print(result);

  // Parse from xml file.
  //
  // You can use "parseFile"(for Async) or "parseFileSync".
  var result2 = PlistParser().parseFileSync("${Directory.current.path}/example/plist_xml.plist");
  print(result2);

  // Parse from binary file.
  //
  // It detects binary format and use binary parser automatically.
  var result3 = PlistParser().parseFileSync(
      "${Directory.current.path}/example/plist_binary.plist");
  print(result3);
}

The output are these:

// ※ Formatted for readability
{
    string_type: hello plist, 
    int_type: 12345, 
    double_type: 12.345, 
    bool_type_true: true, 
    bool_type_false: false, 
    date_type: 2022-02-11 18:27:45.000Z, 
    data_type: Test Value, 
    dict_type: {key1: value1, key2: 2}, 
    array_type: [array item1, array item2]
}
{string_type: hello plist, int_type: 12345, double_type: 12.345, bool_type_true: true, bool_type_false: false, date_type: 2022-02-11 18:27:45.000Z, data_type: Test Value, dict_type: {key1: value1, key2: 2, long_key_item_name_aaaaa_bbbbb_ccccc_ddddd_eeeee: long_key_item_value_11111_22222_33333_44444_55555}, array_type: [array item1, array item2], array_type2: [array2 item1, {nest_array: [nest_array_item], nest_dict: {nest_dict_item: 12345}}]}
{array_type2: [array2 item1, {nest_dict: {nest_dict_item: 12345}, nest_array: [nest_array_item]}], date_type: 2022-02-11 18:27:45.000Z, double_type: 12.345, string_type: hello plist, bool_type_true: true, array_type: [array item1, array item2], bool_type_false: false, dict_type: {key1: value1, key2: 2, long_key_item_name_aaaaa_bbbbb_ccccc_ddddd_eeeee: long_key_item_value_11111_22222_33333_44444_55555}, data_type: Test Value, int_type: 12345}

Other examples are stored in /example/plist_parser_example.dart

✨ Inspiration

💡 References

plist_parser's People

Contributors

dirablue avatar jon-salmon avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.