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

class FlutAlignment extends FlutImmutableObject {
  final Alignment alignment;

  const FlutAlignment(this.alignment) : super('Alignment');

  @override
  Map<String, dynamic> flutEncode() {
    final result = flutBaseProps();
    result['x'] = alignment.x;
    result['y'] = alignment.y;
    return result;
  }

  static Alignment? flutDecode(FlutRuntime runtime, Map<String, dynamic> data) {
    return Alignment(
      runtime.unpackRequiredField<double>(data, 'x'),
      runtime.unpackRequiredField<double>(data, 'y'),
    );
  }
}
