stac_framework 0.3.0
stac_framework: ^0.3.0 copied to clipboard
The Stac Framework enables easy creation of parsers for widgets and actions, enhancing Stac's functionality and supporting custom implementations.
Example #
- Import
stac_framework.dart
at the top of your parser file.
import 'package:stac_framework/stac_framework.dart';
-
Initialize your custom parser for a widget or an action and extend it from
StacParser
orStacActionParser
like this.// define `MyCustomWidget` @freezed class MyCustomWidget with _$MyCustomWidget { ... }
a. Let's say we are initializing a widget parser.
class StacWidgetPraser extends Parser<MyCustomWidget> { ... }
b. Let's say we are initializing an action parser.
class StacActionPraser extends StacActionParser<dynamic> { ... }
-
Now implement the required methods in your custom parser.
a. Let's say we are building a widget parser.
class StacWidgetParser extends StacParser<MyCustomWidget> { @override MyCustomWidget getModel(Map<String, dynamic> json) { // TODO: implement getModel throw UnimplementedError(); } @override Widget parse(BuildContext context, MyCustomWidget model) { // TODO: implement parse throw UnimplementedError(); } @override // TODO: implement type String get type => throw UnimplementedError(); }
b. Let's say we are building an action parser.
class StacActionPraser extends StacActionParser<dynamic> { @override // TODO: implement actionType String get actionType => throw UnimplementedError(); @override getModel(Map<String, dynamic> json) { // TODO: implement getModel throw UnimplementedError(); } @override FutureOr onCall(BuildContext context, model) { // TODO: implement onCall throw UnimplementedError(); } }