Comments (6)
Please make a minimal reproducible example.
from dropdown_button2.
this is the screenshot of Flutterflow test mode, where the widget nicely unfolds.
On the iphone, is does not unfold at all.
from dropdown_button2.
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,
),
),
),
),
);
}
}
from dropdown_button2.
Unfortunately, I can't help with that. I can't run the code given.
I'll need a minimal reproducible example.
from dropdown_button2.
Well I do not know what to add here... the code that I pasted was simply taken from your pub.dev package webpage.
from dropdown_button2.
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.
from dropdown_button2.
Related Issues (20)
- Very slow loading multiple dropdown buttons on one screen HOT 4
- Allow closing dropdown programatically HOT 5
- Accept focusNode property in DropdownItem
- Cannot simultaneously update items and values in beta HOT 2
- The splash effect goes above the error / validation text
- Close programatically on Escape pressed HOT 4
- How can i create menu items with exactly height for each element
- Not possible to have label, text and dropdown values all aligned with OutlineInputBorder HOT 2
- Show selected item when page initialized HOT 6
- onChanged doesn't work when using multiValueListenable HOT 2
- DropdownButtonFormField2 initial value HOT 2
- barrierCoversButton: false property not working
- Not resetting the search querry before reopening the menu breaks the dropdown menu scroll position calculation algorithm
- The package interferes with TextField HOT 1
- Being able to set the errorText HOT 1
- Ink splashes get displayed over search widget HOT 2
- Disable focus on DropdownItem HOT 11
- How to wrap TapRegion with groupID around DropdownButtonFormField2 to track TapInside / TapOutside with other TapRegions
- Add an ability to override comparator function HOT 21
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dropdown_button2.