mirai_framework 0.0.3 mirai_framework: ^0.0.3 copied to clipboard
A local package containing Mirai framework files
Example #
- Import
mirai_framework.dart
at the top of your parser file.
import 'package:mirai_framework/mirai_framework.dart';
-
Initialize your custom parser for a widget or an action and extend it from
MiraiParser
orMiraiActionParser
like this.// define `MyCustomWidget` @freezed class MyCustomWidget with _$MyCustomWidget { ... }
a. Let's say we are initializing a widget parser.
class MiraiWidgetPraser extends MiraiParser<MyCustomWidget> { ... }
b. Let's say we are initializing an action parser.
class MiraiActionPraser extends MiraiActionParser<dynamic> { ... }
-
Now implement the required methods in your custom parser.
a. Let's say we are building a widget parser.
class MiraiWidgetParser extends MiraiParser<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 MiraiActionPraser extends MiraiActionParser<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(); } }