GithubHelp home page GithubHelp logo

Comments (6)

AhmedLSayed9 avatar AhmedLSayed9 commented on June 20, 2024

Please make a minimal reproducible example.

from dropdown_button2.

cnickel76 avatar cnickel76 commented on June 20, 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

from dropdown_button2.

cnickel76 avatar cnickel76 commented on June 20, 2024

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.

AhmedLSayed9 avatar AhmedLSayed9 commented on June 20, 2024

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

I'll need a minimal reproducible example.

from dropdown_button2.

cnickel76 avatar cnickel76 commented on June 20, 2024

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.

AhmedLSayed9 avatar AhmedLSayed9 commented on June 20, 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.

from dropdown_button2.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.