How to add wp visual editor in a custom widget?

Embedding WYSIWYG Editor in Custom widget needs the declaration of the fields under a form function, this will create a WYSIWYG Editor in your widget.
You can define your parameter, what all features you want to show.

public function form( $instance ) {

    $rand    = rand( 0, 999 );
    $ed_id   = $this->get_field_id( 'wp_editor_' . $rand );
    $ed_name = $this->get_field_name( 'wp_editor_' . $rand );
    $content="Hello World!";
    $editor_id = $ed_id;
    $settings = array('media_buttons' => true,'textarea_rows' => 4,'textarea_name' => $ed_name,'teeny' => true,);
    wp_editor( $content, $editor_id, $settings );