stac_framework 0.2.2 copy "stac_framework: ^0.2.2" to clipboard
stac_framework: ^0.2.2 copied to clipboard

The Stac Framework enables easy creation of parsers for widgets and actions, enhancing Stac's functionality and supporting custom implementations.

Stac Framework #

The Stac Framework package contains the framework files for Stac, such as StacParser and StacActionParser. These classes provide a simple way to create custom parsers for widgets and actions in Stac. This can be useful for extending the functionality of Stac or for implementing custom widgets and actions.

Here are some examples of how the Stac Framework package can be used:

  • Create a custom parser for a new widget that is not supported by Stac out of the box.
  • Create a custom parser for a widget that has additional functionality, such as the ability to handle user input.
  • Create a custom action parser to handle a new type of action, such as sending a message to a remote server.
  • Create a custom action parser to handle an existing action in a different way, such as logging the action before it is executed.

Installation 🚀 #

First, we need to add Stac Framework to our pubspec.yaml file.

Install the plugin by running the following command from the project root:

flutter pub add stac_framework

Usage #

  1. Import stac_framework.dart at the top of your parser file.
 import 'package:stac_framework/stac_framework.dart';
  1. Initialize your custom parser for a widget or an action and extend it from StacParser or StacActionParser like this.

        // define `MyCustomWidget`
       
        @freezed
        class MyCustomWidget with _$MyCustomWidget { ... }
    

    a. Let's say we are initializing a widget parser.

    class StacWidgetParser extends StacParser<MyCustomWidget> { 
        ... 
    }
    

    b. Let's say we are initializing an action parser.

    class StacActionParser  extends StacActionParser<dynamic> {
        ...
    }
    
  2. 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 StacActionParser  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();
        }
    }
    
5
likes
160
points
600
downloads

Publisher

verified publisherstac.dev

Weekly Downloads

The Stac Framework enables easy creation of parsers for widgets and actions, enhancing Stac's functionality and supporting custom implementations.

Repository (GitHub)
Contributing

Topics

#ui #widget #server-driven-ui #dynamic-widgets

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on stac_framework