PopupMenu RadioList In Flutter

PopupMenu RadioList In Flutter :

PopupMenu RadioList In Flutter : in this flutter tutorial we design the popup menu with radiolist

the final output and coding given below

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;
}

The flutter tutorial  is a website that bring you the latest and amazing resources of code. All the languages codes are included in this website. The languages like flutter, android, java,kotlin etc.with the help of this languages any user can develop the beautiful application

For more information about Flutter. visit www.fluttertutorial.in