图片自适应
@ -32,3 +32,7 @@ samples, guidance on mobile development, and a full API reference.
|
|||||||
- 使用future.delayed实现倒计时,注意使用async
|
- 使用future.delayed实现倒计时,注意使用async
|
||||||
- 使用三目运算符控制显示
|
- 使用三目运算符控制显示
|
||||||
- 将相同组件抽出
|
- 将相同组件抽出
|
||||||
|
## 图片自适应
|
||||||
|
- 在main中使用theme设置全局样式
|
||||||
|
- 在padding中使用edgeinsets.symmetric设置水平间距
|
||||||
|
- image中,使用fit Boxfit来设置宽高适配
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 18 KiB |
BIN
assets/images/2.0x/welcome.png
Normal file
|
After Width: | Height: | Size: 135 KiB |
|
Before Width: | Height: | Size: 36 KiB After Width: | Height: | Size: 36 KiB |
BIN
assets/images/3.0x/welcome.png
Normal file
|
After Width: | Height: | Size: 256 KiB |
@ -1 +1,2 @@
|
|||||||
static const logo_3xPng = 'assets/images/logo@3x.png';
|
static const logoPng = 'assets/images/logo.png';
|
||||||
|
static const welcomePng = 'assets/images/welcome.png';
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 7.1 KiB After Width: | Height: | Size: 7.1 KiB |
BIN
assets/images/welcome.png
Normal file
|
After Width: | Height: | Size: 54 KiB |
@ -1,4 +1,4 @@
|
|||||||
class AssetsImages{
|
class AssetsImages {
|
||||||
static const logopang = 'assets/images/logo@3x.png';
|
static const logoPng = 'assets/images/logo.png';
|
||||||
|
static const welcomePng = 'assets/images/welcome.png';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import 'pages/splash.dart';
|
import 'pages/welcome.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
runApp(const MyApp());
|
runApp(const MyApp());
|
||||||
@ -11,9 +11,12 @@ class MyApp extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return const MaterialApp(
|
return MaterialApp(
|
||||||
home: SplashPage(),
|
home: const WelcomePage(),
|
||||||
debugShowCheckedModeBanner: false,
|
debugShowCheckedModeBanner: false,
|
||||||
|
theme: ThemeData(
|
||||||
|
fontFamily: 'Poppins',
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -57,7 +57,7 @@ class _SplashPageState extends State<SplashPage> {
|
|||||||
|
|
||||||
//上层图片
|
//上层图片
|
||||||
Image.asset(
|
Image.asset(
|
||||||
AssetsImages.logopang,
|
AssetsImages.logoPng,
|
||||||
width: 84,
|
width: 84,
|
||||||
height: 80,
|
height: 80,
|
||||||
)
|
)
|
||||||
@ -71,7 +71,7 @@ class _SplashPageState extends State<SplashPage> {
|
|||||||
text,
|
text,
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
fontSize: 19,
|
fontSize: 19,
|
||||||
fontFamily: 'Poppins',
|
// fontFamily: 'Poppins',
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
height: 22 / 19,
|
height: 22 / 19,
|
||||||
|
|||||||
56
lib/pages/welcome.dart
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import '../common/assets.dart';
|
||||||
|
|
||||||
|
class WelcomePage extends StatelessWidget {
|
||||||
|
const WelcomePage({Key? key}) : super(key: key);
|
||||||
|
|
||||||
|
Padding _bulidText() {
|
||||||
|
return const Padding(
|
||||||
|
padding: EdgeInsets.symmetric(horizontal: 38),
|
||||||
|
child: Text(
|
||||||
|
'Browse & Oder All Products at Any Time',
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 20,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
color: Color(0xff2B2A2A),
|
||||||
|
height: 23 / 20,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildView() {
|
||||||
|
return Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
//标题
|
||||||
|
_bulidText(),
|
||||||
|
|
||||||
|
const SizedBox(
|
||||||
|
height: 70,
|
||||||
|
),
|
||||||
|
|
||||||
|
//图片
|
||||||
|
Image.asset(AssetsImages.welcomePng,
|
||||||
|
height: 300,
|
||||||
|
//宽撑满
|
||||||
|
width: double.infinity,
|
||||||
|
|
||||||
|
fit: BoxFit.fitWidth),
|
||||||
|
|
||||||
|
//按钮组
|
||||||
|
Container(),
|
||||||
|
|
||||||
|
//end
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
body: Center(child: _buildView()),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||