增加导航,添加welcome按钮组

This commit is contained in:
ddshi 2025-01-22 20:10:11 +08:00
parent f66c0f247c
commit a8d6c2f07e
7 changed files with 98 additions and 30 deletions

7
.gitignore vendored
View File

@ -46,5 +46,8 @@ app.*.map.json
/android/app/release /android/app/release
.dart_tool .dart_tool
.fvm .vscode
.vscode
# FVM Version Cache
.fvm/
.fvmrc

View File

@ -36,3 +36,8 @@ samples, guidance on mobile development, and a full API reference.
- 在main中使用theme设置全局样式 - 在main中使用theme设置全局样式
- 在padding中使用edgeinsets.symmetric设置水平间距 - 在padding中使用edgeinsets.symmetric设置水平间距
- image中使用fit Boxfit来设置宽高适配 - image中使用fit Boxfit来设置宽高适配
## 导航,布局
- 从上到下,从左到右分析布局
- 写布局前先把结构列好用函数拆分用_bulid开头表示私有布局函数
- 在使用elevatedbutton时使用style将样式还原在外面套一层Container作为装饰更方便配置
- 使用Navigator.pushReplacement 替换路由

View File

@ -3,4 +3,5 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists
distributionUrl=file:///D:/Gradle/.gradle/wrapper/dists/gradle-6.7-all.zip distributionUrl=file:///C:/Users/24811/.gradle/wrapper/dists/gradle-6.7-all.zip
# distributionUrl=file:///D:/Gradle/.gradle/wrapper/dists/gradle-6.7-all.zip

View File

