import 'package:flutter/material.dart';
import 'package:flut/flut/runtime.dart';
import 'package:flut/flut/object.dart';

class FlutWidgetSpan extends FlutImmutableObject {
  final WidgetSpan widgetSpan;
  const FlutWidgetSpan(this.widgetSpan) : super('WidgetSpan');

  @override
  Map<String, dynamic> flutEncode() => flutBaseProps();

  static WidgetSpan? flutDecode(
    FlutRuntime runtime,
    Map<String, dynamic> data,
  ) {
    return WidgetSpan(
      alignment: runtime.unpackRequiredField<PlaceholderAlignment>(
        data,
        'alignment',
      ),
      baseline: runtime.unpackOptionalField<TextBaseline>(data, 'baseline'),
      style: runtime.unpackOptionalField<TextStyle>(data, 'style'),
      child: runtime.unpackRequiredField<Widget>(data, 'child'),
    );
  }
}
