How to use an Overlay without the Navigator/App? - flutter

Are there any code examples out there that show how to use an Overlay independant of a Navigator widget?
In our app, we do not want the TitleBar/AppBar to be part of the main nav-stack, it should stay at the top of the window, and be fixed position.
The TitleBar needs acccess to an Overlay though, as it has various tool-tips and pop-up panels.
The only I know to do this is double-wrap Navigator, or MaterialApp, both of which smell bad. I would like to use Overlay directly, but lack any guidance on how to implement it.
Looking a the source of Overlay does not provide much help, and I'd prefer not to delve too deeply into MaterialApp's thousands of lines of src code.
[EDIT] Looking at the Navigator source a bit, it seems Overlay is directly coupled to PageRoutes, which is a real shame :'( It would be nice if there was a simple Overlay(child: ) we could just use.

There is declarative package for using overlays called flutter_portal which lets you show overlays as part of the widget tree.
PortalEntry(
visible: true,
portal: Material(
elevation: 8,
child: IntrinsicWidth(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
ListTile(title: Text('option 1')),
ListTile(title: Text('option 2')),
],
),
),
),
child: RaisedButton(...),
)
With this setup, you can toggle the overlay on and off with a single boolean ('visible') and you no longer have to make calls to Overlay.insert and Overlay.remove.

Related

I want to show details to the right side of screen after clicking an item on left, flutter

[I want to do something like this][1]
I want to show details to the right side of screen after clicking an item on left for my web app
[1]: https://i.stack.imgur.com/6P4Oq.png
body:child:Row[
TabBarView(
physics: NeverScrollableScrollPhysics(),
children: [
OngoingOrder(),//listview inside each view
CompletedOrder(),
CancelledOrder(),
]),
),
ShowOrder(
//rightside of page
)
]),
),
please post your existing code to understand
what logic you have performed.
If you are using any state management tool then please also mention that.
pseudocode: (flutter basic without any state management)
1)create a null Object for the right side
2)perform a null check to show the default demo message "Select An Order to see"
3)when user select an Order, populate the created object with the selected data and call setState((){})

Flutter Image Hovering Overlay Effect

I am working on a flutter web project and I want to the following overlay effect over my image that whenever the cursor hovers over the image, a few buttons should show up, and the opacity of the image gets reduced (or blurred out) while hovering.
I have tried InkWell and GestureDectector but nothing seems to work.
This is basically what I am trying to achieve : Preview.
Try using hovering package to achieve the hovering effect on flutter_web.
First, import the package:
import 'package:hovering/hovering.dart';
Add a GlobalKey within your StatelessWidget:
final _key = GlobalKey<ScaffoldState>();
And then, use the HoverWidget:
HoverWidget(
hoverChild: Container(
height: 200,
width: 200,
color: Colors.green,
child: Center(child: Text('Hover Me..')),
),
onHover: (event) {
_key.currentState.showSnackBar(SnackBar(
content: Text('Yaay! I am Hovered'),
));
},
child: Container(
height: 200,
width: 200,
color: Colors.red,
child: Center(child: Text('Hover Me..')),
),
)
Check the example use case here
Hi Raj this is pretty simple
You just need to use Listener Widget which detects onPointerHover and update you app's state
Here is the api link follow it
Listener in Flutter
If any difficulties comment down below
Okay, over time I have tried many ways and would like to share my insight in case somebody else is looking for the same solution too.
So, the basic way to achieve this is to use the Hovering package.
Another way would be to use MouseRegion.
You can use the onEnter and onExit property of MouseRegion to detect when did the cursor entered and left the region/container you are trying to add a hove effect to.
You can use that to switch between your different app states.
Or it has onHover property as well, that basically tells that if the cursor is currently hovering that region or not you can use that too.
Note: I tried the Listener widget as well, but either I didn't understood it well, or it was too complicated to work with. Anyways, I couldn't achieve what I wanted.

How to use drawer in flutter_platform_widgets: ^0.72.0

I'm trying to use a drawer with PlatformScaffold but it seems MaterialAppBarData does not have a named parameter for drawer. What is the workflow for adding a drawer using flutter platform widgets for the newer versions. For example in ^0.72.0. I can't seem to find any information on this in the docs or on forums.
Found a tutorial using the PlatformAppBar and saw that I should use the material argument in the scaffold other than the one in the PlatformAppBar. Closing this. Below is the workflow.
PlatformApp(
home: PlatformScaffold(
appBar: PlatformAppBar(
title: Text("Title"),
),
body: AppContent(),
material: (context, platform) => MaterialScaffoldData(drawer: Drawer()),
),
);

In Flutter, How does one create a 'how this app works' walk-through?

I want to launch a simple walk-through for our app. The user would log in for the first time (or select the 'tutorial' option in settings), and it would walk you through how to use the app.
To clarify, the app would launch a dialog/alertdialog and the background would go grey or become greyed out highlighting specific areas/buttons of the app to talk them through it. The dialog box would have a child of Text explaining how to use it.
After the user has clicked through the steps the tutorial would end but could be reactivated in settings.
Any help would be appreciated.
Thanks
There is a plugin called showcaseview and does pretty much what you want. You can get it here. For using it you need to wrap the page you want to show in a ShowCaseWidget
ShowCaseWidget(
builder: Builder(
builder : (context) () => Somewidget()
),
),
then for every part of the page you want to show a guide for it, wrap it in a ShowCase
Showcase(
key: _one,
title: 'Menu',
description: 'Click here to see menu options',
child: Icon(
Icons.menu,
color: Colors.black45,
),
),

Flutter Floating Action Button with Dynamic Status

Putting the finishing touches on my first Flutter mobile app.
Another important ToDo: My Floating Action Button appears in the Top App Bar for every page, but i would like its status to change (enabled / disabled) depending on the current page. Is this possible? if so, any tutorials, resources, reference material and / or code examples fit for a novice, would be much appreciated.
Thanks!
Cool, you can use Visibility:
floatingActionButton: Visibility(
child: FloatingActionButton(...),
visible: false, // set it to false
)
Alternatively, you could use NotificationListener (more elegante but sophisticated).
Please check this example from another publication
Edit: maybe controlling it directly in onPressed.
According to official docs:
"If the onPressed callback is null, then the button will be disabled and by default will resemble a flat button in the disabledColor."
FloatingActionButton(
onPressed: shouldButtonBeDisabled() ? null : () => whatToDoOnPressed,
child: Text('blablabla')
);