在顯示代碼之前,我檢查了以下內容以避免類似的答案:
安卓:extratNativeLibs="true"
Jsonfile firebase 已連接
routegenerator 和 initialroute 在主檔案和
generatorfile中檢查
.我喜歡避免使用 mediaQuery 并使用百分比,這就是我使用 FractionallySizedBox 的原因。這是初始路線的代碼:
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
class Start extends StatelessWidget {
const Start({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
body: Align(
alignment: Alignment.center,
child: Center(
child: Column(mainAxisSize: MainAxisSize.min, children: <Widget>[
FractionallySizedBox(widthFactor: 0.15, heightFactor: 0.15, child: Image.asset('assets/crown.png')),
FractionallySizedBox(
widthFactor: 0.40,
heightFactor: 0.20,
child: TextButton(
onPressed: () {
Navigator.of(context).pushNamed('/items');
},
child: Container(
decoration: BoxDecoration(color: Colors.purple),
child: Row(mainAxisSize: MainAxisSize.min, children: <Widget>[
const Text('Start shopping',
style: TextStyle(
color: Colors.white,
fontStyle: FontStyle.italic,
fontSize: 25,
)),
Image.asset('assets/crown.png')
]))))
])))));
}
}
uj5u.com熱心網友回復:
扭曲你FractionallySizedBox的Expanded
Expanded(
child: FractionallySizedBox(
widthFactor: 0.15,
heightFactor: 0.15,
child: Image.asset('assets/crown.png')),
),
Expanded(
child: FractionallySizedBox(
widthFactor: 0.40,
heightFactor: 0.20,
child: TextButton(
onPressed: () {
Navigator.of(context).pushNamed('/items');
},
child: Container(
decoration: BoxDecoration(color: Colors.purple),
child: Row(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
const Text('Start shopping',
style: TextStyle(
color: Colors.white,
fontStyle: FontStyle.italic,
fontSize: 25,
)),
Image.asset('assets/crown.png')
],
),
),
),
),
),
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/478346.html
上一篇:如何在perform_create中使用Validator來限制DjangoRestFramework的影像上傳大小?
