How to change positions of icons in AppBar in flutter? - flutter

I am trying to reposition my "compass" icon near the "search" icon from the App bar. Everytime i try to make a change in the container with higher value 55 for example "padding: const EdgeInsets.symmetric(horizontal: 50)," i get error stack over flow. Also when i try to change the logo(png) the allingment, nothing happens. Help please!
Image
#override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
flexibleSpace: Container(
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topLeft,
end: Alignment.bottomRight,
colors: <Color>[Colors.pink[400], Colors.blue[400]]
),
),
),
title: Row(
children: [
Container(
alignment: Alignment.center,
height: 40,
child: SizedBox(
child: Image.asset(
'assets/images/logox.png',
)
),
),
Container(
padding: const EdgeInsets.symmetric(horizontal: 50),
child: SizedBox(
child: Icon(
Icons.explore_rounded,
))),
// Container(child: Icon(Icons.explore_rounded)),
],
),
actions: [
GestureDetector(
onTap: () {
// authMethods.signOut();
Navigator.pushReplacement(
context,
MaterialPageRoute(
builder: (context) => SearchScreen(),
));
},
child: Container(
padding: EdgeInsets.symmetric(horizontal: 16),
child: Icon(Icons.search)),
)
],
),
drawer: MainDrawer(),
//body: Body(),
bottomNavigationBar: GradientBottomNavigationBar(
fixedColor: Colors.white,
backgroundColorStart: Colors.pink[400],
backgroundColorEnd: Colors.blue[400],
items: <BottomNavigationBarItem>[
BottomNavigationBarItem(
icon: Icon(Icons.home), title: Text('Home')),
BottomNavigationBarItem(
icon: Icon(Icons.wallet_membership), title: Text('QUA')),
BottomNavigationBarItem(
icon: Icon(Icons.help), title: Text('Help')),
],
currentIndex: _selectedIndex,
onTap: _onItemTapped,
),
floatingActionButton: FloatingActionButton(
backgroundColor: Colors.pink,
elevation: 50,
hoverColor: Colors.red,
autofocus: true,
onPressed: () {
print('hi');
},
child: Icon(
Icons.comment,
),
tooltip: 'Pick Image',
),
floatingActionButtonLocation: FloatingActionButtonLocation.endFloat);
}
void _onItemTapped(int index) {
setState(() {
_selectedIndex = index;
});
}
}

There is actions property in AppBar widget which is mainly used to put icons in AppBar. And in your case centerTitle is used to align your image to center
Output
Full code
class MyHomePage extends StatefulWidget {
final Function onItemPressed;
MyHomePage({
Key key,
this.onItemPressed,
}) : super(key: key);
#override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
#override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
flexibleSpace: Container(
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topLeft,
end: Alignment.bottomRight,
colors: <Color>[Colors.pink[400], Colors.blue[400]]),
),
),
centerTitle: true,
title: Container(
alignment: Alignment.center,
height: 40,
child: SizedBox(
child: Image.asset(
'assets/logo.png',
)),
),
actions: [
IconButton(
onPressed: () {},
icon: Icon(Icons.explore_rounded),
),
IconButton(
onPressed: () {},
icon: Icon(Icons.search),
)
],
),
);
}
}

Material appbar has an actions property, you can use that to put search and compass icon together. In order to achieve the same remove
Container(
padding: const EdgeInsets.symmetric(horizontal: 50),
child: SizedBox(
child: Icon(
Icons.explore_rounded,
))),
from its current position and add it into the actions property just above the search button.

Related

Padding and text on Icon Button - flutter

