
基于flutter3.41+dart3.11+get+cached_network_image构建高颜值旅行酒店预约app程序。




基于最新跨平台技术Flutter3.41.5搭建项目模板。



import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
// 引入pages页面
import '../pages/index/index.dart';
import '../pages/hotel/index.dart';
import '../pages/message/index.dart';
import '../pages/explore/index.dart';
import '../pages/my/index.dart';
class Layout extends StatefulWidget {
const Layout({super.key});
@override
State<Layout> createState() => _LayoutState();
}
class _LayoutState extends State<Layout> with AutomaticKeepAliveClientMixin {
// page索引
int pageCurrent = 0;
// page页面
late final List<Widget> pageList = const [
IndexPage(),
HotelPage(),
ExplorePage(),
Message(),
MyPage()
];
@override
bool get wantKeepAlive => true;
// 动态生成导航项
List<BottomNavigationBarItem> buildNavItems() {
return [
BottomNavigationBarItem(
...
),
BottomNavigationBarItem(
...
),
BottomNavigationBarItem(
...
),
BottomNavigationBarItem(
...
),
BottomNavigationBarItem(
...
),
];
}
@override
Widget build(BuildContext context) {
super.build(context);
return Scaffold(
backgroundColor: Colors.grey[50],
body: IndexedStack(
index: pageCurrent,
children: pageList,
),
// 底部导航栏
bottomNavigationBar: Theme(
// Flutter去掉BottomNavigationBar底部导航栏的水波纹
data: ThemeData(
splashColor: Colors.transparent,
highlightColor: Colors.transparent,
hoverColor: Colors.transparent,
),
child: Stack(
children: [
Container(
decoration: BoxDecoration(
border: Border(top: BorderSide(color: Colors.black45, width: .1)),
),
child: BottomNavigationBar(
backgroundColor: Colors.white,
fixedColor: Color(0xffffaa00),
unselectedItemColor: Colors.black,
type: BottomNavigationBarType.fixed,
elevation: 1.0,
unselectedFontSize: 12.0,
selectedFontSize: 12.0,
currentIndex: pageCurrent,
items: buildNavItems(),
onTap: (index) {
if(pageCurrent == index) return;
setState(() {
pageCurrent = index;
});
},
),
),
// 自定义底部导航栏中间按钮
Positioned(
left: MediaQuery.of(context).size.width / 2 - 18,
top: 0,
bottom: 0,
child: InkWell(
...
),
),
],
),
),
);
}
}

import 'dart:io';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:get/get.dart';
import 'package:get_storage/get_storage.dart';
import 'package:intl/date_symbol_data_local.dart';
import 'package:shirne_dialog/shirne_dialog.dart';
import 'utils/common.dart';
// 引入布局页面
import 'layouts/index.dart';
// 引入路由配置
import 'router/index.dart';
void main() async {
// 初始化get_storage存储
await GetStorage.init();
// 初始化国际化语言
initializeDateFormatting('zh_CN');
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return AnnotatedRegion(
value: SystemUiOverlayStyle(
/**
* 修复flutter3.32以上会出现底部导航栏背景黑色
* The bottom navigation bar is always black from flutter: 3.32.1.
* It's working fine on flutter: 3.29.3
*/
systemNavigationBarColor: Colors.transparent,
systemNavigationBarIconBrightness: Brightness.dark,
),
child: GetMaterialApp(
title: 'Flutter3 Trip',
debugShowCheckedModeBanner: false,
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Color(0xffffaa00)),
useMaterial3: true,
// 修复windows下字体不一致情况
fontFamily: Platform.isWindows ? 'Microsoft YaHei' : null
),
home: const Layout(),
// 初始化路由
initialRoute: Common.isLogin() ? '/' : '/login',
// 路由页面
getPages: routePages,
// 初始化弹窗key
navigatorKey: MyDialog.navigatorKey,
),
);
}
}很多开发者反馈说是升级到Flutter最新版本。会出现手机端底部导航栏黑色背景情况。可以尝试如下方法解决。
AnnotatedRegion(
value: SystemUiOverlayStyle(
systemNavigationBarColor: Colors.transparent,
systemNavigationBarIconBrightness: Brightness.dark,
),
child: MaterialApp(
...
),
)



Flutter3.41实战AI:从零到一构建app版流式ai系统
Electron41 + Vite8打造流式输出客户端AI助手
Vite8.0+Vue3.5+Arco深度对接DeepSeek网页版AI智能助手
2026版開工新作uni-app+mphtml结合deepseek跨端ai应用
vite7.2-deepseek流式ai对话|vue3.5+vant4+katex+mermaid智能ai打字会话
最新实战Vite7.3+Tauri2.10深度集成DeepSeek桌面端AI智能助手
electron38-vite7-vue3os电脑端os管理系统
最新版electron38-vite7-admin电脑端中后台管理系统
Electron38+Vite7+Pinia3+ElementPlus客户端聊天程序
基于tauri2.8+vite7+vue3+element-plus仿QQ/微信聊天应用
tauri2.9-vite7-vue3admin客户端后台系统管理Exe模板
最新原创uniapp-vue3-osadmin手机版后台管理系统
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。