I try to navigate page through clicking an image - flutter

I am new to flutter. Im trying to navigate page through clicking an image but it keep messing around.
below show before and after i make changes

you can use inkwell
inkwell has so many property like color etc.....
it's a rectangular area of a Material that responds to touch.
InkWell(
splashColor: Colors.transparent,
highlightColor: Colors.transparent,
focusColor: Colors.transparent,
hoverColor: Colors.transparent,
onTap: () {
Navigator.pushReplacementNamed(context, "/you'r destination page");
},
child: Image.asset(" you'r image path ")
)
it provides tapping section , using onTap you can tap what ever you want
OR
you can use GestureDetector
GestureDetector(
onTap: () {
Navigator.pushReplacementNamed(context, "/you'r destination page");
},
child: Image.asset(" you'r image path ")
)
it also recognize gestures that correspond to its non-null callbacks.

You need to wrap your Image with the gesture detector, right now they are in the same column but not together ie
GestureDetector(
onTap: DoNavigationHere,
Child: Image.asset
)

Related

Flutter: OnTap and OnPressed Same Inkwell

Currently I have an Inkwell and an onTap that does x when tapped on, which is what I want. On top of that, I would like it to do y instead of x when a user presses and holds that button for a second or two.
I was wondering what functionality I can use in order to implement this, thanks in advance for any help!
InkWell(
splashColor: Colors.black,
highlightColor: Colors.blue,
onTap: pageX,
child: Container()
Inkwell supports onTap and onLongPress.
Example:
child: InkWell(
onTap: (){print("onTap!")},
onLongPress:(){print("onLongPress!")},
}

Flutter Box with Navigation on pressed

I am writing a flutter app where i want create boxes like grid and each can be click to navigate on different screen.
Similar to below example
I am a beginner, how can i achieve this. Can you please share some pointer. I went through Documentation but if you can help me with what to search for I can read. or if you can share some exmaple.
You can wrap each box widget with an inkwell and add an onTap to it where you can call the navigation ie:
InkWell(
onTap: () => Navigator.of(context).pop(false),
child: Container(
height: 25.0,
width: 80.0,
child: Text('CANCEL'),
),
InkWell
Gesture Detector

Floating action button to be ontop of drawer after opening

I have a floating action button which opens the drawer. I want it to stay in its place when it opens the drawer and just change the icon to close icon with animation. I couldn't find a good solution to do this.
I tried wrapping inside my drawer with scaffold and adding a floating action button there and using hero widgets so make it look like it stays in its place but didn't help at all.
Is there anyway to achieve this?
U can use foldable Sidebar package to achieve this functionalities that's package is available on :
https://pub.dev/packages/foldable_sidebar
And check this piece of code how to use this :
child: Scaffold(
body: FoldableSidebarBuilder(
drawerBackgroundColor: Colors.deepOrange,
drawer: CustomDrawer(closeDrawer: (){
setState(() {
drawerStatus = FDBStatus.FDB_CLOSE; // For Closing the Sidebar
});
},),
screenContents: FirstScreen(), // Your Screen Widget
status: drawerStatus,
),
floatingActionButton: FloatingActionButton(
backgroundColor: Colors.deepOrange,
child: Icon(Icons.menu,color: Colors.white,),
onPressed: () {
// To Open/Close Sidebar
setState(() {
drawerStatus = drawerStatus == FDBStatus.FDB_OPEN ? FDBStatus.FDB_CLOSE : FDBStatus.FDB_OPEN;
});
}),
),
),

Long pressed menu in flutter

how to make this top bar menu when we do a long press on a card or container.
you can wrap your card widget with InkWell or GestureDetector both have longPress, then you pass a call back to your view to show the menu.
Color _colorFilterTile = Colors.transparent;
InkWell(
onLongPress: (){
//call function
setState(() {
_colorFilterTile= Colors.green.withOpacity(0.5);
});
},
child: Container(
color: _colorFilterTile,
child: ...,
),
)

ListTile covers button animation

Just noticed that ListTile cover button animation when wrapped inside a container with background color set to anything but transparent. Wrapping ListTile in a container with set color is the only way I know to change background color of ListTile. Is there any other way to change background color of the ListTile without loosing button animation?
Container(
color: Colors.green,
child: ListTile(
title: Text('Test'),
trailing: IconButton(
icon: Icon(Icons.add),
onPressed: () {},
),
),
)
OUTPUT
This is because of the way InkWell works (Some buttons, like the IconButton, use InkWell or InkResponse as their parent). You can read about it more on this github issue page.
In order to make that ripple effect to display on top of the decorated Container (the green one in your code) - it needs a Material widget above the Container in the widget display tree.
So you should edit the code and add a Material widget with transparency in your Container, so the widget display tree will look like Container -> Material -> Ink.
Container(
color: Colors.green,
child: Material(
type: MaterialType.transparency,
child: ListTile(
title: Text('Test'),
trailing: IconButton(
icon: Icon(Icons.add),
onPressed: () {},
),
),
),
),