I am creating a menu with IconButton, but I want to decrease the space between the buttons.
Currently It looks like this:
But I want this:
Also, I would like to know how to put the text below each button, just like the image. I have tried to use other types of button but didn't worked.
This is Menu.dart code:
import 'package:flutter/material.dart';
void main() => runApp(Menu());
class Menu extends StatefulWidget {
const Menu({super.key});
#override
State<Menu> createState() => _MenuState();
}
class _MenuState extends State<Menu> {
#override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Color.fromARGB(255, 160, 244, 230),
elevation: 0,
),
body: Container(
padding: EdgeInsets.symmetric(horizontal: 90),
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [Color.fromARGB(255, 160, 244, 230), Color.fromARGB(255, 92, 172, 178)]
)
),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
IconButton(
icon: Image.asset("assets/entrada.png"),
iconSize: 190,
onPressed: () {},
),
IconButton(
icon: Image.asset("assets/saida.png"),
iconSize: 190,
onPressed: () {},
),
IconButton(
icon: Image.asset("assets/categorias.png"),
iconSize: 190,
onPressed: () {},
)
]
)
)
);
}
}
First you need to build your custom button like this:
Widget customButton(
{required String image,
required String title,
required Function() onTap,
required Size size}) {
return GestureDetector(
onTap: onTap,
child: Container(
color: Colors.transparent,
child: Column(
children: [
Container(
height: size.height,
width: size.width,
constraints: BoxConstraints(maxHeight: 130, maxWidth: 130),
child: Image.asset(image),
),
Text(title),
],
),
),
);
}
then use it like this:
Padding(
padding: const EdgeInsets.symmetric(vertical: 32.0),
child: LayoutBuilder(builder: (context, constraints) {
var buttonMargin = 32.0;
var buttonSize = constraints.maxHeight / 3 - buttonMargin;
return Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
customButton(
image: "assets/entrada.png",
title: 'some text',
onTap: () {},
size: Size(buttonSize, buttonSize),
),
Padding(
padding: EdgeInsets.symmetric(vertical: buttonMargin),
child: customButton(
image: "assets/saida.png",
title: 'some text 2',
onTap: () {},
size: Size(buttonSize, buttonSize),
),
),
customButton(
image: "assets/categorias.png",
title: 'some text 3',
onTap: () {},
size: Size(buttonSize, buttonSize),
),
],
);
}),
)

Custom widget of app bar with a humburger menu as ElevatedButton with a Drawer doesn't work OnPressed

I am facing a problem with my custom app bar. I would like it to have a drawer but it doesn't work. I just don't know how to make it being able to open.
It is a custom app bar widget named Pasek (which stands for top bar in my language).
It has a logo picture which on click moves you to the first page of the app.
Next to it there is humburger menu with a drawer but I do not know why it doesn't work. I click on it and nothing happens.
Any ideas?
class Pasek extends StatelessWidget with PreferredSizeWidget {
#override
Size get preferredSize => Size.fromHeight(50.0);
const Pasek({
Key? key,
}) : super(key: key);
#override
Widget build(BuildContext context) {
return AppBar(
actions: <Widget>[
Padding(
padding: EdgeInsets.only(right: 35.0),
child: ElevatedButton(
child: Icon(Icons.menu, color: Colors.white),
onPressed: () {
Scaffold(
endDrawer: Drawer(
child: ListView(
padding: EdgeInsets.zero,
children: const <Widget>[
DrawerHeader(
decoration: BoxDecoration(
color: Colors.black,
),
child: Text(
'Menu',
style: TextStyle(
color: Colors.pink,
fontSize: 24,
),
),
),
ListTile(
leading: Icon(Icons.message),
title: Text('Messages'),
),
ListTile(
leading: Icon(Icons.account_circle),
title: Text('Profile'),
),
ListTile(
leading: Icon(Icons.settings),
title: Text('Settings'),
),
],
),
),
);
},
)),
],
backgroundColor: Colors.black,
title: GestureDetector(
onTap: () {
Navigator.of(context).push(
MaterialPageRoute(
builder: (_) => FirstPage(),
),
);
}, // Image tapped
child: Image.asset(
'images/logo.png',
fit: BoxFit.scaleDown,
height: 30,
width: 200,
),
));
}
}

Navigate to a tab screen from a bottom navigation bar screen on button click

