點樣 Flutter 改 web title,唔洗眨呀眨?
Mar 24, 2024
我哋一齊睇睇個問題:
其實都冇乜嘢,只係個 title 會閃咗一啲唔係我哋 app title 嘅嘢。話礙眼唔礙眼,我哋都試下改下。
FYI,原本嘅 app title 坐落喺我哋嘅 MaterialApp:
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo', // 呢度
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
useMaterial3: true,
),
home: Scaffold(
appBar: AppBar(
title: const Text('Flutter Demo'),
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
),
body: const Center(
child: Text('The Next Big Thing'),
),
),
);
}
}
咁我哋既然要改 web,就要去翻 web/index.html,<head> 入面有一行 <title>:
<head>
<!-- ... -->
<title>medium_tutorials</title>
<!-- ... -->
</head>
改翻我哋想要嘅 title,就搞掂,好似咁。
<head>
<!-- ... -->
<title>Flutter Demo</title>
<!-- ... -->
</head>
多謝收睇。
下次再同大家講下我哋可以點樣改 icon,再講下點樣改 splash screen。
下次見 👋。