68 lines
2.1 KiB
Dart
68 lines
2.1 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
import 'package:pad_start/pages/page1/index.dart';
|
|
import 'package:pad_start/pages/page2/index.dart';
|
|
import 'package:pad_start/pages/page3/index.dart';
|
|
import 'package:pad_start/pages/page4/index.dart';
|
|
|
|
class IndexPage extends StatefulWidget {
|
|
const IndexPage({Key? key}) : super(key: key);
|
|
|
|
@override
|
|
State<IndexPage> createState() => _IndexPageState();
|
|
}
|
|
|
|
class _IndexPageState extends State<IndexPage> {
|
|
List<String> nav = ['首页', '操作', '演示', '我的'];
|
|
int currentIndex = 0;
|
|
List<Widget> navWidget = [Page1(), Page2(), Page3(), Page4()];
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
body: Row(
|
|
children: [
|
|
Container(
|
|
width: 100.w,
|
|
height: double.infinity,
|
|
color: Colors.grey.withOpacity(0.1),
|
|
child: Column(
|
|
children: [
|
|
...List.generate(nav.length, (index){
|
|
return Container(
|
|
margin: EdgeInsets.only(bottom: 10),
|
|
child: Material(
|
|
color: Colors.white,
|
|
child: InkWell(
|
|
onTap: (){
|
|
setState((){
|
|
this.currentIndex = index;
|
|
});
|
|
},
|
|
child: Container(
|
|
width: 100.w,
|
|
height: 100.w,
|
|
alignment: Alignment.center,
|
|
child: Text('${nav[index]}', style: TextStyle(
|
|
fontSize: 16,
|
|
fontWeight: FontWeight.bold,
|
|
),),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
})
|
|
],
|
|
),
|
|
),
|
|
Expanded(child: Container(
|
|
child: IndexedStack(
|
|
index: currentIndex,
|
|
children: navWidget,
|
|
),
|
|
))
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|