flutter小部件之路(Scaffold页面小部件)
程序员文章站
2022-06-01 17:01:04
...
import 'package:flutter/material.dart';
void main()=>runApp(Myapp());
class Myapp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: Scaffold(
appBar: AppBar(
title: Text('dclef'),
),
body: Center(
child: Text('hello'),
),
drawer: Drawer(),//左边侧边栏
bottomNavigationBar: BottomNavigationBar(//底部栏
items: [
BottomNavigationBarItem(
// ignore: deprecated_member_use
title: Text('home'),
icon: Icon(Icons.home)
),
BottomNavigationBarItem(
// ignore: deprecated_member_use
title: Text('video'),
icon: Icon(Icons.video_call)
),
],
),
floatingActionButton: FloatingActionButton(//按钮
onPressed: (){
print('onPressed');
},
child: Icon(Icons.add),
),
floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,//位置居中
),
);
}
}