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

class FlutTextTheme extends FlutImmutableObject {
  final TextTheme textTheme;

  const FlutTextTheme(this.textTheme) : super('TextTheme');

  @override
  Map<String, dynamic> flutEncode() {
    final result = flutBaseProps();
    if (textTheme.headlineMedium != null) {
      result['headlineMedium'] = FlutTextStyle(
        textTheme.headlineMedium!,
      ).flutEncode();
    }
    return result;
  }

  static TextTheme? flutDecode(FlutRuntime runtime, Map<String, dynamic> data) {
    return TextTheme(
      headlineMedium: runtime.unpackOptionalField<TextStyle>(
        data,
        'headlineMedium',
      ),
    );
  }
}
