2、四个切换页面
页面 1 :
import 'package:flutter/material.dart'; /// 应用主界面 class HomePage extends StatefulWidget { @override _HomePageState createState() => _HomePageState(); } class _HomePageState extends State<HomePage> { @override Widget build(BuildContext context) { /// 界面框架 return Scaffold( /// 居中组件 body: Center( child: Text("应用主页面"), ), ); } }
页面 2 :
import 'package:flutter/material.dart'; /// 图片页面 class ImagePage extends StatefulWidget { @override _ImagePageState createState() => _ImagePageState(); } class _ImagePageState extends State<ImagePage> { @override Widget build(BuildContext context) { /// 界面框架 return Scaffold( /// 居中组件 body: Center( child: Text("图片页面"), ), ); } }
页面 3 :
import 'package:flutter/material.dart'; /// 搜索页面 class SearchPage extends StatefulWidget { @override _SearchPageState createState() => _SearchPageState(); } class _SearchPageState extends State<SearchPage> { @override Widget build(BuildContext context) { /// 界面框架 return Scaffold( /// 居中组件 body: Center( child: Text("搜索页面"), ), ); } }
页面 4 :
import 'package:flutter/material.dart'; /// 个人设置界面 class SettingPage extends StatefulWidget { @override _SettingPageState createState() => _SettingPageState(); } class _SettingPageState extends State<SettingPage> { @override Widget build(BuildContext context) { /// 界面框架 return Scaffold( /// 居中组件 body: Center( child: Text("个人设置页面"), ), ); } }
3、应用启动主界面
import 'package:flutter/material.dart'; import 'package:flutter_app/navigator/main_navigator.dart'; /// 应用主页面 void main() { runApp( MyApp() ); } class MyApp extends StatelessWidget { // This widget is the root of your application. @override Widget build(BuildContext context) { return MaterialApp( title: 'Flutter Demo', theme: ThemeData( primarySwatch: Colors.blue, ), home: MainNavigatorWidget(), ); } }
4、运行效果
五、相关资源
参考资料 :
Flutter 官网 : https://flutter.dev/
Flutter 插件下载地址 : https://pub.dev/packages
Flutter 开发文档 : https://flutter.cn/docs ( 强烈推荐 )
官方 GitHub 地址 : https://github.com/flutter
Flutter 中文社区 : https://flutter.cn/
Flutter 实用教程 : https://flutter.cn/docs/cookbook
Flutter CodeLab : https://codelabs.flutter-io.cn/
Dart 中文文档 : https://dart.cn/
Dart 开发者官网 : https://api.dart.dev/
Flutter 中文网 : https://flutterchina.club/ , http://flutter.axuer.com/docs/
Flutter 相关问题 : https://flutterchina.club/faq/ ( 入门阶段推荐看一遍 )
GitHub 上的 Flutter 开源示例 : https://download.csdn.net/download/han1202012/15989510
Flutter 实战电子书 : https://book.flutterchina.club/chapter1/
重要的专题 :
Flutter 动画参考文档 : https://flutterchina.club/animations/
博客源码下载 :
GitHub 地址 : https://github.com/han1202012/flutter_app ( 随博客进度一直更新 , 有可能没有本博客的源码 )
博客源码快照 : https://download.csdn.net/download/han1202012/16306822 ( 本篇博客的源码快照 , 可以找到本博客的源码 )