I have a button that should redirect me to the second tab on my tab bar upon clicking it.
The thing is that the navigation in my app is a little bit complicated , i have a main menu which is my Navigation bar , and i navigate between the screens in my app , mainly through it , each screen posses an index , for instance , index (0) the first screen, is composed of a tab bar that is itself divided in two tabs. I need to be able to click on a button in screen index (2) and then be redirected to screen index (0) tab 2. The app's current behavior is to redirect me to tab 1, which is quite normal , since i've instructed my app to redirect me to my main nav bar page and gave it the index (0) , so it's going to logically take me to the first tab .
here's the function that i am calling in the onclick action :
void redirectLinkNotif(BuildContext context) {
if (localNotification!.topic == "QRQC_CREATION") {
Navigator.pushReplacement(
context,
MaterialPageRoute(
builder: (context) {
return BottomNavBar(
index: 0,
);
},
),
);
} else {
Navigator.pushReplacement(
context,
MaterialPageRoute(
builder: (context) {
return BottomNavBar(
index: 4,
);
},
),
);
}
}
Here's my tab bar page :
class MainQrqcScreenWithTab extends StatefulWidget {
const MainQrqcScreenWithTab({Key? key}) : super(key: key);
#override
State<StatefulWidget> createState() => MainQrqcScreenWithTabState();
}
class MainQrqcScreenWithTabState extends State<MainQrqcScreenWithTab> {
#override
Widget build(BuildContext context) {
return DefaultTabController(
length: 2,
child: SafeArea(
child: Scaffold(
resizeToAvoidBottomInset: false,
backgroundColor: Colors.white,
body: Container(
decoration: const BoxDecoration(
image: DecorationImage(
image: AssetImage("assets/images/deepnBg.png"),
fit: BoxFit.cover,
)),
child: Column(
children: <Widget>[
Row(
children: [
Expanded(
child: TabBar(
labelStyle: TextStyle(
fontSize: 12.0, fontWeight: FontWeight.bold),
labelColor: Colors.black,
unselectedLabelColor: Colors.grey,
tabs: <Widget>[
Tab(
text: 'Mes QRQC',
),
Tab(
text: 'Liste des QRQC',
)
],
),
),
],
),
Expanded(
child: TabBarView(children: [MyQrqc(), AllQrqcListView()]),
),
],
),
),
),
),
);
}
}
And this is my bottom nav bar (main page) :
class BottomNavBar extends StatefulWidget {
#override
State<BottomNavBar> createState() => _BottomNavBarState();
int index;
BottomNavBar({required this.index});
}
class _BottomNavBarState extends State<BottomNavBar> {
bool isClick = false;
int changeActivePage(int index) {
setState(() {
//activeIndex = index;
widget.index = index;
});
return index;
}
List<Widget> pages = [];
final tabs = [
"Mes Qrqc",
"Profil",
"Ajout Qrqc",
"Notifications",
"Liste des actions",
"Liste des actions",
];
#override
void initState() {
pages = const [
MainQrqcScreenWithTab(),
UserProfile(),
AddQrqcScreen(),
ListNotifications(),
ToDoScreen(),
];
super.initState();
}
#override
Widget build(BuildContext context) {
SizeConfig.init(context);
const kPrimaryColor = Color(0xFF1C5E7D);
const kPrimaryLightColor = Color(0xFF1393CE);
return SafeArea(
child: Scaffold(
resizeToAvoidBottomInset: false,
appBar: PreferredSize(
preferredSize: Size.fromHeight(SizeConfig.screenHeight * 0.075),
child: CustomBaseAppBar(
title: tabs[widget.index],
callback: () {
setState(() {
changeActivePage(3);
});
Future.delayed(Duration(seconds: 1)).then(
(value) => LocalNotificationsViewModel().readNotifications());
},
),
),
bottomNavigationBar: widget.index == 2
? Visibility(
visible: false,
child: BottomAppBar(
clipBehavior:
Clip.antiAlias, //bottom navigation bar on scaffold
color: Colors.transparent,
shape: CircularNotchedRectangle(), //shape of notch
notchMargin: 6.0,
child: SizedBox(
width: MediaQuery.of(context).size.width,
child: Container(
decoration: const BoxDecoration(
gradient: LinearGradient(
colors: [kPrimaryColor, kPrimaryLightColor],
begin: Alignment.topLeft,
end: Alignment.topRight,
stops: [0.1, 0.8],
tileMode: TileMode.clamp,
),
),
),
),
),
)
: BottomAppBar(
clipBehavior:
Clip.antiAlias, //bottom navigation bar on scaffold
color: Colors.transparent,
shape: CircularNotchedRectangle(), //shape of notch
notchMargin: 6.0,
child: SizedBox(
width: MediaQuery.of(context).size.width,
child: Container(
decoration: const BoxDecoration(
gradient: LinearGradient(
colors: [kPrimaryColor, kPrimaryLightColor],
begin: Alignment.topLeft,
end: Alignment.topRight,
stops: [0.1, 0.8],
tileMode: TileMode.clamp,
),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
IconButton(
onPressed: () => changeActivePage(0),
color: Colors.white,
icon: Icon(Icons.home)),
Padding(
padding: const EdgeInsets.only(right: 38.0),
child: IconButton(
onPressed: () => changeActivePage(4),
color: Colors.white,
icon: Icon(Icons.view_list_outlined)),
),
Padding(
padding: const EdgeInsets.only(left: 38.0),
child: IconButton(
onPressed: () => changeActivePage(3),
color: Colors.white,
icon: Icon(Icons.notifications)),
),
IconButton(
onPressed: () => changeActivePage(1),
color: Colors.white,
icon: Icon(Icons.person)),
],
),
),
),
),
body: pages[widget.index],
floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
floatingActionButton: widget.index == 2
? Visibility(
visible: false,
child: FloatingActionButton(
backgroundColor: kPrimaryLightColor,
onPressed: () async {
setState(() {});
},
child: const Text("OK"),
),
)
: FloatingActionButton(
backgroundColor: kPrimaryLightColor,
onPressed: () {
changeActivePage(2);
},
child: const Icon(Icons.add),
),
),
);
}
}
i want to be able to be redirected to index 0 , in my nav bar , tab 2 , and i have no clue how to do so if you'd be willing to help i'd be grateful , happy coding .
We can navigate to the different pages using passing the initial index to pageContoller.
initialize the pageController
var _pageController;
var _selectedIndex;
#override
void initState() {
_selectedIndex = widget.selectedIndex;
_pageController = PageController(initialPage: _selectedIndex);
print(_selectedIndex);
if (_pageController.hasClients) {
_pageController.jumpTo(double.parse(_selectedIndex.toString()));
onPageChange(_selectedIndex);
_onSelected(_selectedIndex);
}
super.initState();
}