@ -1,6 +1,7 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'pages/welcome.dart'; import 'pages/splash.dart';
void main() { void main() {
runApp(const MyApp()); runApp(const MyApp());
@ -12,9 +13,11 @@ class MyApp extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return MaterialApp( return MaterialApp(
home: const WelcomePage(), home: const SplashPage(),
debugShowCheckedModeBanner: false, debugShowCheckedModeBanner: false,
theme: ThemeData( theme: ThemeData(
//
primarySwatch: Colors.orange,
fontFamily: 'Poppins', fontFamily: 'Poppins',
), ),
); );

View File

@ -1,6 +1,7 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import '../common/app_colors.dart'; import '../common/app_colors.dart';
import '../common/assets.dart'; import '../common/assets.dart';
import '../pages/Welcome.dart';
class SplashPage extends StatefulWidget { class SplashPage extends StatefulWidget {
const SplashPage({Key? key}) : super(key: key); const SplashPage({Key? key}) : super(key: key);
@ -30,6 +31,10 @@ class _SplashPageState extends State<SplashPage> {
if (number == 0) { if (number == 0) {
print('倒计时结束 '); print('倒计时结束 ');
Navigator.push(context, MaterialPageRoute(builder: (context) {
return const WelcomePage();
}));
} }
} }

View File

@ -5,6 +5,55 @@ import '../common/assets.dart';
class WelcomePage extends StatelessWidget { class WelcomePage extends StatelessWidget {
const WelcomePage({Key? key}) : super(key: key); const WelcomePage({Key? key}) : super(key: key);
//
Widget _bulidBtns() {
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 20),
child: Row(
children: [
//skip按钮
TextButton(
onPressed: () {},
child: const Text('Skip',
style: TextStyle(
fontSize: 15,
color: Color(0xff2B2A2A),
fontWeight: FontWeight.w300,
)),
),
//
const Spacer(),
//getstarted按钮
//Container
Container(
height: 42,
width: 139,
//
clipBehavior: Clip.antiAlias,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(32),
),
child: ElevatedButton(
onPressed: (() {}),
style: ButtonStyle(
elevation: MaterialStateProperty.all(0),
//0children尺寸
minimumSize: MaterialStateProperty.all(Size.zero)),
child: const Text('Get Started',
style: TextStyle(
fontSize: 16,
color: Colors.white,
fontWeight: FontWeight.w300,
)),
),
),
],
),
);
}
Padding _bulidText() { Padding _bulidText() {
return const Padding( return const Padding(
padding: EdgeInsets.symmetric(horizontal: 38), padding: EdgeInsets.symmetric(horizontal: 38),
@ -36,11 +85,13 @@ class WelcomePage extends StatelessWidget {
height: 300, height: 300,
// //
width: double.infinity, width: double.infinity,
fit: BoxFit.fitWidth), fit: BoxFit.fitWidth),
const SizedBox(
height: 70,
),
// //
Container(), _bulidBtns(),
//end //end
], ],

View File

@ -5,56 +5,56 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: async name: async
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.8.2" version: "2.8.2"
boolean_selector: boolean_selector:
dependency: transitive dependency: transitive
description: description:
name: boolean_selector name: boolean_selector
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.1.0" version: "2.1.0"
characters: characters:
dependency: transitive dependency: transitive
description: description:
name: characters name: characters
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.2.0" version: "1.2.0"
charcode: charcode:
dependency: transitive dependency: transitive
description: description:
name: charcode name: charcode
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.3.1" version: "1.3.1"
clock: clock:
dependency: transitive dependency: transitive
description: description:
name: clock name: clock
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.1.0" version: "1.1.0"
collection: collection:
dependency: transitive dependency: transitive
description: description:
name: collection name: collection
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.15.0" version: "1.15.0"
cupertino_icons: cupertino_icons:
dependency: "direct main" dependency: "direct main"
description: description:
name: cupertino_icons name: cupertino_icons
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.0.5" version: "1.0.4"
fake_async: fake_async:
dependency: transitive dependency: transitive
description: description:
name: fake_async name: fake_async
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.2.0" version: "1.2.0"
flutter: flutter:
@ -66,7 +66,7 @@ packages:
dependency: "direct dev" dependency: "direct dev"
description: description:
name: flutter_lints name: flutter_lints
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.0.4" version: "1.0.4"
flutter_test: flutter_test:
@ -78,35 +78,35 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: lints name: lints
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.0.1" version: "1.0.1"
matcher: matcher:
dependency: transitive dependency: transitive
description: description:
name: matcher name: matcher
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.12.11" version: "0.12.11"
material_color_utilities: material_color_utilities:
dependency: transitive dependency: transitive
description: description:
name: material_color_utilities name: material_color_utilities
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.1.3" version: "0.1.3"
meta: meta:
dependency: transitive dependency: transitive
description: description:
name: meta name: meta
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.7.0" version: "1.7.0"
path: path:
dependency: transitive dependency: transitive
description: description:
name: path name: path
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.8.0" version: "1.8.0"
sky_engine: sky_engine:
@ -118,56 +118,56 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: source_span name: source_span
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.8.1" version: "1.8.1"
stack_trace: stack_trace:
dependency: transitive dependency: transitive
description: description:
name: stack_trace name: stack_trace
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.10.0" version: "1.10.0"
stream_channel: stream_channel:
dependency: transitive dependency: transitive
description: description:
name: stream_channel name: stream_channel
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.1.0" version: "2.1.0"
string_scanner: string_scanner:
dependency: transitive dependency: transitive
description: description:
name: string_scanner name: string_scanner
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.1.0" version: "1.1.0"
term_glyph: term_glyph:
dependency: transitive dependency: transitive
description: description:
name: term_glyph name: term_glyph
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.2.0" version: "1.2.0"
test_api: test_api:
dependency: transitive dependency: transitive
description: description:
name: test_api name: test_api
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.4.8" version: "0.4.8"
typed_data: typed_data:
dependency: transitive dependency: transitive
description: description:
name: typed_data name: typed_data
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.3.0" version: "1.3.0"
vector_math: vector_math:
dependency: transitive dependency: transitive
description: description:
name: vector_math name: vector_math
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.1.1" version: "2.1.1"
sdks: sdks: