Flutter - make a container invisible - flutter

I'm trying to get a bar with an icon that "pops out" of it
bar with icon
my problem is that the container containing the objects is not invisible even if I use the command: 'color: Colors.trasparent'
Widget _bottomNavigator(String uid) {
return Container(
height: 50,
color: Colors.transparent,
child: Offstage(
offstage: !_isVisible,
child: Stack(children: [
Align(
alignment: Alignment.bottomCenter,
child: Container(
height: 20,
color: iconColor,
)),
Align(
alignment: Alignment.bottomCenter,
child: Container(
height: 50,
constraints: BoxConstraints.tightForFinite(),
color: Colors.transparent,
child: TextButton.icon(
icon: Icon(
Icons.add_photo_alternate,
color: gradientBeginColor,
size: 40,
),
label: Text(
'',
),
onPressed: () async {...},
),
),
),
]),
Does anyone know how I can make the container no longer visible?
Thank you

Use Visibility widget to control a widget's visibility.
Visibility(
visible: false, // not visible if set false
child: Container(
...
),
),

Try this, use with Opacity, with opacity: 0.0 then wrap the widget with opacity

Related

How to reposition a fixed widget in flutter

I'm building an AR app with Flutter and using the ar_flutter_plugin.
The position of the AR widget seems to be fixed to the top left and it doesn't move anywhere else. Whatever the other widgets in the tree, doesn't change anything. It's always at top left corner (see image).
It works with a dummy widget just fine (compare second img).
Child Ar widget
Widget build(BuildContext context) {
return SizedBox(
width: widget.width,
height: widget.height,
child: Column(
children: [
Expanded(
child: Column(children: [
Expanded(
child: ARView(
onARViewCreated: onARViewCreated,
planeDetectionConfig:
PlaneDetectionConfig.horizontalAndVertical,
),
),
Align(
alignment: Alignment(1, 1),
child: FloatingActionButton(onPressed: takePicture))
]),
),
],
));
}
Parent Widget
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Title'),
),
key: scaffoldKey,
backgroundColor: FlutterFlowTheme.of(context).primaryBackground,
body: SafeArea(
child: GestureDetector(
onTap: () => FocusScope.of(context).unfocus(),
child: Stack(
children: [
Container(
width: 350,
height: 350,
child: ObjectsOnPlanesWidget(
// child: custom_widgets.ArPlaceholder(
width: double.infinity,
height: double.infinity,
modelUrl: widget.modelUrl,
),
),
Align(
alignment: AlignmentDirectional(-0.23, -0.92),
child: Padding(
padding: EdgeInsetsDirectional.fromSTEB(8, 24, 8, 24),
child: Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Container(
width: 30,
height: 30,
decoration: BoxDecoration(
color:
FlutterFlowTheme.of(context).secondaryBackground,
borderRadius: BorderRadius.circular(12),
),
child: InkWell(
onTap: () async {
Navigator.pop(context);
},
child: Icon(
Icons.chevron_left,
color: Colors.black,
size: 24,
),
),
),
Text(
'Try On',
style: FlutterFlowTheme.of(context).bodyText1,
),
Container(
width: 30,
height: 30,
decoration: BoxDecoration(
color:
FlutterFlowTheme.of(context).secondaryBackground,
borderRadius: BorderRadius.circular(12),
),
child: Icon(
Icons.share_outlined,
color: Colors.black,
size: 24,
),
),
],
),
),
),
Align(
alignment: AlignmentDirectional(0, 0.95),
child: Container(
width: 50,
height: 50,
decoration: BoxDecoration(
color: FlutterFlowTheme.of(context).secondaryBackground,
borderRadius: BorderRadius.circular(12),
),
child: Icon(
Icons.photo_camera,
color: Colors.black,
size: 24,
),
),
),
],
),
),
),
);
}
I want to put the camera in the background and put other widgets (such as photo-taking-button) on top of it.
How do I reposition it into a container? At least under the App Bar?
Logically this should have worked, what i would suggest you try would be to first have a SafeArea widget.
SafeArea(
child: build(buildContext),
),
I had a similar issue in the past and using this solved it.
Also, there seems to be an open issue which seems related to this with the following possible solution :
With Flutter 2.10.5. it works without problems. This seems to be a Flutter 3 problem.
The way platforms views are rendered was changed in the 3.0 release.
probably same issue:
flutter/flutter#106246
explained here:
flutter/flutter#103630
I hope this will be fixed in new Flutter 3 releases soon.
And also this
I try the master channel Flutter v3.1.0-0.0.pre.1372 and the issue is fixed there.
Fixed will come to a stable channel soon with Flutter v3.1.0.
Also, I am not sure why are you using SizedBox as your parent widget.
Why not try a basic Container instead?
Good luck, Let me know if I can help with anything else

How to disable Inkwell image button in flutter

