Flutter Inherited Custom AppBar disappear on TextField tap - flutter

I'm using a custom appBar and a bottomNavigationBar in a Scaffold, per below code:
return Scaffold(
appBar: LogoAppBar(),
drawer: topDrawer(),
body: _pageOptions[_selectedTab],
bottomNavigationBar: BottomNavigationBar(...)
When I navigate via the BottomNavigationBar the custom AppBar sticks at the top of the new screen, just like I want it to.
However, when I navigate and thereafter tap on a TextField on the new screen to enter some text, the inherited AppBar automatically disappear (when the keyboard shows up).
The full code for this screen is rather long and therefore rather impractical to post here, but it basically boils down to the following:
return Scaffold(
backgroundColor: Colors.white,
body: Column(
children: [
Container(
Column(
children: [
DropDownButton(...),
TextField(...), // with a textSearchController
],
Expanded(
child: ListViewBuilder(...) // showing a list based on the search
Is there any way to make the AppBar from the inherited class stick without putting a new appBar in the Scaffold in the class I navigated to?

Try removing Scaffold as you are already calling it once in the main screen.
return Column(
children: [
Container(
Column(
children: [
DropDownButton(...),
TextField(...), // with a textSearchController
],
Expanded(
child: ListViewBuilder(...)

Ujjwal's suggestion was incredibly helpful. I removed the Scaffold and unfortunately the problem persisted, but it made me realize that I had also wrapped the LogoAppBar() code in a Scaffold. Once I removed the Scaffold from the LogoAppBar() it all worked!

Related

How can i prevent scaffold from resize it's self when keyboard open EXCEPT a specific widget

i have broadcast screen ( in full screen) . i have textField on the same broadcast screen on the bottom so we have here Stack like following
Scaffold(
body: Stack(
alignment: Alignment.bottomCenter,
children:[
broadCastScreen()
TextField()
]
)
)
so my layout looks like this
now when i tap on the text field all scaffold resize its self because of the keyboard show up
the good point in this part that my textfieldalways smoothly move to be up the keyboard visible
but the bad part that my broadcast screen resize its self inappropriately for the user experience
so i decide to prevent that annoying party with set resizeToAvoidBottomInset to false
well now everything sound good , but i noticed that my keyboard covering my text field
so How Can i use resizeToAvoidBottomInsetto all my widgets except my textfield part ?
i tried to wrap my textfield with another scaffold with set resizeToAvoidBottomInset to true
and scaffold color to transparent so others widgets be visible and tis work as expected but i completely faced problems with GestureDetector pointers in my first scaffold and thats because my second scaffold stack it
another solution i tried programmatically to set my textfield bottom padding to be the same of my keyboard height using EdgeInsets.fromWindowPadding(WidgetsBinding.instance.window.viewInsets,WidgetsBinding.instance.window.devicePixelRatio);
but that's not perfect way because there is some delay with height keyboard value like 900 millisecond to get the keyboard height Furthermore it i tested it on several difference phones and i got null height with some devices It does not guarantee the measurement of all phones
any other perfect way friend ?
Scaffold(
resizeToAvoidBottomInset: false,
body: Stack(
fit: StackFit.expand,
children: [
SingleChildScrollView(
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Content()
]
Positioned(
bottom: 0,
child:
child: TextFormField(
decoration: InputDecoration(filled: true, fillColor:
Colors.red
),
),
)
],
),
);
Simply Wrap your content in SingleChildScrollView and wrap your TextField in Positioned widget set bottom parameter of Positioned to Zero, add
fit: StackFit.expand,
Note: Don't forget to add above code to your Stack Widget
Let's try to do something like this
Scaffold(
body: Stack(
alignment: Alignment.bottomCenter,
children:[
Positioned.fill(child:
broadCastScreen()),
Position(
bottom:0,
child: TextField())
]
)
)

Static Widgets with a PageView

Is there a way to make a few widgets static upon a PageView change?
I know I can make one widget static by wrapping the Scaffold within a Container, and have that Container have something like a decoration, but I don't know how to add more widgets that do not change when a page changes.
I have a few widgets that change when the page view changes, but then I want to have, say a Button below those widgets that stay still, but
if I put the same Button in every widget, it will swipe through and show two buttons when I change the page momentarily.
I just figured it out, I thought the PageView can only be assigned to the body property of a Scaffold, but wrapping it within a Column like this works. So just add the static widgets within the Column!
return Container(
decoration: BoxDecoration(), // For background.
),
child: Scaffold(
backgroundColor: Colors.transparent,
body: Column(
children: [
Flexible(child: pageView),
// Static Widgets here!
],
),
),
);

Display permanent Widget under AppBar in Flutter

I would like to implement small audio player controlls directly under the AppBar if an audio is playing. This can be seen in many apps like Telegram.
Example:
How to realize that in Flutter? The Player has to be displayed on all Screens! Like a permanent, sticky one widget.
You can use toolbarHeight on AppBar to get extra spaces, and place Column(any widget based on your need) on title.
appBar: AppBar(
toolbarHeight: 100,
title: Column(
children: [
Text("title"),
Row(
children: [Icon(Icons.ac_unit)],
)
],
),
),

Flutter - How to create a TabBar View with top bottom as the same levels as the tab

I have a TabBar that has form items in the view. that currently look like this.
as you can see the Cancel and Continue buttons are at the top. I used a Scalfold widget with an AppBar for those.
The problem is I want the continued bottom to align with the tabs. like this.
How can I get that desired result?
appBar: AppBar(
automaticallyImplyLeading: false,
title: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.end,
children: <Widget>[
YourFirstButton,
YourTabBar(),
YourSecondButton(),
],
),
),

FLUTTER: How to get widgets to flow on top while the keyboard appears?

I want to get widgets to flow on top while the keyboard appears, and here's the widget I have:
Scaffold(
resizeToAvoidBottomInset: false,
body: Stack(
children: [
Image.network('url'),
Column(
children: [
Text('Some text'),
SizedBox(height: 11),
Text('Some text'),
]
)
]
)
)
The result I want is to let the background image stays the same, so it stays under the keyboard, but while letting the column flow on top of the keyboard, so it will change its location as the keyboard showing and dismissing.
At rest:
After keyboard showed:
This is called a custom keyboard.
The plugin keyboard_actions can be customized for your needs: https://pub.dev/packages/keyboard_actions
Working way:
Surprisingly, by just wrapping the Column with a Padding widget and give it a padding of EdgeInsets.only(MediaQuery.of(context).viewInsets.bottom),
and also adding
mainAxisAlignment: MainAxisAlignment.end
to the Column did the trick! Easy solution~