Flutter showDialog on top of a widget - flutter

I'm developing a chat application which allows users to reply to others' messages. I want to make it so that when user long pressed a chat bubble, a dialog will appear directly on top of the bubble with the options to either reply or forward. I tried using showDialog, but the dialog always appears in the center. Is there any way to do this with flutter? Any help will be appreciated.

Please refer to this focused_menu plugin
Example
or
You can also try flutter menu

You can use show aligned dialog.

Just use flutter_smart_dialog: ^4.5.3+7
or use aligned_dialog: ^0.0.6

Make custom dialog by giving scaffold a transperant background. pass your custom widget to the body, align it wherever you want
showGeneralDialog(
barrierColor: Colors.black.withOpacity(0.8),
context: context,
barrierDismissible: false,
barrierLabel: MaterialLocalizations.of(context).modalBarrierDismissLabel,
transitionDuration: const Duration(milliseconds: 200),
pageBuilder: (context, animation1, animation2) {
return Scaffold(
body:CustomWidgetDialog(),
);
},
);

Related

On tap on suggestion in search bar not working in flutter web using flutter_typeahead package

I'm using flutter_typeahead: ^4.3.3 package for search bar.
When the onChange event is dispatched, it will call API and show suggestion on that but it's running one keyword behind the actual search and whenever I try to tap on suggestion it will not navigate to next screen.
I had try to navigate on onSuggestionSelected, onTap and suggestionsCallback but it will not navigate to next screen.
The issue you're facing with flutter_typeahead might be due to incorrect implementation of the onSuggestionSelected or onTap event handlers.
To correctly navigate to the next screen, you need to use the Navigator class in Flutter. Here's an example on how to do it using the onSuggestionSelected event handler:
TypeAheadField(
onSuggestionSelected: (suggestion) {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => YourNextScreen(suggestion),
),
);
},
// Other TypeAheadField properties and configurations
)
In the code above, YourNextScreen is the widget class for the next screen you want to navigate to. The suggestion argument is the selected suggestion from the suggestions list.
Make sure to pass the appropriate BuildContext to the Navigator and also ensure that you have set up the routing in your Flutter app.

How do I trigger an action/detect when a user swipes away from a ModalBottomSheet in a Flutter app?

I have implemented a filter feature in my app, which opens up a modalBottomSheet with some filtering options when a user clicks on a particular button.
I want to get data from my database based on the filters, right when the user clicks/swipes away from the modalBottomSheet.
How do I detect that they've done this?
Is there a better way to do this?
showModalBottomSheet(
context: context,
builder: (context){
return Text("example");
}).then((value) => {
//database things
});
You can use like this. You can detect bottomsheet is closed with this way.

Flutter show double bottomsheet type design

I need to know what type of widget is this in flutter or how can create this. I know this question is irrelevant but I didn't find this so that's why I need to ask
You can see it's showing a round bottom sheet type thing and in the background show one more rounded bottom sheet. These types of things I see in every app now and need to design something similar any help how can I achieve this?
try modal_bottom_sheet:
showCupertinoModalBottomSheet(
context: context,
builder: (context) => Container(),
)

How to Swipe a card in a group of listview and open repective page releated to that card while using Page View in flutter?

Image understands you the purpose better
https://i.stack.imgur.com/Z45YH.jpg
I tried everything but failed!
Navigating
Navigating to a new Page is easy
Navigator.push(
context,
MaterialPageRoute(builder: (context) => SecondRoute()),
);
"SecoundRoute" is the Widget you will open in a new Window.
More information about this here.
Swipe gesture
This is a bit more complicated. There is a widget called "Dismissible" but like the name say its to dismiss something from a List. There is an issue which suggests to make it possible to avoid deleting the entry from the ListView directly. However, this is inactive. I don't know whether this feature is there or where it is on the priority list.
dismissible
If you use a prebuild and static list of widgets you can maybe get around it, by navigating to the naw page in the onDismissed: callback and using pushReplacement in the rout back. This will case your main page to get Rebuild. Because your Widgets are static I think they will be their again.
Navigator.pushReplacement(
context,
MaterialPageRoute(
builder: (context) => Page1(),
),
);
flutter_slidable
There is a plugin called flutter_slidable perhaps a solution can be found with this plugin.

