Skip to content

Commit

Permalink
docs: add docs
Browse files Browse the repository at this point in the history
  • Loading branch information
minikin committed Mar 25, 2024
1 parent 0d87437 commit 1864721
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import 'package:flutter/material.dart';
import 'package:rfw/rfw.dart';

/// Returns a map of Catalyst core widget definitions.
///
/// The map contains a collection of [LocalWidgetBuilder] functions
/// that define the core widgets used in Catalyst.
Map<String, LocalWidgetBuilder> get _catalystCoreWidgetsDefinitions =>
<String, LocalWidgetBuilder>{
'TextField': (BuildContext context, DataSource source) {
Expand All @@ -16,5 +20,9 @@ Map<String, LocalWidgetBuilder> get _catalystCoreWidgetsDefinitions =>
},
};

/// Creates a [LocalWidgetLibrary] containing the Catalyst core widgets.
///
/// The [LocalWidgetLibrary] is created using the [_catalystCoreWidgetsDefinitions]
/// map of widget definitions.
LocalWidgetLibrary createCatalystCoreWidgets() =>
LocalWidgetLibrary(_catalystCoreWidgetsDefinitions);
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,22 @@ import 'dart:io';

import 'package:rfw/formats.dart';

/// A class that provides methods for encoding Remote Widget files.
final class RemoteWidgetEncoder {
const RemoteWidgetEncoder._();

/// Converts a text file in the Remote Widget format to the RFW binary format.
///
/// The [inputFile] parameter specifies the path to the input text file.
/// The [outputFile] parameter specifies the path to the output binary file.
///
/// Throws an exception if the conversion fails.
static Future<void> rfwTxtToRfw({
required String inputFile,
required String outputFile,
}) async {
try {
print('Reading to $inputFile');
print('Reading from $inputFile');
final content = await File(inputFile).readAsString();
print('Content: $content');

Expand All @@ -23,7 +30,7 @@ final class RemoteWidgetEncoder {
await File(outputFile).writeAsBytes(bytes);
print('Successfully processed $outputFile');
} catch (e) {
Exception('Failed to process $inputFile: $e');
throw Exception('Failed to process $inputFile: $e');
}
}
}

0 comments on commit 1864721

Please sign in to comment.