Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dropdown remains static on iPhone app #255

Open
cnickel76 opened this issue Apr 15, 2024 · 6 comments
Open

Dropdown remains static on iPhone app #255

cnickel76 opened this issue Apr 15, 2024 · 6 comments
Labels
question Further information is requested

Comments

@cnickel76
Copy link

I'm using the multi select dropdown widget in a Flutterflow app, within a drawer (drawn from the left hand side of the page). It works fine on Android and iPad, but not on iphone. There the widget does not unfold, it stays static and useless. Can someone help? Thanks

@AhmedLSayed9
Copy link
Owner

Please make a minimal reproducible example.

@AhmedLSayed9 AhmedLSayed9 added the question Further information is requested label Apr 15, 2024
@cnickel76
Copy link
Author

cnickel76 commented Apr 15, 2024

this is the screenshot of Flutterflow test mode, where the widget nicely unfolds.
On the iphone, is does not unfold at all.

Capture d'écran 2024-04-15 161419

@cnickel76
Copy link
Author

this is the code of my custom widget in Flutterflow:
// Automatic FlutterFlow imports
import '/backend/backend.dart';
import '/backend/schema/structs/index.dart';
import '/backend/supabase/supabase.dart';
import '/flutter_flow/flutter_flow_theme.dart';
import '/flutter_flow/flutter_flow_util.dart';
import '/custom_code/widgets/index.dart'; // Imports other custom widgets
import '/custom_code/actions/index.dart'; // Imports custom actions
import '/flutter_flow/custom_functions.dart'; // Imports custom functions
import 'package:flutter/material.dart';
// Begin custom widget code
// DO NOT REMOVE OR MODIFY THE CODE ABOVE!

import 'package:dropdown_button2/dropdown_button2.dart';

// ignore: must_be_immutable
class MyDDWidget2 extends StatefulWidget {
@OverRide
MyDDWidget2({
super.key,
this.width,
this.height,
required this.items,
required this.selectedItems,
});

final double? width;
final double? height;
List items;
List selectedItems;
@OverRide
State createState() => _MyDDWidget2State();
}

class _MyDDWidget2State extends State {
@OverRide
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: DropdownButtonHideUnderline(
child: DropdownButton2(
isExpanded: true,
hint: Text(
'Select Category',
style: TextStyle(
fontSize: 14,
color: Theme.of(context).hintColor,
),
),
items: widget.items.map((item) {
return DropdownMenuItem(
value: item,
//disable default onTap to avoid closing menu when selecting an item
enabled: false,
child: StatefulBuilder(
builder: (context, menuSetState) {
final isSelected = widget.selectedItems.contains(item);
return InkWell(
onTap: () {
isSelected
? widget.selectedItems.remove(item)
: widget.selectedItems.add(item);
//This rebuilds the StatefulWidget to update the button's text
FFAppState().update(() {
FFAppState().selEventCats = widget.selectedItems;
});
//This rebuilds the dropdownMenu Widget to update the check mark
menuSetState(() {});
},
child: Container(
height: double.infinity,
padding: const EdgeInsets.symmetric(horizontal: 16.0),
child: Row(
children: [
if (isSelected)
const Icon(Icons.check_box_outlined)
else
const Icon(Icons.check_box_outline_blank),
const SizedBox(width: 16),
Expanded(
child: Text(
item,
style: const TextStyle(
fontSize: 12,
),
),
),
],
),
),
);
},
),
);
}).toList(),
//Use last selected item as the current value so if we've limited menu height, it scroll to last item.
value:
widget.selectedItems.isEmpty ? null : widget.selectedItems.last,
onChanged: (value) {},
selectedItemBuilder: (context) {
return widget.items.map(
(item) {
return Container(
alignment: AlignmentDirectional.center,
child: Text(
widget.selectedItems.join(', '),
style: const TextStyle(
fontSize: 12,
overflow: TextOverflow.ellipsis,
),
maxLines: 1,
),
);
},
).toList();
},
buttonStyleData: const ButtonStyleData(
padding: EdgeInsets.only(left: 16, right: 8),
height: 30,
width: 180,
),
menuItemStyleData: const MenuItemStyleData(
height: 30,
padding: EdgeInsets.zero,
),
),
),
),
);
}
}

@AhmedLSayed9
Copy link
Owner

Unfortunately, I can't help with that. I can't run the code given.

I'll need a minimal reproducible example.

@cnickel76
Copy link
Author

Well I do not know what to add here... the code that I pasted was simply taken from your pub.dev package webpage.

@AhmedLSayed9
Copy link
Owner

AhmedLSayed9 commented Apr 17, 2024

Yes, but I can't run that sample. It has dependencies that I don't have:

import '/backend/backend.dart';
import '/backend/schema/structs/index.dart';
import '/backend/supabase/supabase.dart';
import '/flutter_flow/flutter_flow_theme.dart';
import '/flutter_flow/flutter_flow_util.dart';
import '/custom_code/widgets/index.dart'; // Imports other custom widgets
import '/custom_code/actions/index.dart'; // Imports custom actions
import '/flutter_flow/custom_functions.dart'; // Imports custom functions

Also, you should put the code refactored into a code block like the above one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants