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

class FlutTextField {
  FlutTextField._();

  static Widget? flutDecode(FlutRuntime runtime, Map<String, dynamic> data) {
    return TextField(
      key: runtime.decodeKey(data),
      controller: runtime.unpackOptionalField<TextEditingController>(
        data,
        'controller',
      ),
      focusNode: runtime.unpackOptionalField<FocusNode>(data, 'focusNode'),
      decoration: runtime.unpackOptionalField<InputDecoration>(
        data,
        'decoration',
      ),
      style: runtime.unpackOptionalField<TextStyle>(data, 'style'),
      textAlign: runtime.unpackRequiredField<TextAlign>(data, 'textAlign'),
      readOnly: runtime.unpackRequiredField<bool>(data, 'readOnly'),
      autofocus: runtime.unpackRequiredField<bool>(data, 'autofocus'),
      obscureText: runtime.unpackRequiredField<bool>(data, 'obscureText'),
      maxLines: runtime.unpackOptionalField<int>(data, 'maxLines'),
      minLines: runtime.unpackOptionalField<int>(data, 'minLines'),
      maxLength: runtime.unpackOptionalField<int>(data, 'maxLength'),
      onChanged: runtime.unpackOptionalCallback(data, 'onChangedId'),
      onSubmitted: runtime.unpackOptionalCallback(data, 'onSubmittedId'),
      enabled: runtime.unpackOptionalField<bool>(data, 'enabled'),
    );
  }
}
