Unwanted action button in flutter appbar - android-studio

I'm building a screen which has a bottom navigation bar, where I placed an burger action button and a floating button, and an appbar where I want to place my app logo.
Even though i didn't give any action to the appbar, the burger icon still appears at the left of the title.
I would like to only have the title in the appbar.
This is my code:
appBar: new AppBar(
title: new Image.asset('assets/logo/logo-home.png', fit: BoxFit.fitHeight),
actions: null,
backgroundColor: Colors.black,
elevation: 0.0,
),
key: _scaffoldKey,
floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
floatingActionButton: FloatingActionButton(
child: ImageIcon(new AssetImage("assets/icons/star.png"), color: Colors.black),
backgroundColor: Colors.white,
onPressed: scan,
),
bottomNavigationBar: BottomAppBar(
color: Color.black,
child: new Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
IconButton(icon: Icon(Icons.menu), color: Colors.white, onPressed: ()=> _scaffoldKey.currentState.openDrawer(),),
],
),
),

If the scaffold has a drawer and the appbar doesn't contain 'leading' property (or with null value), Appbar will append a menu icon in its actions.
It's mentioned in the documents:
If the leading widget is omitted, but the AppBar is in a Scaffold with a Drawer, then a button will be inserted to open the drawer. Otherwise, if the nearest Navigator has any previous routes, a BackButton is inserted instead. This behavior can be turned off by setting the automaticallyImplyLeading to false. In that case a null leading widget will result in the middle/title widget stretching to start.
The solution is easy, just replace title property with leading in your appbar
appBar: new AppBar(
leading: new Image.asset('assets/logo/logo-home.png', fit: BoxFit.fitHeight),
actions: null,
backgroundColor: Colors.black,
elevation: 0.0,
),

Related

remove padding of switch button in flutter

default switch button in flutter have padding, I want reduce padding, I tried everything I know but I still can't do it
default
I want
I made it
Switch(
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
value: !state,
activeTrackColor: PrimaryColor.value,
onChanged: (value)=> context.read<SettingRo>().change(value),
),
You can use Material Button or Inkwell or Button theme for this.
Solution 1:MaterialButton/RawMaterialButton:
MaterialButton(
onPressed: () {},
color: Colors.red,
minWidth: 0,
height: 0,
padding: EdgeInsets.zero,
child: Text('Material Button'),
)
Solution 2 Inkwell:
InkWell(
child: Center(child: Container(child: Text("Inkwell"))),
onTap: () => onPressed()
);
Solution 3: wrap the button in a ButtonTheme.
give maxWith and height (set to zero to wrap the child) and then pass your button as the child.
ButtonTheme(
padding: EdgeInsets.symmetric(vertical: 2.0, horizontal: 6.0), //adds padding inside the button
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, //limits the touch area to the button area
minWidth: 0, //wraps child's width
height: 0, //wraps child's height
child: RaisedButton(onPressed: (){}, child: Text('ButtonTheme')), //your original button
);

[FLUTTER]: Cut text depending of height of ListTile

I have the following widget. The problem is I need to cut my subtitle string depending on the height and width of the ListTile. Now, height of the ListTile depends on length of substring I have. Longer is my substring, longer is the height of the ListTile. It looks awkward. Putting ListTile inside Container widget is good, but the substring overlaps the next ListTile content. it looks terrible too. Another solution was using FittedBox, I thought. But, I need the fixed size of each ListTile, without changing the fontSize. That's why the FixedBox doesn't fit me:) It changes the fontSize. I need to cut my string when it reaches the end of the ListTile. How can I solve this?
InkWell(
onTap: () {
Navigator.of(context).push(
MaterialPageRoute(
builder: (_) => ProductScreen(product),
),
);
},
child: Column(
children: [
Container(
padding: const EdgeInsets.symmetric(
vertical: 8.0,
horizontal: 4.0,
),
child: ListTile(
title: Text(
product.title.toUpperCase(),
style: Styles.listTitleStyle,
),
subtitle: Text(
product.description,
style: Styles.listBodyStyle,
),
),
),
const Divider(height: 1.0),
],
For your text widget add something like this,
subtitle: Text(
maxLines: 2, //customize your number of lines
overflow: TextOverflow.ellipsis, //add this to set (...) at the end of sentence
product.description,
style: Styles.listBodyStyle,
),

Flutter: Fixed bottom button, central dynamic TextField that moves with keyboard popup

Many variations of this question exist with solutions. I have been unable to find an adequate solution. Is it possible to fix a button at the bottom of the screen which the keyboard is allowed to overlay, but also moves the other text fields up?
I've attached a screenshot example
My current solution works, but the space between the textfield and the post button is a fixed SizedBox height. This shifts the post button around on different screen heights, which is hack.
Is there a way to do something similar to how an Expanded widget fills the empty space, but within a ListView? Expanded throws an error if parent is a ListView, and a parent of Flex would squeeze all the elements when the keyboard comes up.
Widget Layout: (super simplified)
return ListView(
children: <Widget>[
Container(//The photo boxes at top
height: fixed,
),
ListTile(
leading: CircleAvatar(),
title: Container(child: TextField(),),
),
SizedBox(
height: screenHeight * 0.5 - 225
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Container(
child: RaisedButton(
onPressed: doThing
child: Text('POST'),
),
),
],
),
],
);

the argument for the named parameter 'child' was already specified

I can't put icon and text at the same time for floatbuttom?
The error in the title.
return new Scaffold(
appBar: new AppBar(
title: new Text('Hello'),
backgroundColor: Colors.blue,
),
body: new Container(
padding: new EdgeInsets.all(22.0),
child: new Column(
children: <Widget>[
new Text("it's working, $name"),
new FlatButton(onPressed:()=> onClick('test'), child: new Icon(Icons.accessibility),child : new Text('data'))
],
)));
}
}
Your problem is inside the FlatButton widget, you are using child attribute two times.
You can put text and icon, this way:
FlatButton.icon(
icon: Icon(Icons.accessibility),
label: Text('data'),
onPressed: () {
//Code to execute when Button is clicked
},
)
I believe wrapping both children in either a row or column would solve your problem.
FlatButton can only take one widget as the child parameter.
FlatButton(
onPressed:()=> onClick('test')},
child: Row(
children: <Widget>[
new Icon(Icons.accessibility),
new Text('data'),
],
),
),

Flutter Align widget rect does not detect the onTap gesture

I have a couple of image buttons laid out as follows :
The layout code is :
new Container(
height: 48.0,
child: new Row(
children: <Widget>[
new GestureDetector(
onTap: cancelTurn,
child: new Align(child: new Image.asset("assets/cancel_button.png"), widthFactor: 1.5),
),
new Expanded(child: new Container()),
new GestureDetector(
onTap: confirmTurn,
child: new Align(child: new Image.asset("assets/confirm_button.png"), widthFactor: 1.5),
),
],
),
)
I am using Align widget to hopefully increase the clickable area of the GestureDetector. However, my clicks only work when I click inside the Image widget rect. If you notice, the bounds/rects for Align and Image are different. Align is extended beyond the Image child by using the widthFactor property (set to 1.5)
Any ideas on why the Align widget might not be detecting the tap gesture in its bounds.
Try passing a hitTestBehavior of HitTestBehavior.opaque to the GestureDetector.
Other tips:
Instead of Align, consider a Padding.
Consider using an IconButton with Icons.close and Icons.check instead of embedding a custom png. You could wrap it in a Material to draw the black circle and it will even clip the ink splash for you automatically.
To get the desired effect, you could replace the GestureDetector elements for InkWell. This will give a feedback to the user (due to the Ink animation) and will be activated when the whole area is pressed.
To do that, your container should look like this:
new Container(
height: 48.0,
child: new Row(
children: <Widget>[
new InkWell(
onTap: cancelTurn,
child: new Align(child: new Image.asset("assets/cancel_button.png"), widthFactor: 1.5),
),
new Expanded(child: new Container()),
new InkWell(
onTap: confirmTurn,
child: new Align(child: new Image.asset("assets/confirm_button.png"), widthFactor: 1.5),
),
],
),
)

Resources