### Initialize DictReader with initDict Source: https://github.com/mumu-lhl/dict_reader/blob/main/example/README.md Demonstrates how to initialize the DictReader with granular control using the `initDict` method. It shows examples of partial initialization (only header) and full initialization, along with closing the reader. ```dart import 'package:dict_reader/dict_reader.dart'; void main() async { final dictReader = DictReader("MDX FILE PATH"); // Only initialize header await dictReader.initDict(readKeys: false, readRecordBlockInfo: false); // ... perform operations // Full initialization await dictReader.initDict(); // ... perform other operations await dictReader.close(); } ``` -------------------------------- ### Search for Keys with search Source: https://github.com/mumu-lhl/dict_reader/blob/main/example/README.md Illustrates how to use the `search` method to find keys that match a given query. It includes examples of searching with and without a limit, returning a list of matching keys. ```dart import 'package:dict_reader/dict_reader.dart'; void main() async { final dictReader = DictReader("MDX FILE PATH"); await dictReader.initDict(); final keys = dictReader.search("go"); print(keys); final keysWithLimit = dictReader.search("go", limit: 1); print(keysWithLimit); await dictReader.close(); } ``` -------------------------------- ### Install dict_reader Package Source: https://github.com/mumu-lhl/dict_reader/blob/main/README_CN.md Command to add the dict_reader package to your Dart project using the Dart package manager. ```sh dart pub add dict_reader ``` -------------------------------- ### Initialize DictReader with initDict Source: https://github.com/mumu-lhl/dict_reader/blob/main/example/README_CN.md Demonstrates how to initialize the DictReader with fine-grained control over the initialization process using the `initDict` method. It shows examples of initializing only the header or performing a full initialization. The `initDict` method accepts parameters like `readKeys`, `readRecordBlockInfo`, and `readHeader` to customize the initialization. ```dart import 'package:dict_reader/dict_reader.dart'; void main() async { final dictReader = DictReader("MDX FILE PATH"); // 仅初始化头部 await dictReader.initDict(readKeys: false, readRecordBlockInfo: false); // ... 执行操作 // 完全初始化 await dictReader.initDict(); // ... 执行其他操作 await dictReader.close(); } ``` -------------------------------- ### Locate and Read Entry Source: https://github.com/mumu-lhl/dict_reader/blob/main/example/README_CN.md Shows how to locate a specific entry in the dictionary using its key and then read the corresponding data. It first initializes the DictReader, then uses the `locate` method to get the offset information for a given key, and finally reads the MDX record using `readOneMdx`. ```dart import 'package:dict_reader/dict_reader.dart'; void main() async { final dictReader = DictReader("MDX FILE PATH"); await dictReader.initDict(); final offsetInfo = await dictReader.locate("go"); print(await dictReader.readOneMdx(offsetInfo!)); await dictReader.close(); } ``` -------------------------------- ### Read Data After Stored Data Offset Source: https://github.com/mumu-lhl/dict_reader/blob/main/example/README.md Provides an example of reading data using a stored offset after initializing the `DictReader` with reduced overhead by setting `readKeys` and `readRecordBlockInfo` to false. This optimizes initialization time for scenarios where only specific data is needed later. ```dart import 'package:dict_reader/dict_reader.dart'; // ... void main() { // ... final dictReader = DictReader("MDX FILE PATH"); // Pass false to reduce initialization time await dictReader.initDict(readKeys: false, readRecordBlockInfo: false); final offsetInfo = map["go"]; print(await dictReader.readOneMdx(offsetInfo!)); await dictReader.close(); } ``` -------------------------------- ### Install dict_reader package Source: https://github.com/mumu-lhl/dict_reader/blob/main/README.md This command adds the dict_reader package to your Dart project's dependencies using the Dart package manager. ```sh dart pub add dict_reader ``` -------------------------------- ### Read Data Offset with readWithOffset Source: https://github.com/mumu-lhl/dict_reader/blob/main/example/README.md Illustrates how to use `readWithOffset` to get `RecordOffsetInfo` for each key, allowing for later retrieval of data using `readOneMdx`. This method is useful for building an index or accessing data selectively. ```dart import 'package:dict_reader/dict_reader.dart'; void main() async { final dictReader = DictReader("MDX FILE PATH"); await dictReader.initDict(); final map = {}; await for (final offsetInfo in dictReader.readWithOffset()) { map[offsetInfo.keyText] = offsetInfo; } final offsetInfo = map["go"]; print(await dictReader.readOneMdx(offsetInfo!)); await dictReader.close(); } ``` -------------------------------- ### Search for Keys Source: https://github.com/mumu-lhl/dict_reader/blob/main/example/README_CN.md Illustrates how to search for keys within the dictionary. The `search` method returns a list of keys that match the provided query. It also shows how to limit the number of search results using the `limit` parameter. ```dart import 'package:dict_reader/dict_reader.dart'; void main() async { final dictReader = DictReader("MDX FILE PATH"); await dictReader.initDict(); final keys = dictReader.search("go"); print(keys); final keysWithLimit = dictReader.search("go", limit: 1); print(keysWithLimit); await dictReader.close(); } ``` -------------------------------- ### Read Data with Saved Offsets (Optimized Initialization) Source: https://github.com/mumu-lhl/dict_reader/blob/main/example/README_CN.md Demonstrates reading data using pre-saved offset information when the DictReader is initialized with reduced settings (e.g., `readKeys: false`). This approach can speed up initialization when only data reading is required and offsets are already available. ```dart import 'package:dict_reader/dict_reader.dart'; // ... void main() async { // ... final dictReader = DictReader("MDX FILE PATH"); // Pass false to reduce initialization time await dictReader.initDict(readKeys: false, readRecordBlockInfo: false); final offsetInfo = map["go"]; print(await dictReader.readOneMdx(offsetInfo!)); await dictReader.close(); } ``` -------------------------------- ### Locate Data with locate Source: https://github.com/mumu-lhl/dict_reader/blob/main/example/README.md Shows how to use the `locate` method to find the offset information for a given key and then read the corresponding data using `readOneMdx`. This is useful for accessing specific records efficiently. ```dart import 'package:dict_reader/dict_reader.dart'; void main() async { final dictReader = DictReader("MDX FILE PATH"); await dictReader.initDict(); final offsetInfo = await dictReader.locate("go"); print(await dictReader.readOneMdx(offsetInfo!)); await dictReader.close(); } ``` -------------------------------- ### Read All Data with MDX Data Source: https://github.com/mumu-lhl/dict_reader/blob/main/example/README_CN.md Shows how to iterate through all entries in the dictionary and read their key text and data. The `readWithMdxData` method provides an asynchronous stream of `MdxRecord` objects, each containing the `keyText` and `data`. ```dart import 'package:dict_reader/dict_reader.dart'; void main() async { final dictReader = DictReader("MDX FILE PATH"); await dictReader.initDict(); await for (final MdxRecord(:keyText, :data) in dictReader.readWithMdxData()) { print("$keyText, $data"); } await dictReader.close(); } ``` -------------------------------- ### Read Data Using Offsets Source: https://github.com/mumu-lhl/dict_reader/blob/main/example/README_CN.md Explains how to read data by first obtaining offset information for all entries and then reading specific records using these offsets. The `readWithOffset` method streams `RecordOffsetInfo` objects, which can be stored and used later with `readOneMdx`. ```dart import 'package:dict_reader/dict_reader.dart'; void main() async { final dictReader = DictReader("MDX FILE PATH"); await dictReader.initDict(); final map = {}; await for (final offsetInfo in dictReader.readWithOffset()) { map[offsetInfo.keyText] = offsetInfo; } final offsetInfo = map["go"]; print(await dictReader.readOneMdx(offsetInfo!)); await dictReader.close(); } ``` -------------------------------- ### Read Data Directly with readWithMdxData Source: https://github.com/mumu-lhl/dict_reader/blob/main/example/README.md Shows how to iterate through all records in the MDX file and read their key text and data directly using the `readWithMdxData` stream. This is suitable for processing the entire dictionary content. ```dart import 'package:dict_reader/dict_reader.dart'; void main() async { final dictReader = DictReader("MDX FILE PATH"); await dictReader.initDict(); await for (final MdxRecord(:keyText, :data) in dictReader.readWithMdxData()) { print("$keyText, $data"); } await dictReader.close(); } ``` -------------------------------- ### Check Key Existence with exist Source: https://github.com/mumu-lhl/dict_reader/blob/main/example/README.md Demonstrates the usage of the `exist` method to check if a specific key is present in the dictionary. It returns a boolean value indicating the presence or absence of the key. ```dart import 'package:dict_reader/dict_reader.dart'; void main() async { final dictReader = DictReader("MDX FILE PATH"); await dictReader.initDict(); final keyExists = dictReader.exist("go"); print(keyExists); final keyDoesNotExist = dictReader.exist("non-existent-key"); print(keyDoesNotExist); await dictReader.close(); } ``` -------------------------------- ### Check Key Existence Source: https://github.com/mumu-lhl/dict_reader/blob/main/example/README_CN.md Demonstrates how to check if a key exists in the dictionary using the `exist` method. This method returns a boolean value indicating whether the key is present. ```dart import 'package:dict_reader/dict_reader.dart'; void main() async { final dictReader = DictReader("MDX FILE PATH"); await dictReader.initDict(); final keyExists = dictReader.exist("go"); print(keyExists); final keyDoesNotExist = dictReader.exist("non-existent-key"); print(keyDoesNotExist); await dictReader.close(); } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.