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

class FlutTextSpan extends FlutImmutableObject {
  final TextSpan textSpan;

  const FlutTextSpan(this.textSpan) : super('TextSpan');

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

  static TextSpan? flutDecode(FlutRuntime runtime, Map<String, dynamic> data) {
    return TextSpan(
      text: runtime.unpackOptionalField<String>(data, 'text'),
      style: runtime.unpackOptionalField<TextStyle>(data, 'style'),
      children: runtime.unpackOptionalField<List<InlineSpan>>(data, 'children'),
    );
  }
}
