import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

class SelectionDialog<T> extends StatefulWidget{
  @override
  State<StatefulWidget> createState() => SelectionDialogState();

  String title;
  List<T> items;
  show({@required String title, @required List<T> items}){
    this.title = title;
  }
}

class SelectionDialogState extends State<SelectionDialog>{

  @override
  Widget build(BuildContext context) {
    return Column(
      crossAxisAlignment: CrossAxisAlignment.stretch,
      mainAxisAlignment: MainAxisAlignment.center,
      children: [
        Container(
          decoration: BoxDecoration(color: Colors.white, borderRadius: BorderRadius.circular(15)),
          child: Column(
            children: [
              Padding(
                padding: const EdgeInsets.all(15),
                child: Text(widget.title,),
              ),

              Container(height: 0.5, color: Colors.grey,),

              ListView.separated(
                  padding: EdgeInsets.all(10),
                  itemCount: widget.items.length,
                  itemBuilder: (ctx,idx) => item(idx),
                  separatorBuilder: (ctx,idx) => Container(height: 0.25, color: Colors.grey.withOpacity(0.7),))
            ],
          ),
        )
      ],
    );
  }

  Widget item(int idx){
    var model = widget.items[idx];
    return Container(
      padding: EdgeInsets.all(10),
      height: 20,
      color: Colors.blue,
      child: Text(model.toString()),
    );
  }

}