- Edited
Merhaba,
Ana stateful sınıfımda scaffold içinde appbar, body ve bottom navigation bar tanımlarım var. Body widget'ına da içinde buton olan ikinci bir stateful sınıf return oluyor. İkinci sınıf ana sınıfın app ve bottomapp barını kullanıyor kısaca. İkinci sınıftaki buton ile uygulamanın aktif bottomapp barını değiştirmek istiyorum.
Yazdığım kodlar şu şekilde
import 'package:flutter/material.dart';
class HomePage extends StatefulWidget {
_HomePageState createState () => _HomePageState();
}
class _HomePageState extends State<HomePage> {
bool bottomNavDurum = true;
@override
Widget build (BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Home Page"),
backgroundColor: Colors.red,
),
body: SecondPage(),
bottomNavigationBar: bottomNavDurum
?
BottomAppBar(
child: Container(
height: 50, child: Text("Custom Bottom Bar 1")),
color: Colors.red)
:
BottomAppBar(
child: Container(
height: 50, child: Text("Custom Bottom Bar 2")),
color: Colors.yellowAccent)
);
}
class SecondPage extends StatefulWidget {
@override
_SecondPageState createState () => _SecondPageState();
}
class _SecondPageState extends State<SecondPage> {
@override
Widget build (BuildContext context) {
return Center(
child: Container(
child: RaisedButton(
child: Text("Button"),
color: Colors.orange,
onPressed: () {
HomePage()
.createState()
.bottomNavDurum = false;
}),
),
);
}
}
Ana sınıftaki bottomappbar'ın durumunu kontrol ettiğim değişkene değeri gönderiyorum fakat setState çalıştırabileceğim bir yapı kuramadım.