How to use draggable with Bottom Modal Screen? - flutter

I have a showModalBottomScreen activated displaying several images in GridView.
Here's my App Screen with BottomModalSheet on
All of those images are Draggable
Here's the Draggable Image
return Container(child: LongPressDraggable(data: img,feedback: img,child: img));
What I need my app to do is : When I start to drag one of the images, the Bottom Modal Sheet should close(pop) and I must be able to submit the draggable onto a drag target. But the Bottom Modal Sheet closes and I am unable to retain the draggable.
This is what I used:
onDragStarted: ()=> Navigator.of(context).pop()
The error message is get in my debug console: OPTS_INPUT: First frame was drawed before optimized, so skip!
How do I overcome this?

Perhaps you should create a PersistentBottomSheetController controller inside your widget, along with GlobalKey<ScaffoldState> key for your widget's scaffold ( used to control the showModalBottomSheet ) .
And change onDragStarted:() => controller.close()
If you could provide more details about your app, maybe I would be of more help.

Related

Delete picked images one by one from gallery - flutter

I can able to pick the images from gallery and show it up in the UI. I have to delete the one by image after selecting. I done the UI, by showing the red cancel button for each image . But i am unable to delete and show it up un the UI. Please help.
this is my code.
Extract the Bottom Sheet Widget to Separate Stateful Widget and it should work.
setstate won't work inside that particular Bottom Sheet until it's separated to a Stateful Widget. Give it a try.
I Done by myself. The issue is i am using bottom sheet to add the images. To delete the images i called removeAtIndex. it works fine. The problem is the bottom sheet does not know the state of the context, so added statefull builder for the bottom sheet. Now it works fine.

Modal bottom sheet on flutter with interactive background

I want to dim (gray) the background when the bottom sheet opens, like a modal bottom sheet, but still be able to interact with the rest of the UI while the bottom sheet is open - like a regular bottom sheet.
Any ideas?
Even though, I won't recommend creating such an effect as it is not very understandable from the user perspective.
You can achieve this by using the IgnorePointer, Stack and setState((){})
1- Add a field bool showOverlay = false;
2- Align some Container to with Alignment.bottom to represent ur bottom sheet
3- Put some overlay Container with some background color and opacity and wrap it with IgnorePointer(ignoring: true, ...) which will let it not interfere with your widgets below.
I think you got it from here.

I want to make a container under app bar which works like a secondary App Bar where I can put my back icon button and title in the center in flutter

I have tried everything. But I can't find a permanent solution How to put the title in the center while my back icon button on the left side. I want to use this secondary app bar on every screen of my app.
Please check the image below for a better understanding.
This is the problem that I am facing
Take a ListView Widget at body of Scaffold and in its children put first widget as a ListTile that comes under AppBar. So that there will be a leading icon and title in center. After that take a Column and add your needed widgets for every page.

ExpansionTile - how to collapse other tiles, hide keyboard on press

I'm new to Flutter, trying to build my first app.
my main app body contains a one level ExpansionTile list, which can be filterable by a searchbar.
I'm trying to implement the following behavior -
after a user press a tile to reveal the expanded info
1. the keyboard, if present, should hide
2. previously open tile if expanded should collapse
I have tried using GestureDetector on the root widget with on tap function taking focus, but it does not detect tapping on tiles.
using expansionList onExpansionChanged seems logical but i don't understand how to use it
advice will be greatly appreciated..

Flutter overlay is moving

I'm asking how to disable Overlays to move when a Scaffold.of(context).showSnackBar is called like on my video below.
The same thing is happening when the keyboard appear. Sometime the blue floattingButton (+) don't come back to it's original position :-(
Thx in advance.
Problem animation
The FloatingActionButton going up when the Scaffold is displayed is something common to all default implementations.
Give a look to the "Bootom app bar" demo in the Gallery app. Press on the search button and you will see it coming up. Or just add a Scaffold to the app that is built with flutter create command.
This happens because of the way the FAB button is placed on the screen and the effect of displaying the Snackbar by the Scaffold.
The FAB button is displayed at the bottom of the content area of the Scaffold content. When the content area is shrinked to include the BottomAppBar, the FAB goes up with it. It has nothing to do with Overlay.
You have two options:
Either you create your own versiĆ³n of the FAB which is not
controlled by the Scaffold.
Or you hack the Scaffold so the size of the SnackBar is not taken
into account.
For this second option you can try the following:
Go to the file /lib/src/material/scaffold.dart in your flutter installation and look for the line with the code snackBarSize: snackBarSize, inside the _ScaffoldLayout class.
Replace it with snackBarSize: Size(0.0, 0.0),
You will see that the FAB stays in its place.