0
I made a Flutter screen using Cupertino, which by clicking on the "drive" field would open a "Drive" screen to choose the drive, but the Navigationbar that was used on one screen is being passed to another without at least passing it to the other page, and I’m not sure how to solve the problem;
Screenshot:
Widget build(BuildContext context) {
return PlatformTabScaffold(
tabController: tabController,
appBarBuilder: (_, index) => PlatformAppBar(
android: (_) => MaterialAppBarData(
centerTitle: true,
),
ios: (_) => CupertinoNavigationBarData(
backgroundColor: CupertinoColors.white,
title: Text(
titulo,
style: TextStyle(color: CupertinoColors.black),
)),
title: (Text(titulo)),
),
bodyBuilder: (context, index) => textPage(tabController.index(context)),
itemChanged: (int a) {
setState(() {
titulo = pageName(a);
});
},
iosTabs: (_) => CupertinoTabBarData(
// Aba de Navegação do IOS
items: <BottomNavigationBarItem>[
BottomNavigationBarItem(
icon: Icon(Icons.play_arrow), title: Text('Iniciar Dia')),
BottomNavigationBarItem(
icon: Icon(Icons.local_shipping), title: Text('Abastecer')),
BottomNavigationBarItem(
icon: Icon(Icons.stop), title: Text('Finalizar Dia')),
BottomNavigationBarItem(
icon: Icon(Icons.local_gas_station), title: Text('Tanque')),
BottomNavigationBarItem(
icon: Icon(Icons.equalizer), title: Text('Mais opções')),
],
backgroundColor: CupertinoColors.lightBackgroundGray,
activeColor: CupertinoColors.activeBlue,
inactiveColor: CupertinoColors.inactiveGray,
),
androidTabs: (_) => MaterialNavBarData(
//Aba de Navegação do Android
type: BottomNavigationBarType.fixed,
backgroundColor: Colors.orange[700],
unselectedItemColor: Colors.black87,
selectedItemColor: Colors.white70,
showSelectedLabels: true,
items: <BottomNavigationBarItem>[
BottomNavigationBarItem(
icon: Icon(Icons.play_arrow), title: Text('Iniciar Dia')),
BottomNavigationBarItem(
icon: Icon(Icons.local_shipping), title: Text('Abastecer')),
BottomNavigationBarItem(
icon: Icon(Icons.close), title: Text('Finalizar Dia')),
BottomNavigationBarItem(
icon: Icon(Icons.local_gas_station), title: Text('Tanque')),
BottomNavigationBarItem(
backgroundColor: Colors.orange,
icon: Icon(Icons.equalizer),
title: Text('Mais opções')),
],
),
);
}
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_platform_widgets/flutter_platform_widgets.dart';
class UnidadeOpcoes extends StatefulWidget {
@override
_UnidadeOpcoesState createState() => _UnidadeOpcoesState();
}
class _UnidadeOpcoesState extends State<UnidadeOpcoes> {
var _currencies1 = ["one", "two", "three"];
bool check = false;
@override
Widget build(BuildContext context) {
return PlatformScaffold(
appBar: PlatformAppBar(
title: Text("Unidade"),
android: (_) => MaterialAppBarData(
automaticallyImplyLeading: true,
),
ios: (_) => CupertinoNavigationBarData(
trailing: CupertinoButton(
padding: EdgeInsets.only(bottom: 0.0),
child: Text("Salvar"),
onPressed: () {
Navigator.pop(context);
},
),
automaticallyImplyMiddle: true,
leading: CupertinoButton(
padding: EdgeInsets.only(bottom: 0.0),
child: Text("Cancelar"),
onPressed: () {
Navigator.pop(context);
},
),
),
),
body: Text("Teste"),
ios: (_) => CupertinoPageScaffoldData(),
android: (_) => MaterialScaffoldData(
body: Container(
color: Colors.white,
child: ListView.builder(
itemCount: _currencies1.length,
itemBuilder: (BuildContext context, int index) {
return ListTile(
title: Text(
_currencies1[index],
),
leading: check == false
? Icon(Icons.check_box_outline_blank)
: Icon(Icons.check_box, color: Colors.blueAccent),
onTap: () {
setState(() {
check = !check;
});
},
);
},
),
),
),
);
} }
If you solved your problem, please mark as accepted.
– Matheus Ribeiro