2021年12月15日 星期三

Flutter Drawer 導航元件

 


import 'package:flutter/material.dart';
import 'package:untitled/Constants.dart';
import 'package:untitled/page1.dart';

class detailpage extends StatelessWidget {
final GlobalKey<ScaffoldState> _scaffoldKey = new GlobalKey<ScaffoldState>();

@override
Widget build(BuildContext context) {
List<String> _List = ['List1', 'List2', 'List3'];

return Scaffold(
key: _scaffoldKey,
backgroundColor: appBackgroundGreyColor,
drawer: Drawer(
backgroundColor: appBackgroundGreyColor,
child: ListView(
children: <Widget>[
DrawerHeader(
child: Text(
"DrawerHeader",
style: TextStyle(color: Colors.white),
),
),
ListTile(
title: Text(
"Page 1",
style: TextStyle(color: Colors.white),
),
subtitle: Text("Page 1"),
onTap: () {
Navigator.pop(context);
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => page1())); //跳頁
},
),
ListTile(
title: Text(
"Log Out",
style: TextStyle(color: Colors.white),
),
subtitle: Text("Log Out"),
onTap: () {
Navigator.pop(context);
Navigator.pop(context);
},
),
],
)),
body: _detailpage(),
);
}
}

class _detailpage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Text("text");
}
}

沒有留言:

張貼留言