parse method

Future<Widget?> parse(
  1. BuildContext context, {
  2. required String page,
  3. String? url,
  4. required Map<String, dynamic> data,
})
inherited

Implementation

Future<Widget?> parse(BuildContext context,
    {required String page,
    String? url,
    required Map<String, dynamic> data}) async {
  // Cache decoder for same state instance
  if (_decoder == null) {
    _decoder = Decoder(page, url: url, dataSource: data);
    await _decoder!.resolve(context);
  } else if(!_decoder!.hasResolved){
    // fix bug: in some conditions, _decoder has bean initial, but dataSource
    // hasn't, the waining page will be shown.
    // do nothing, waiting for resolving...
    return null;
  }
  Widget widget;
  try {
    widget = _decoder!.toWidget(context);
    print("==================解析控件结束==================");
    print(widget);
    return widget;
  } catch (e) {
    widget = WarningWidget(parentContext:context,name: page, url: url, error: e, solution: "$page load error");
  }
  return widget;
}