kf_drawer 1.1.2 kf_drawer: ^1.1.2 copied to clipboard
Side menu (Drawer)
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:kf_drawer/kf_drawer.dart';
import 'screens/auth_page.dart';
import 'screens/calendar_page.dart';
import 'screens/main_page.dart';
import 'utils/class_builder.dart';
void main() {
ClassBuilder.registerClasses();
runApp(MyApp());
}
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: MainWidget(),
);
}
}
class MainWidget extends StatefulWidget {
MainWidget({Key key, this.title}) : super(key: key);
final String title;
@override
_MainWidgetState createState() => _MainWidgetState();
}
class _MainWidgetState extends State<MainWidget> with TickerProviderStateMixin {
KFDrawerController _drawerController;
@override
void initState() {
super.initState();
_drawerController = KFDrawerController(
initialPage: ClassBuilder.fromString('MainPage'),
items: [
KFDrawerItem.initWithPage(
text: Text('MAIN', style: TextStyle(color: Colors.white)),
icon: Icon(Icons.home, color: Colors.white),
page: MainPage(),
),
KFDrawerItem.initWithPage(
text: Text(
'CALENDAR',
style: TextStyle(color: Colors.white),
),
icon: Icon(Icons.calendar_today, color: Colors.white),
page: CalendarPage(),
),
KFDrawerItem.initWithPage(
text: Text(
'SETTINGS',
style: TextStyle(color: Colors.white),
),
icon: Icon(Icons.settings, color: Colors.white),
page: ClassBuilder.fromString('SettingsPage'),
),
],
);
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: KFDrawer(
// borderRadius: 0.0,
// shadowBorderRadius: 0.0,
// menuPadding: EdgeInsets.all(0.0),
// scrollable: true,
controller: _drawerController,
header: Align(
alignment: Alignment.centerLeft,
child: Container(
padding: EdgeInsets.symmetric(horizontal: 16.0),
width: MediaQuery.of(context).size.width * 0.6,
child: Image.asset(
'assets/logo.png',
alignment: Alignment.centerLeft,
),
),
),
footer: KFDrawerItem(
text: Text(
'SIGN IN',
style: TextStyle(color: Colors.white),
),
icon: Icon(
Icons.input,
color: Colors.white,
),
onPressed: () {
Navigator.of(context).push(CupertinoPageRoute(
fullscreenDialog: true,
builder: (BuildContext context) {
return AuthPage();
},
));
},
),
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topLeft,
end: Alignment.bottomRight,
colors: [Color.fromRGBO(255, 255, 255, 1.0), Color.fromRGBO(44, 72, 171, 1.0)],
tileMode: TileMode.repeated,
),
),
),
);
}
}