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

class FlutCurve extends FlutImmutableObject {
  final Curve curve;

  const FlutCurve(this.curve) : super('Curve');

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

  static Curve? flutDecode(FlutRuntime runtime, Map<String, dynamic> data) {
    final kind = runtime.unpackRequiredField<String>(data, 'kind');
    switch (kind) {
      case 'linear':
        return Curves.linear;
      case 'decelerate':
        return Curves.decelerate;
      case 'ease':
        return Curves.ease;
      case 'easeIn':
        return Curves.easeIn;
      case 'easeOut':
        return Curves.easeOut;
      case 'easeInOut':
        return Curves.easeInOut;
      case 'fastOutSlowIn':
        return Curves.fastOutSlowIn;
    }
    throw ArgumentError('Unknown Curve kind: $kind');
  }
}