how to open side menu bar in flutter?

I am new to flutter and I have created a menu button to open a side menu but however, I need some help to make it happen.
Can anyone help me implemented or guide me in my code of how to make it work. please and thank you very much!
Here is my code:
Widget _icon(IconData icon, {Color color = LightColor.iconColor}) {
return Container(
padding: EdgeInsets.all(10),
decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(13)),
color: Theme.of(context).backgroundColor,
boxShadow: AppTheme.shadow),
child: Icon(
icon,
color: color,
),
);
}
Main:
class _MainPageState extends State<MainPage> {
bool isHomePageSelected = true;
Widget _appBar() {
return Container(
padding: AppTheme.padding,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
RotatedBox(
quarterTurns: 4,
child: _icon(Icons.menu, color: Colors.black54),
),
ClipRRect(
borderRadius: BorderRadius.all(Radius.circular(13)),
child: Container(
decoration: BoxDecoration(
color: Theme.of(context).backgroundColor,
boxShadow: <BoxShadow>[
BoxShadow(
color: Color(0xfff8f8f8),
blurRadius: 10,
spreadRadius: 10),
],
),
),
)
],
),
);
}
You can copy paste run full code below
You can use GlobalKey() and call _key.currentState.openDrawer();
code snippet
GlobalKey<ScaffoldState> _key = GlobalKey();
...
child: InkWell(
onTap: () {
_key.currentState.openDrawer();
},
working demo
full code
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
#override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
#override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
int _counter = 0;
GlobalKey<ScaffoldState> _key = GlobalKey();
void _incrementCounter() {
setState(() {
_counter++;
});
}
Widget _icon(IconData icon, {Color color = Colors.blue}) {
return Container(
padding: EdgeInsets.all(10),
decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(13)),
color: Theme.of(context).backgroundColor,
//boxShadow: AppTheme.shadow
),
child: InkWell(
onTap: () {
_key.currentState.openDrawer();
},
child: Icon(
icon,
color: color,
),
),
);
}
bool isHomePageSelected = true;
Widget _appBar() {
return Container(
//padding: AppTheme.padding,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
RotatedBox(
quarterTurns: 4,
child: _icon(Icons.menu, color: Colors.black54),
),
ClipRRect(
borderRadius: BorderRadius.all(Radius.circular(13)),
child: Container(
decoration: BoxDecoration(
color: Theme.of(context).backgroundColor,
boxShadow: <BoxShadow>[
BoxShadow(
color: Color(0xfff8f8f8),
blurRadius: 10,
spreadRadius: 10),
],
),
),
)
],
),
);
}
#override
Widget build(BuildContext context) {
return Scaffold(
key: _key,
appBar: AppBar(leading: _appBar()),
drawer: Drawer(
// Add a ListView to the drawer. This ensures the user can scroll
// through the options in the drawer if there isn't enough vertical
// space to fit everything.
child: ListView(
// Important: Remove any padding from the ListView.
padding: EdgeInsets.zero,
children: <Widget>[
DrawerHeader(
child: Text('Drawer Header'),
decoration: BoxDecoration(
color: Colors.blue,
),
),
ListTile(
title: Text('Item 1'),
onTap: () {
// Update the state of the app
// ...
// Then close the drawer
Navigator.pop(context);
},
),
ListTile(
title: Text('Item 2'),
onTap: () {
// Update the state of the app
// ...
// Then close the drawer
Navigator.pop(context);
},
),
],
),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
'You have pushed the button this many times:',
),
Text(
'$_counter',
style: Theme.of(context).textTheme.headline4,
),
],
),
),
floatingActionButton: FloatingActionButton(
onPressed: _incrementCounter,
tooltip: 'Increment',
child: Icon(Icons.add),
),
);
}
}
Use this code:
Scaffold.of(context).openDrawer();
Reference: https://api.flutter.dev/flutter/material/ScaffoldState/openDrawer.html
The recommended way is to call Scaffold.of(context).openDrawer();
Sample Code:
drawer: const NavBar(), // Your nav bar here
appBar: AppBar(
title: "Home".appBarText(),
leading: Builder(builder: (context) {
return IconButton(
icon: const Icon(Icons.menu),
onPressed: () {
Scaffold.of(context).openDrawer();
},
);

How to fix "A RenderFlex overflowed by Infinity pixels on the bottom." error on flutter?

I brought some code from the net for the different appbar design and apply it to my code. And I wanted to use bottomnavigationbar and tabbar for my app. But when I tried to apply them together, the part of bottomenavigationbar overflowed by infinity pixels on the bottom. To make scroll on the tabbarview, I attached expanded and singlechildscrollview too, but nothing changed.
I'm a real beginner of Dart and Flutter.
Please give me a hint to fix this problem.
Home.dart
class Home extends StatelessWidget {
GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey();
#override
Widget build(BuildContext context) {
return Scaffold(
key: _scaffoldKey,
body: Column(
children: <Widget>[
Container(
height: 160.0,
child: Stack(
children: <Widget>[
Container(
color: Colors.pinkAccent[400],
width: MediaQuery.of(context).size.width,
height: 100.0,
child: Center(
child: Text(
"여행 앱 로고",
style: TextStyle(color: Colors.white, fontSize: 18.0),
),
),
),
Positioned(
top: 80.0,
left: 0.0,
right: 0.0,
child: Container(
padding: EdgeInsets.symmetric(horizontal: 20.0),
child: DecoratedBox(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(1.0),
border: Border.all(
color: Colors.grey.withOpacity(0.5), width: 1.0),
color: Colors.white),
child: Row(
children: [
IconButton(
icon: Icon(
Icons.menu,
color: Colors.pinkAccent[400],
),
onPressed: () {
print("your menu action here");
_scaffoldKey.currentState.openDrawer();
},
),
Expanded(
child: TextField(
decoration: InputDecoration.collapsed(
hintText: "검색",
),
),
),
IconButton(
icon: Icon(
Icons.search,
color: Colors.pinkAccent[400],
),
onPressed: () {
print("your menu action here");
},
),
],
),
),
),
)
],
),
),
Container(
child: TabBarHome(),
),
],
),
);
}
}
TabBarHome.dart
class TabBarHome extends StatefulWidget {
#override
_TabBarHomeState createState() => _TabBarHomeState();
}
class _TabBarHomeState extends State<TabBarHome> with
SingleTickerProviderStateMixin {
TabController _tabController;
#override
void initState() {
super.initState();
_tabController = TabController(length: 3, vsync: this);
}
#override
void dispose() {
super.dispose();
_tabController.dispose();
}
#override
Widget build(BuildContext context) {
return Scaffold(
body: Column(
children: <Widget>[
Expanded(
child: SingleChildScrollView(
child: TabBarView(
controller: _tabController,
children: <Widget>[
Text('회원가입'),
Text('마이페이지'),
Text('공지'),
],
),
),
),
],
),
bottomNavigationBar: Container(
child: TabBar(
controller: _tabController,
labelColor: Colors.black45,
tabs: <Widget>[
Tab(icon: Icon(Icons.person), text: '회원가입'),
Tab(icon: Icon(Icons.assignment_ind), text: '마이페이지'),
Tab(icon: Icon(Icons.list), text: '공지'),
],
),
color: Colors.cyanAccent[100],
),
floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat,
floatingActionButton: FloatingActionButton.extended(
onPressed: () { },
tooltip: '해외 명소',
icon: Icon(Icons.location_on),
label: Text("해외"),
backgroundColor: Colors.orange[600],
elevation: 10.0,
),
);
}
}
I expect to scroll each tabbarview page and make no errors. Thank you.
Here is my solution to your problem. I have also used just one Scaffold rather than using two. Please check this out and let me know if it works for you.
class Home extends StatefulWidget {
#override
State<StatefulWidget> createState() {
// TODO: implement createState
return _HomeState();
}
}
class _HomeState extends State<Home> with TickerProviderStateMixin {
GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey();
TabController _tabController;
int _selectedTabIndex;
#override
void initState() {
super.initState();
_selectedTabIndex = 0;
_tabController = TabController(length: 3, vsync: this);
}
#override
void dispose() {
super.dispose();
_tabController.dispose();
}
#override
Widget build(BuildContext context) {
return Scaffold(
key: _scaffoldKey,
body: Column(
children: <Widget>[
Container(
height: 160.0,
child: Stack(
children: <Widget>[
Container(
color: Colors.pinkAccent[400],
width: MediaQuery.of(context).size.width,
height: 100.0,
child: Center(
child: Text(
"여행 앱 로고",
style: TextStyle(color: Colors.white, fontSize: 18.0),
),
),
),
Positioned(
top: 80.0,
left: 0.0,
right: 0.0,
child: Container(
padding: EdgeInsets.symmetric(horizontal: 20.0),
child: DecoratedBox(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(1.0),
border: Border.all(
color: Colors.grey.withOpacity(0.5), width: 1.0),
color: Colors.white),
child: Row(
children: [
IconButton(
icon: Icon(
Icons.menu,
color: Colors.pinkAccent[400],
),
onPressed: () {
print("your menu action here");
_scaffoldKey.currentState.openDrawer();
},
),
Expanded(
child: TextField(
decoration: InputDecoration.collapsed(
hintText: "검색",
),
),
),
IconButton(
icon: Icon(
Icons.search,
color: Colors.pinkAccent[400],
),
onPressed: () {
print("your menu action here");
},
),
],
),
),
),
)
],
),
),
Expanded(
child: TabBarView(
controller: _tabController,
children: <Widget>[
Text('회원가입'),
Text('마이페이지'),
Text('공지'),
],
),
)
/* Container(
child: TabBarHome(),
),*/
],
),
bottomNavigationBar: BottomNavigationBar(
currentIndex: _selectedTabIndex,
items: [
BottomNavigationBarItem(
icon: Icon(Icons.person), title: Text('회원가입')),
BottomNavigationBarItem(
icon: Icon(Icons.assignment_ind), title: Text('마이페이지')),
BottomNavigationBarItem(icon: Icon(Icons.list), title: Text('공지')),
],
onTap: (int tappedIndex) {
setState(() {
_selectedTabIndex = tappedIndex;
_tabController.index = tappedIndex;
});
},
),
floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat,
floatingActionButton: FloatingActionButton.extended(
onPressed: () {},
tooltip: '해외 명소',
icon: Icon(Icons.location_on),
label: Text("해외"),
backgroundColor: Colors.orange[600],
elevation: 10.0,
),
);
}
}