Home > database >  PopupMenuButton not showing in Flutter
PopupMenuButton not showing in Flutter

Time:01-12

I don't know what it's wrong with my code, PopupMenuButton it's not working,

I have run the flutter update, yet, it seems not to be working.

Below is my code

import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:oga_bliss/screen/add_prop_page.dart';

import '../widget/notice_me.dart';
import '../widget/property_app_bar.dart';
import '../widget/property_tile_widget.dart';

enum SampleItem { itemOne, itemTwo, itemThree }

class ProductPropertyPage extends StatefulWidget {
  const ProductPropertyPage({Key? key}) : super(key: key);

  @override
  State<ProductPropertyPage> createState() => _ProductPropertyPageState();
}

class _ProductPropertyPageState extends State<ProductPropertyPage> {
  final GlobalKey _menuKey = GlobalKey();

  SampleItem? selectedMenu;
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Column(
        children: [
          const PropertyAppBar(title: 'Property'),
          Expanded(
            child: SingleChildScrollView(
              child: Column(
                children: [
                  NoticeMe(
                    title: 'Oops!',
                    desc: 'Your bank account is not yet verify!',
                    icon: Icons.warning,
                    icon_color: Colors.red,
                    border_color: Colors.red,
                    btnTitle: 'Verify Now',
                    btnColor: Colors.blue,
                    onTap: () {},
                  ),
                  PropertyTileWidget(
                    props_image_name:
                        'https://ogabliss.com/project_dir/property/45164d94bc96f243362af5468841cd44.jpg',
                    props_name: 'Newly Built 3 Bedroom flat',
                    props_desc:
                        'this newly built bedroom flat its covered with the latest and later type of euqipment that will keep your day going well',
                    props_price: '90000000000000',
                    props_type: 'Buy',
                    props_bedroom: '100',
                    props_bathroom: '290',
                    props_toilet: '100',
                    onTap: () {
                      _popUpBUtton();
                    },
                  ),
                  PropertyTileWidget(
                    props_image_name:
                        'https://ogabliss.com/project_dir/property/45164d94bc96f243362af5468841cd44.jpg',
                    props_name: 'Newly Built 3 Bedroom flat',
                    props_desc:
                        'this newly built bedroom flat its covered with the latest and later type of euqipment that will keep your day going well',
                    props_price: '90000000000000',
                    props_type: 'Rent',
                    props_bedroom: '100',
                    props_bathroom: '290',
                    props_toilet: '100',
                    onTap: () {
                      _popUpBUtton();
                    },
                  ),
                ],
              ),
            ),
          )
        ],
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: () {
          Get.to(
            () => AddPropertyPage(),
            transition: Transition.upToDown,
          );
        },
        child: const Icon(Icons.add),
      ),
    );
  }

  Widget _popUpBUtton() => PopupMenuButton<String>(
        enabled: true,
        itemBuilder: (context) {
          return [
            const PopupMenuItem(
              child: Text('Submit'),
              value: "One",
            ),
            const PopupMenuItem(
              child: Text('Edit'),
              value: "Two",
            ),
            const PopupMenuItem(
              child: Text('Delete'),
              value: "Three",
            ),
          ];
        },
      );
}

CodePudding user response:

You can't open any widget by tapping another widget ... instead of trying this

@override
  Widget build(BuildContext context) {
    return Column(
      children: [
    _popUpBUtton(),
     ]); }

 
Widget _popUpBUtton() => PopupMenuButton<String>(
        child: PropertyTileWidget(
          props_image_name:
              'https://ogabliss.com/project_dir/property/45164d94bc96f243362af5468841cd44.jpg',
          props_name: 'Newly Built 3 Bedroom flat',
          props_desc:
              'this newly built bedroom flat its covered with the latest and later type of euqipment that will keep your day going well',
          props_price: '90000000000000',
          props_type: 'Buy',
          props_bedroom: '100',
          props_bathroom: '290',
          props_toilet: '100',
        ),
        itemBuilder: (context) {
          return [
            const PopupMenuItem(
              value: "One",
              child: Text('Submit'),
            ),
            const PopupMenuItem(
              value: "Two",
              child: Text('Edit'),
            ),
            const PopupMenuItem(
              value: "Three",
              child: Text('Delete'),
            ),
          ];
        },
      );
}

enter image description here

  • Related