Mimic iOS 13 fullscreen dialog

I noticed that in iOS 13 full screen dialog has changed, introducing a new slide from bottom animation.
Here is an example
Is it possible to mimic this behaviour with flutter? iOS animation it's not a simple slide from bottom but involves also the background page.
Looking throught flutter documentation I found this class but, without any example I can't understand how to use it or if it's what I'm searching.
Thanks
Update: Based on another answer by #VadimKo, I now understand that the stacking effect might also be desired. The answer linked to a package modal_bottom_sheet based on which I have updated my example
If I'm understanding your question right, you want to show a full screen dialog that slides up from the bottom and has UI similar to the one showed in your picture.
CupertinoFullscreenDialogTransition is really just two SlideTransitions stacked up so it's nothing special.
You could achieve something close to the posted images by using showGeneralDialog
In that, you could show anything using the combination of pageBuilder and transitionBuilder. It's very flexible and can even be used to show full routes on top of current route.
If you use CupertinoFullscreenDialogTransition as the pageBuilder it should achieve your goal. It's not required to provide a transitionBuilder since it's being performed by the pageBuilder implicitly.
The following example tries to mimic requested UI by using CupertinoApp, CustomScrollView and CupertinoSliverNavigationBar for the content of the dialog
Update: A transitionBuilder similar to the one provided by modal_bottom_sheet can be used to add the stacking effect.
Important code from the DartPad example:
showGeneralDialog(
barrierDismissible: true,
barrierLabel: 'Settings',
barrierColor: Colors.black,
context: context,
/// This would be slow but good to understand how transitions are working
transitionDuration: const Duration(seconds: 1),
/// Optionally provide the [transitionBuilder] to get the stacking effect
/// as of iOS 13
transitionBuilder: (context, animation, secondaryAnimation, child) {
/// The following transition widget was inspired from `modal_bottom_sheet` package
/// Some modifications have been made to remove certain limitations,
/// See the full DartPad example or take a look at `modal_bottom_sheet`
return _CupertinoModalTransition(
animation: animation,
child: child,
/// This renders the current widget behind the modal
/// Notice the use of [this], it is to make sure correct context is used
behindChild: this.build(this.context),
);
},
pageBuilder: (context, animation, secondaryAnimation) {
/// This is the simplest use case for [CupertinoFullscreenDialogTransition]
/// This provides the slide up and slide down transition effects
return CupertinoFullscreenDialogTransition(
primaryRouteAnimation: animation,
secondaryRouteAnimation: secondaryAnimation,
/// Content of your dialog
child: Container(),
linearTransition: true,
);
},
);
DartPad Full example : https://dartpad.dev/57de88ce8d64dff9d3e6fe0627a8b654
Update: The DartPad example works just like modal_bottom_sheet but without any need to make changes to existing code such as the requirement to use MaterialWithModalsPageRoute or to wrap current/preview routes in CupertinoScaffold both of which are provided by the same package.
Preview:
See the GIF preview: https://i.imgur.com/mZ77M62.gifv
Note: There is already showCupertinoDialog provided by the flutter team but it doesn't provide as much flexibility. It can however be used for normal small dialog popups that don't usually take full screen space.
You can always build your own widgets, however in this case you can use an existing package: Modal bottom sheet
you can also check some more existing flutter issues here: enter link description here
You can use this package cupertino_fullscreen_modal
CupertinoFullscreenModal.of(context).showModal(Widget child, onClose (popValue) {});
You can also try another already existing package Cupertino Stackview
CupertinoStackView(
true, //_isPrimary
"Page I", //_navigation
Scaffold(...), //_child
Colors.black, //_backgroundColor
{Key key,
isDismissible : true,
radius : Radius.circular(10.0)})