Flutter - Как реализовать в коде свайп меню?
Вот рабочий код на Flutter как уже поняли. Все работает, но как сделать свайп сдвигом влево/вправо не могу понять
import 'package:flutter/material.dart';
import 'package:curved_navigation_bar/curved_navigation_bar.dart';
import 'package:flutterapp/pages/favorite.dart';
import 'package:flutterapp/pages/game.dart';
import 'package:flutterapp/pages/rhv.dart';
import 'package:flutterapp/pages/tvorchestvo.dart';
import 'pages/home.dart';
void main() => runApp(MaterialApp(home: BottomNavBar()));
class BottomNavBar extends StatefulWidget {
@override
_BottomNavBarState createState() => _BottomNavBarState();
}
class _BottomNavBarState extends State<BottomNavBar> {
int pageIndex = 0;
final Home _home = Home();
final Game _game = Game();
final Favorite _favorite = Favorite();
final Rhv _rhv = Rhv();
final Tvorchestvo _tvorchestvo = Tvorchestvo();
Widget _showPage = new Home();
Widget _pageChooser(int page){
switch(page){
case 0:
return _home;
break;
case 1:
return _game;
break;
case 2:
return _favorite;
break;
case 3:
return _tvorchestvo;
break;
case 4:
return _rhv;
break;
default:
return new Container(
child: new Center(
child: new Text(
'No',
style: new TextStyle(fontSize:30),
),
),
);
}
}
GlobalKey _bottomNavigationKey = GlobalKey();
@override
Widget build(BuildContext context) {
return Scaffold(
bottomNavigationBar: CurvedNavigationBar(
key: _bottomNavigationKey,
// initialindex: pageIndex,
height: 50.0,
items: <Widget>[
Icon(Icons.home, size: 30, color: Colors.white),
Icon(Icons.list, size: 30, color: Colors.white),
Icon(Icons.favorite, size: 30, color: Colors.white),
Icon(Icons.call_split, size: 30, color: Colors.white),
Icon(Icons.perm_identity, size: 30, color: Colors.white),
],
color: Colors.deepOrange,
buttonBackgroundColor: Colors.deepOrange,
backgroundColor: Colors.white,
animationCurve: Curves.easeInOut,
animationDuration: Duration(milliseconds: 600),
onTap: (int tappedIndex) {
setState(() {
_showPage = _pageChooser(tappedIndex);
});
},
),
body: Container(
color: Colors.white,
child: Center(
child: Column(
children: <Widget>[
// Text(_page.toString(), textScaleFactor: 10.0),
RaisedButton(
// child: Text('Go To Page of index 1'),
child: _showPage,
onPressed: () {
final CurvedNavigationBarState navBarState =
_bottomNavigationKey.currentState;
navBarState.setPage(1);
},
)
],
),
),
));
}
}