PopupMenu RadioList In Flutter

Screenshot :

PopupMenu RadioList In Flutter

Program :

import 'package:flutter/material.dart';

void main() {
  runApp(new MaterialApp(
    debugShowCheckedModeBanner: false,
    title: 'MENU',
    home: new MyHomePage(),
  ));
}

class MyHomePage extends StatefulWidget {
  State createState() => new MyHomePageState();
}

List<CustomPopupMenu> choices = <CustomPopupMenu>[
  CustomPopupMenu(title: 'FlutterTutotial', icon: Icons.home),
  CustomPopupMenu(title: 'Tab in Flutter', icon: Icons.bookmark),
  CustomPopupMenu(title: 'Drawer in Flutter', icon: Icons.settings),
];

class MyHomePageState extends State<MyHomePage> {
  ValueNotifier<CustomPopupMenu> _selectedItem = new ValueNotifier<CustomPopupMenu>(choices[0]);

  @override
  Widget build(BuildContext context) {
    return new Scaffold(body: new Center(
      child: new PopupMenuButton<CustomPopupMenu>(
        itemBuilder: (BuildContext context) {
          return new List<PopupMenuEntry<CustomPopupMenu>>.generate(
            choices.length, (int index) {
              return new PopupMenuItem(
                value: choices[index],
                child: new AnimatedBuilder(
                  child: new Text(choices[index].title),
                  animation: _selectedItem,
                  builder: (BuildContext context, Widget child) {
                    return new RadioListTile<CustomPopupMenu>(
                      value: choices[index],
                      groupValue: _selectedItem.value,
                      title: child,
                      onChanged: (CustomPopupMenu value) {
                        _selectedItem.value = value;
                        Navigator.pop(context);
                      },
                    );
                  },
                ),
              );
            },
          );
        },
      ),
    ));
  }
}

class CustomPopupMenu {
  CustomPopupMenu({this.title, this.icon});

  String title;
  IconData icon;
}