Related
This is my code:
class Temp extends StatefulWidget {
const Temp({Key? key}) : super(key: key);
#override
State<Temp> createState() => _TempState();
}
// stores ExpansionPanel state information
class Item {
Item(bool exp) {
this.isExpanded = exp;
}
late bool isExpanded;
}
List<Item> items = [Item(false), Item(true), Item(true), Item(false)];
class _TempState extends State<Temp> {
#override
Widget build(BuildContext context) {
return DefaultTabController(
length: 4,
child: Scaffold(
body: SingleChildScrollView(
child: Container(
child: ExpansionPanelList(
expandedHeaderPadding: EdgeInsets.zero,
expansionCallback: (int index, bool isExpanded) {
setState(() {
items[index].isExpanded = !isExpanded;
});
},
children: [
ExpansionPanel(
headerBuilder: (BuildContext context, bool isExpanded) {
return ListTile(
title: Text("Test", style: TextStyle(fontSize: 16, fontWeight: FontWeight.w700)),
leading: Icon(Icons.info),
minLeadingWidth : 4,
contentPadding: EdgeInsets.symmetric(vertical: 0.0, horizontal: 16.0),
dense:true,
);
},
body: Column(
children: [
ListTile(
title: Text("Test 1", style: TextStyle(fontSize: 16)),
leading: Icon(Icons.handshake_outlined),
minLeadingWidth : 4,
contentPadding: EdgeInsets.symmetric(vertical: 0.0, horizontal: 16.0),
dense:true,
),
ExpansionTile(
title: const Text('Test 2', style: TextStyle(color: Colors.black87),),
leading: Icon(Icons.handshake_outlined, color: Colors.black54,),
trailing: Column(),
children: <Widget>[
ListTile(
dense: true,
tileColor: Color(0xffffeed4),
title: Text('Foo', style: TextStyle (fontSize: 16),),
trailing: SizedBox(
child: Text("foo", style: TextStyle (fontSize: 16),)
),
),
ListTile(
tileColor: Color(0xffffeed4),
title: Text('Bar', style: TextStyle (fontSize: 16),),
dense: true,
trailing: SizedBox(
child: Text("bar", style: TextStyle (fontSize: 16),)
),
),
Container(
height: 10,
color: Color(0xffffeed4),
),
Container(
color: Color(0xffffeed4),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
TextButton(
style: TextButton.styleFrom(
backgroundColor: Colors.indigo,
shape: CircleBorder(),
),
child: Icon(
Icons.copy,
color: Colors.white,
),
onPressed: () {},
),
TextButton(
style: TextButton.styleFrom(
backgroundColor: Colors.indigo,
shape: CircleBorder(),
),
child: Icon(
Icons.delete_rounded,
color: Colors.white,
),
onPressed: () {},
),
TextButton(
style: TextButton.styleFrom(
backgroundColor: Colors.indigo,
shape: CircleBorder(),
),
child: Icon(
Icons.info_outline,
color: Colors.white,
),
onPressed: () {},
),
],
),
),
Container(
height: 10,
color: Color(0xffffeed4),
)
],
onExpansionChanged: (bool expanded) {
//setState(() => _customTileExpanded = expanded);
},
),
],
),
isExpanded: items[1].isExpanded,
canTapOnHeader: true
),
],
),
),
),
floatingActionButton: FloatingActionButton(
onPressed: null,
tooltip: 'Increment',
child: const Icon(Icons.add),
),
)
);
}
}
And this is the result:
As you see when I click on ExpansionTile title/header then children background is visible not only on this ExpansionTile title/header (Test 2) but also on the previous one (Test 1). As a result it is rather ugly. I don't want children background color be visible on ExpansionTile title/header. Could anyone say how to do it?
It is a bug in flutter. Issue is here
I am working on one of the screens of my app, my first widget buildrow shows up perfectly however the second one does not appear, is this because my screen is not wide enough? I do have 3 buttons within the first buildrow, does that mean it will not show up because it is below it? Here is my code! Please let me know if anyone can help!
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.task.name),
),
body: Material(
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
Expanded(
child: timerText,
),
Expanded(
flex: 0,
child: Padding(
padding: const EdgeInsets.only(bottom: 24.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
RaisedButton(
onPressed: disable
? null
: () {
setState(() {
StudyViewModel.stopwatch.reset();
});
},
color: Colors.red,
padding: EdgeInsets.symmetric(
horizontal: 60.0,
vertical: 20.0,
),
child: Text(
"Reset",
style: TextStyle(fontSize: 20.0, color: Colors.white),
),
),
RaisedButton(
onPressed: () {
setState(() {
if (StudyViewModel.stopwatch.isRunning) {
StudyViewModel.stopwatch.stop();
disable = false;
} else {
StudyViewModel.stopwatch.start();
disable = true;
}
});
},
color: Colors.green,
padding: EdgeInsets.symmetric(
horizontal: 60.0,
vertical: 20.0,
),
child: Text(
"Play/Pause",
style: TextStyle(fontSize: 24.0, color: Colors.white),
),
),
RaisedButton(
onPressed: disable
? null
: () async {
widget.task.elapsedTime =
StudyViewModel.milliToElapsedString(
StudyViewModel
.stopwatch.elapsedMilliseconds);
await StudyViewModel.saveFile();
Navigator.of(context).pop();
},
color: Colors.yellow,
padding: EdgeInsets.symmetric(
horizontal: 60.0,
vertical: 20.0,
),
child: Text(
"Save",
style: TextStyle(fontSize: 24.0, color: Colors.white),
),
),
],
),
),
),
],
),
),
);
}
Widget buildRow(BuildContext context, int index) {
return ListView(
children: <Widget>[
Text(StudyViewModel.studies[index].name,
style: TextStyle(fontSize: 18.0),
),
ListView.builder(
shrinkWrap: true,
primary: false,
itemCount: StudyViewModel.studies[index].tasks.length,
itemBuilder: (context, int taskIndex) {
return ListTile(
title: Text(StudyViewModel.studies[index].tasks[taskIndex].name),
contentPadding: EdgeInsets.symmetric(horizontal: 32.0),
subtitle: Text(
StudyViewModel.studies[index].tasks[taskIndex].elapsedTime),
);
},
),
],
);
}
}
Try to wrap your middle RaisedButton with Flexible.
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.task.name),
),
body: Material(
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
Expanded(
child: timerText,
),
Expanded(
flex: 0,
child: Padding(
padding: const EdgeInsets.only(bottom: 24.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
RaisedButton(
onPressed: disable
? null
: () {
setState(() {
StudyViewModel.stopwatch.reset();
});
},
color: Colors.red,
padding: EdgeInsets.symmetric(
horizontal: 60.0,
vertical: 20.0,
),
child: Text(
"Reset",
style: TextStyle(fontSize: 20.0, color: Colors.white),
),
),
Flexible(
child: RaisedButton(
onPressed: () {
setState(() {
if (StudyViewModel.stopwatch.isRunning) {
StudyViewModel.stopwatch.stop();
disable = false;
} else {
StudyViewModel.stopwatch.start();
disable = true;
}
});
},
color: Colors.green,
padding: EdgeInsets.symmetric(
horizontal: 60.0,
vertical: 20.0,
),
child: Text(
"Play/Pause",
style: TextStyle(fontSize: 24.0, color: Colors.white),
),
),
),
RaisedButton(
onPressed: disable
? null
: () async {
widget.task.elapsedTime =
StudyViewModel.milliToElapsedString(
StudyViewModel
.stopwatch.elapsedMilliseconds);
await StudyViewModel.saveFile();
Navigator.of(context).pop();
},
color: Colors.yellow,
padding: EdgeInsets.symmetric(
horizontal: 60.0,
vertical: 20.0,
),
child: Text(
"Save",
style: TextStyle(fontSize: 24.0, color: Colors.white),
),
),
],
),
),
),
],
),
),
);
}
I am Trying to build an app. which fetching the user credential data and shows in profile page. I am getting an error => Bad state: cannot get a field on a DocumentSnapshotPlatform which does not exist in the profile section need help
Widget headerProfile(BuildContext context, DocumentSnapshot snapshot) {
return SizedBox(
height: MediaQuery.of(context).size.height * 0.25,
width: MediaQuery.of(context).size.width,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Expanded(
child: Container(
height: 200.0,
width: 180.0,
child: Column(
children: [
GestureDetector(
onTap: () {},
child: CircleAvatar(
backgroundColor: constantColors.transperant,
radius: 60.0,
backgroundImage: NetworkImage(snapshot['userimage']),
),
),
Padding(
padding: const EdgeInsets.only(top: 8.0),
child: Text(snapshot['username'],
style: TextStyle(
color: constantColors.whiteColor,
fontWeight: FontWeight.bold,
fontSize: 16.0)),
),
Padding(
padding: const EdgeInsets.only(top: 8.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(EvaIcons.email, color: constantColors.greenColor),
Padding(
padding: const EdgeInsets.only(left:9.0),
child: Text(snapshot['useremail'],
style: TextStyle(
color: constantColors.whiteColor,
fontWeight: FontWeight.bold,
fontSize: 13.0)),
),
],
),
),
],
),
),
),
Container(
// width: 200.0,
width: 200.0,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Padding(
padding: const EdgeInsets.only(top:16.0, right: 30.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Container(
decoration: BoxDecoration(
color: constantColors.darkColor,
borderRadius: BorderRadius.circular(15.0)),
height: 70.0,
width: 80.0,
child: Column(
children: [
Text(
'0',
style: TextStyle(
color: constantColors.whiteColor,
fontWeight: FontWeight.bold,
fontSize: 28.0),
),
Text(
'Followers',
style: TextStyle(
color: constantColors.whiteColor,
fontWeight: FontWeight.bold,
fontSize: 12.0),
),
],
),
),
Container(
decoration: BoxDecoration(
color: constantColors.darkColor,
borderRadius: BorderRadius.circular(15.0)),
height: 70.0,
width: 80.0,
child: Column(
children: [
Text(
'0',
style: TextStyle(
color: constantColors.whiteColor,
fontWeight: FontWeight.bold,
fontSize: 28.0),
),
Text(
'Following',
style: TextStyle(
color: constantColors.whiteColor,
fontWeight: FontWeight.bold,
fontSize: 12.0),
),
],
),
),
],
),
),
Padding(
padding: const EdgeInsets.only(top:16.0),
child: Container(
decoration: BoxDecoration(
color: constantColors.darkColor,
borderRadius: BorderRadius.circular(15.0)),
height: 70.0,
width: 80.0,
child: Column(
children: [
Text(
'0',
style: TextStyle(
color: constantColors.whiteColor,
fontWeight: FontWeight.bold,
fontSize: 28.0),
),
Text(
'Posts',
style: TextStyle(
color: constantColors.whiteColor,
fontWeight: FontWeight.bold,
fontSize: 12.0),
),
],
),
),
),
],
),
)
],
),
);
}
I think the error is coming from the snapshot['username'], snapshot['userimage'] and snapshot['useremail'].....
This is my Profile.dart
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
centerTitle: true,
leading: IconButton(
onPressed: () {},
icon: Icon(
EvaIcons.settings2Outline,
color: constantColors.lightBlueColor,
)),
actions: [
IconButton(
onPressed: () {},
icon: Icon(EvaIcons.logOutOutline,
color: constantColors.greenColor)),
],
backgroundColor: constantColors.blueGreyColor.withOpacity(0.4),
title: RichText(
text: TextSpan(
text: 'My ',
style: TextStyle(
color: constantColors.whiteColor,
fontWeight: FontWeight.bold,
fontSize: 20.0,
),
children: <TextSpan>[
TextSpan(
text: 'Profile',
style: TextStyle(
color: constantColors.blueColor,
fontWeight: FontWeight.bold,
fontSize: 20.0,
),
),
])),
),
body: SingleChildScrollView(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Container(
height: MediaQuery.of(context).size.height,
width: MediaQuery.of(context).size.width,
child: StreamBuilder<DocumentSnapshot>(
stream: FirebaseFirestore.instance
.collection('users')
.doc(Provider.of<Authentication>(context, listen: false)
.getUserUid)
.snapshots(),
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) {
return Center(
child: CircularProgressIndicator(),
);
} else {
return new Column(
children: [
Provider.of<ProfileHelpers>(context, listen: false).headerProfile(context, snapshot.data)
],
);
}
},
),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(15.0),
color: constantColors.blueGreyColor.withOpacity(0.6)),
),
),
),
);
}
and below is the FirebaseOperations.dart
Future initUserData(BuildContext context) async {
return FirebaseFirestore.instance
.collection('users')
.doc(Provider.of<Authentication>(context, listen: false).getUserUid)
.get()
.then((doc) {
print('Fetching user data...');
initUserName = doc.data()['username'];
initUserEmail = doc.data()['useremail'];
initUserImage = doc.data()['userimage'];
print(initUserName);
print(initUserEmail);
print(initUserImage);
notifyListeners();
});
String initUserEmail, initUserName, initUserImage;
String get getInitUserName => initUserName;
String get getInitUserEmail => initUserEmail;
String get getInitUserImage => initUserImage;
All my code is this please help and there is user profile circle avatar at the bottom navbar it is also not the the image
Widget bottomNavBar(BuildContext context, int index, PageController pageController) {
return CustomNavigationBar(
currentIndex: index,
bubbleCurve: Curves.bounceIn,
scaleCurve: Curves.decelerate,
selectedColor: constantColors.blueColor,
unSelectedColor: constantColors.whiteColor,
strokeColor: constantColors.blueColor,
scaleFactor: 0.5,
iconSize: 30.0,
onTap: (val) {
index = val;
pageController.jumpToPage(val);
notifyListeners();
},
backgroundColor: Color(0xff040307),
items: [
CustomNavigationBarItem(icon: Icon(EvaIcons.home)),
CustomNavigationBarItem(icon: Icon(Icons.message_rounded)),
CustomNavigationBarItem(
icon: CircleAvatar(
radius: 35.0,
backgroundColor: constantColors.blueGreyColor,
backgroundImage: NetworkImage(Provider.of<FirebaseOperations>(context, listen: false).initUserImage),
)),
]);
}
Homepage.dart
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: constantColors.darkColor,
body: PageView(
controller: homepageController,
children: [
Feed(),
Chatroom(),
Profile(),
],
physics: NeverScrollableScrollPhysics(),
onPageChanged: (page) {
setState(() {
pageIndex = page;
});
},
),
bottomNavigationBar: Provider.of<HomepageHelpers>(context, listen: false)
.bottomNavBar(context, pageIndex, homepageController),
);
}
Please Help
I am having trouble with calling SetState when pressing a FAB. Nothing changes on the screen...
Here's the code :
bool _editMode = false;
return DefaultTabController(
length: 3,
child: Scaffold(
backgroundColor: Colors.orange[100],
appBar: AppBar(
backgroundColor: Colors.white,
automaticallyImplyLeading: false,
title: Center(
child: Text(
'Liste de vocabulaire n°${userData.selectedCarnetList + 1}'
.toUpperCase(),
style: TextStyle(
fontSize: 20.0,
fontWeight: FontWeight.bold,
color: Colors.blue[800],
),
maxLines: 2,
textAlign: TextAlign.center,
),
),
actions: [
GestureDetector(
child: Container(
padding: EdgeInsets.all(16.0),
child: listsProvider.dicoLanguage == Language.french
? Image.asset(
'icons/french_flag.png',
height: 45.0,
width: 45.0,
)
: Image.asset(
'icons/english_flag.png',
height: 45.0,
width: 45.0,
),
),
onTap: () => listsProvider.dicoLanguage == Language.french
? listsProvider.setDicoLanguage(Language.english)
: listsProvider.setDicoLanguage(Language.french),
),
],
bottom: TabBar(
indicatorWeight: 10,
indicatorColor: Colors.green[800],
tabs: [
Tab(
child: Text(
'Ordre alphabétique',
textAlign: TextAlign.center,
style: TextStyle(color: Colors.red[800]),
),
),
Tab(
child: Text(
'Catégorie grammaticale',
textAlign: TextAlign.center,
style: TextStyle(color: Colors.red[800]),
),
),
Tab(
child: Text(
'Niveau',
textAlign: TextAlign.center,
style: TextStyle(color: Colors.red[800]),
),
),
]),
),
body: TabBarView(
children: [
ListView(
children: [
Padding(
padding: const EdgeInsets.all(8.0),
child: CarnetListCard(
index: index,
taille:
userData.userInfo.carnetVoc[index].wordId.length,
titre: userData.userInfo
.carnetVoc[userData.selectedCarnetList].titre
.toUpperCase(),
dateCreation:
userData.userInfo.carnetVoc[index].creation,
dateModification:
userData.userInfo.carnetVoc[index].modification,
mots: ListView.builder(
itemCount: userData
.userInfo.carnetVoc[index].wordId.length,
itemBuilder: (context, index2) {
return ListTile(
contentPadding: EdgeInsets.all(0),
title: Container(
decoration: BoxDecoration(
color: Colors.red[800],
borderRadius: BorderRadius.circular(10.0),
),
child: Padding(
padding: const EdgeInsets.all(12.0),
child: Row(
mainAxisAlignment:
MainAxisAlignment.spaceAround,
children: [
Expanded(
child: Text(
listsProvider.dicoLanguage ==
Language.english
? wordBank[userData
.userInfo
.carnetVoc[index]
.wordId[index2]]
.main
: wordBank[userData
.userInfo
.carnetVoc[index]
.wordId[index2]]
.mainFr,
style: TextStyle(
color: Colors.white,
fontSize: 13.0,
),
),
),
Expanded(
child: Text(
listsProvider.dicoLanguage ==
Language.english
? wordBank[userData
.userInfo
.carnetVoc[index]
.wordId[index2]]
.mainFr
: wordBank[userData
.userInfo
.carnetVoc[index]
.wordId[index2]]
.main,
style: TextStyle(
color: Colors.orange[100],
fontSize: 13.0),
),
),
],
),
),
),
onTap: () => Navigator.push(context,
MaterialPageRoute(builder: (context) {
return DisplayThematicList(
subTheme: listsProvider
.themeBank[index].subTheme[index2],
langue: listsProvider.dicoLanguage,
image: listsProvider.themeBank[index].thema,
);
})),
);
},
),
),
),
],
),
ListView(),
ListView(),
],
),
floatingActionButton: _editMode == false
? Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Padding(
padding: const EdgeInsets.symmetric(horizontal: 25.0),
child: FloatingActionButton(
heroTag: 'Back',
backgroundColor: Colors.red[800],
child: Icon(Icons.arrow_back),
onPressed: () => Navigator.pushReplacementNamed(
context, CarnetScreen.id),
),
),
FloatingActionButton.extended(
heroTag: 'Edit',
backgroundColor: Colors.blue[800],
icon: Icon(Icons.edit),
label: Text('Modifier'),
onPressed: () {
setState(() {
_editMode = true;
print(_editMode);
});
})
],
)
: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Padding(
padding: const EdgeInsets.symmetric(horizontal: 25.0),
child: FloatingActionButton(
heroTag: 'Close',
backgroundColor: Colors.red[800],
child: Icon(Icons.close),
onPressed: () => Navigator.pushReplacementNamed(
context, CarnetScreen.id),
),
),
FloatingActionButton.extended(
heroTag: 'Valider',
backgroundColor: Colors.green[800],
icon: Icon(Icons.library_add_check_rounded),
label: Text('Valider'),
onPressed: () {
setState(() {
_editMode = false;
print(_editMode);
});
}),
],
),
),
);
}
}
When tapping FAB ('EDIT'), I set (_editMode) to TRUE, and it should rebuild with new buttons showing... but for some reason nothing happens...
Is there anything in a FAB which separates the action from the State of the Screen ? or could it be due to the TAB BAR ?
Any idea why ?
Put your variable bool _editMode = false; above build method
bool _editMode = false;
#override
Widget build(BuildContext context) {
In my application, I have the "Homepage" with BottomNavigationBar already installed and running with 4 different pages. After I access the "Perfil" screen and advance to other child screens (PaymentForm) and try to go back to the "Perfil" page, the BottomNavigationBar is not there. How do I return to the "HomePage" with the index corresponding to that screen "Perfil"? Codes below.
Homepage() with BottomNavigationBar:
class HomePage extends StatefulWidget {
#override
_HomePageState createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
int _currentIndex = 0;
final tabs = [
Center(child: MainPage()),
Center(child: Text('Busca')),
Center(child: Text('Pedidos')),
Center(child: Perfil()),
];
#override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: Scaffold(
body: tabs[_currentIndex],
bottomNavigationBar: BottomNavigationBar(
currentIndex: _currentIndex,
type: BottomNavigationBarType.fixed,
items: [
BottomNavigationBarItem(
icon: Image.asset(
'assets/images/home_icone.png',
width: 40,
height: 40,
),
title: Text(
'Inicio',
style: TextStyle(color: Color(0xff203760)),
),
),
BottomNavigationBarItem(
icon: Image.asset(
'assets/images/busca_icone.png',
width: 40,
height: 40,
),
title: Text(
'Busca',
style: TextStyle(color: Color(0xff203760)),
),
),
BottomNavigationBarItem(
icon: Image.asset(
'assets/images/pedidos_icone.png',
width: 40,
height: 40,
),
title: Text(
'Pedidos',
style: TextStyle(color: Color(0xff203760)),
),
),
BottomNavigationBarItem(
icon: Image.asset(
'assets/images/perfil_icone.png',
width: 40,
height: 40,
),
title: Text(
'Perfil',
style: TextStyle(color: Color(0xff203760)),
),
),
],
onTap: (index) {
setState(() {
_currentIndex = index;
});
},
),
),
);
}
}
Perfil():
class Perfil extends StatefulWidget {
#override
_PerfilState createState() => _PerfilState();
}
class _PerfilState extends State<Perfil>{
final AuthService _auth = AuthService();
#override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: Scaffold(
body: SingleChildScrollView(
child: Column(
children: <Widget>[
Container(
decoration: BoxDecoration(
border: Border(
bottom: BorderSide(
color: Colors.blueGrey,
width: 1.0,
),
),
),
height: 120,
width: double.maxFinite,
margin: EdgeInsets.fromLTRB(0, 20, 0, 0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: <Widget>[
Image.asset(
'assets/images/perfil_foto.png',
height: 60,
width: 60,
),
Text(
'$nameUser',
style: TextStyle(color: Color(0xff203760), fontSize: 28.0),
textAlign: TextAlign.center,
),
Image.asset(
'assets/images/right_arrow.png',
height: 40,
width: 40,
)
],
),
),
Padding(
padding: const EdgeInsets.all(5),
child: Column(
children: <Widget>[
ListView(
shrinkWrap: true,
children: <Widget>[
ListTile(
leading: Icon(
Icons.notifications_none,
size: 40.0,
color: Color(0xff203760),
),
title: Text(
"Notificações",
style: TextStyle(color: Color(0xff203760), fontSize: 20.0),
),
subtitle: Text(
"Central de notificações",
style: TextStyle(color: Color(0xff203760), fontSize: 16.0),
),
onTap: () {},
),
ListTile(
leading: Icon(
Icons.favorite_border,
size: 40.0,
color: Color(0xff203760),
),
title: Text(
"Favoritos",
style: TextStyle(color: Color(0xff203760), fontSize: 20.0),
),
subtitle: Text(
"Central de notificações",
style: TextStyle(color: Color(0xff203760), fontSize: 16.0),
),
onTap: () {},
),
ListTile(
leading: Icon(
Icons.payment,
size: 40.0,
color: Color(0xff203760),
),
title: Text(
"Formas de Pagamento",
style: TextStyle(color: Color(0xff203760), fontSize: 20.0),
),
subtitle: Text(
"Central de notificações",
style: TextStyle(color: Color(0xff203760), fontSize: 16.0),
),
onTap: () {
Navigator.of(context).push(MaterialPageRoute(builder: (context) => PaymentForm()));
},
),
ListTile(
leading: Icon(
Icons.location_on,
size: 40.0,
color: Color(0xff203760),
),
title: Text(
"Endereços",
style: TextStyle(color: Color(0xff203760), fontSize: 20.0),
),
subtitle: Text(
"Central de notificações",
style: TextStyle(color: Color(0xff203760), fontSize: 16.0),
),
onTap: () {},
),
ListTile(
leading: Image.asset(
'assets/images/logout.png',
width: 40,
height: 40,
),
title: Text(
"Sair",
style: TextStyle(color: Color(0xff203760), fontSize: 20.0),
),
subtitle: Text(
"Finalizar sessão",
style: TextStyle(color: Color(0xff203760), fontSize: 16.0),
),
onTap: () async {
await _auth.signOut();
},
),
],
),
],
),
)
],
),
),
),
);
}
}
PaymentForm() (child page from Perfil):
class PaymentForm extends StatefulWidget {
#override
_PaymentFormState createState() => _PaymentFormState();
}
class _PaymentFormState extends State<PaymentForm> {
#override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: Scaffold(
body: Column(
children: <Widget>[
Container(
height: 120,
width: double.maxFinite,
margin: EdgeInsets.all(0),
decoration: BoxDecoration(
border: Border(
bottom: BorderSide(
color: Colors.blueGrey,
width: 0.5,
),
),
),
child: Padding(
padding: const EdgeInsets.fromLTRB(0, 25, 0, 0),
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Container(
padding: const EdgeInsets.fromLTRB(15, 15, 10, 15),
child: ClipOval(
child: Container(
width: 35,
height: 35,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage('assets/images/left_arrow.png'),
),
),
child: FlatButton(
padding: EdgeInsets.all(0.0),
onPressed: () {
print('teste');
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => HomePage()),
);
},
child: null,
),
),
),
),
Text(
" Formas de pagamento",
style:
TextStyle(color: Color(0xff203760), fontSize: 28.0),
textAlign: TextAlign.center,
),
],
),
),
),
Padding(
padding: const EdgeInsets.all(0),
child: Column(
children: <Widget>[
ListView(
shrinkWrap: true,
children: ListTile.divideTiles(
context: context,
color: Color(0xff203760),
tiles: [
ListTile(
title: Text(
"Cartão de crédito",
style: TextStyle(
color: Color(0xff203760), fontSize: 24.0),
),
subtitle: Text(
"Master ****** 3284",
style: TextStyle(
color: Color(0xff203760), fontSize: 12.0),
),
trailing: Image.asset(
'assets/images/menu_dots.png',
width: 10,
),
onTap: () {
Navigator.of(context).push(MaterialPageRoute(
builder: (context) => CartManager()));
},
),
],
).toList(),
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Container(
padding: const EdgeInsets.all(15),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
"Cartão de crédito",
style: TextStyle(
color: Color(0xff203760),
fontSize: 28.0,
),
),
],
),
),
Container(
padding: const EdgeInsets.all(15),
child: ClipOval(
child: Container(
width: 40,
height: 40,
decoration: BoxDecoration(
image: DecorationImage(
image:
AssetImage('assets/images/add_button.png'),
),
),
child: FlatButton(
padding: EdgeInsets.all(0.0),
onPressed: () {
print('teste');
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => CartAdd()),
);
},
child: null,
),
),
),
),
],
),
],
),
)
],
),
),
);
}
}
Thanks for the help!!!
Your issue is that you are using the MaterialApp widget in each class. You don't need to do this. Only your HomePage needs to have it. On the other classes, you only need to have the content you want to show. Taking your code, removing the MaterialApp widgets and simplifying it without the parts you haven't shared, will make it work:
class HomePage extends StatefulWidget {
#override
_HomePageState createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
int _currentIndex = 0;
final tabs = [
Center(child: Text('Main')),
Center(child: Text('Busca')),
Center(child: Text('Pedidos')),
Center(child: Text('Perfil')),
];
#override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: Scaffold(
body: tabs[_currentIndex],
bottomNavigationBar: BottomNavigationBar(
currentIndex: _currentIndex,
type: BottomNavigationBarType.fixed,
items: [
BottomNavigationBarItem(
icon: Icon(Icons.home),
title: Text(
'Inicio',
style: TextStyle(color: Color(0xff203760)),
),
),
BottomNavigationBarItem(
icon: Icon(Icons.home),
title: Text(
'Busca',
style: TextStyle(color: Color(0xff203760)),
),
),
BottomNavigationBarItem(
icon: Icon(Icons.home),
title: Text(
'Pedidos',
style: TextStyle(color: Color(0xff203760)),
),
),
BottomNavigationBarItem(
icon: Icon(Icons.home),
title: Text(
'Perfil',
style: TextStyle(color: Color(0xff203760)),
),
),
],
onTap: (index) {
setState(() {
_currentIndex = index;
});
},
),
),
);
}
}