I would like to make the inkwell image button to be disabled. I can disable onTap event, but can't make gray like disabled button. I tried with adding this code
decoration: new BoxDecoration(color:Colors.grey.withOpacity(0.6)),
But it doesn't work as I want.
My code:
child: Container(
decoration:
new BoxDecoration(color: Colors.grey.withOpacity(0.6)),
child: Material(
//elevation: 4.0,
clipBehavior: Clip.none,
color: Colors.black,
child: Stack(
alignment: Alignment.center,
fit: StackFit.passthrough,
children: [
Ink.image(
image: AssetImage(ihaveheard_imagepath),
fit: BoxFit.cover,
width: MediaQuery.of(context).size.width / 4 * 3,
height: MediaQuery.of(context).size.width / 6,
child: InkWell(onTap: () {}),
),
Align(
alignment: Alignment.center,
child: Padding(
padding: EdgeInsets.all(8.0),
child: InkWell(
child: Text(
LocaleKeys.ihaveheard,
style: TextStyle(
fontSize:
MediaQuery.of(context).size.width / 30,
color: Colors.white),
).tr(),
onTap: () {
ihaveheard_imagepath =
"assets/images/greenbutton.png";
setState(() {});
},
),
),
)
],
),
),
),
child:
IgnorePointer(
ignoring: disableBtn, //true or false
child: Container(
foregroundDecoration: disableBtn
? BoxDecoration( //this can make disabled effect
color: Colors.grey,
backgroundBlendMode: BlendMode.lighten)
: null,
child: ...
You can use IgnorePointer as parent widget to prevent tab event.
IgnorePointer(
ignoring: disableBtn, //true, false
child: yourWidget()
You can pass null to decoration to show default based on tappable state
Container(
decoration: disableBtn? BoxDecoration(...): null,
.....
)

Flutter & AlertDialog : How to stretch a container so that it has the same width with the AlertDialog box?

I have been trying to make a button in AlertDialog box in Flutter. But I cannot find a way to stretch the button container. Please check my code and see the example picture below.
AlertDialog(
title: Center(child: Text("Picture")),
content: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Container(
width: width,
//height: height,
child: FadeInImage.memoryNetwork(
placeholder: kTransparentImage,
image: image.url,
),
),
SizedBox(
height: 10,
),
InkWell(
onTap: () {
Navigator.pop(context);
},
child: Container(
alignment: Alignment.center,
height: 50,
width: width,
color: primaryColor,
child: Text(
'Okay',
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold),
),
),
),
],
),
);
Please help me in this. I am looking forward to hearing your opinion. Thank you in advance.
The AlertDialog has a default content padding of 24 logical pixels to the right, left and bottom of the AlertDialog to separate the content from the other edges of the dialog..
To Make the Button fit the AlertDialog width, you will need to give the AlertDialog a padding of zero and apply paddings to others widgets except the Button.
I added an example using your code:
AlertDialog(
// change the default padding to zero
contentPadding: EdgeInsets.zero,
title: Center(child: Text("Picture")),
content: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
// wrap your container with a padding widget
Padding(
padding: const EdgeInsets.all(20.0), // give a preferred padding
child: Container(
width: width,
//height: height,
placeholder: kTransparentImage,
image: image.url,
),
),
),
SizedBox(
height: 10,
),
InkWell(
onTap: () {
Navigator.pop(context);
},
child: Container(
alignment: Alignment.center,
height: 50,
width: width,
color: primaryColor,
child: Text(
'Okay',
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold),
),
),
),
],
),
);

How to get pointer events in flutter from touch events that originated outside of the container?

I have a Draggable container, and another container that is supposed to get position of draggable content.
return SizedBox.expand(
child: Column(
children: <Widget>[
Draggable(
child: Container(
width: 50,
height: 56,
color: Colors.orange,
),
feedback: Container(
width: 50,
height: 56,
color: Colors.orange,
),
),
SizedBox.fromSize(
size: Size(500, 500),
child: Listener(
onPointerSignal: (PointerSignalEvent details) => print('get updates here'),
child: Container(
color: Colors.pink.withOpacity(0.2),
),
),
),
],
),
);
How to receive any movement on top of a container? onPanUpdate works only for pan originated in that container.
The same goes for onPointerMove from Listener.

How do deal with nested InkWell with Flutter?

Suppose you have a few nested InkResponse, if you tap on the inner one, all of the parent will actually trigger the splash effect even though they will loose in the tap arena for the right tapped widget. The effect will be something like this:
How to prevent such behavior? How to display the splash only for the tapped widget? In this example image it's being used a Container > Row (with InkReponse) > Icon (also with InkResponse). This will also happen if you use material buttons.
You might want to try IgnorePointer
I encourage you to use Stack widget because you can be able to put together multiple widgets. Here there is an example of a container with inner container and they are both clickable independently,
Stack(
children: [
InkWell(
onTap: (){},
child: Container(
width: 400,
height: 400,
color: Colors.green,
),
),
Positioned(
top: 30,
left: 20,
child: InkWell(
onTap: (){},
child: Container(
width: 100,
height: 100,
color: Colors.red,
),
))
],
)
This worked for me
Center(
child:Container(
width: 100,
height: 100,
child: Card(
child: InkWell(
splashColor: color3,
onTap: () {
},
child: Column(
children: [
SizedBox(
height: 10,
),
IconButton(
splashRadius: 7,
splashColor: Colors.pink,
onPressed: () {},
icon: SvgPicture.asset(
ImageConst.bellIcon,
width: 20,
height: 20,
color: Colors.black,
),
),
SizedBox(
height: 10,
),
Text("text"),
],
),
),
),
),
)
Try to wrap the icon into GestureDetector with the empty handler + Padding.