如何为不同的设备设置相同的小部件位置?
How Can i set same position of widgets for different device?
Hi to Everyone. I am setting position of icon widget. But it is
changing on different device. How can i fix it? thanks in advance.
> -------------------------------------- ---------------------------------------------- ---------------------------------------------- --------------------------------------------
[for example][1]
import 'package:flutter/material.dart';
import 'package:country_icons/country_icons.dart';
class E_Takvim_Container extends StatefulWidget {
const E_Takvim_Container({Key key}) : super(key: key);
@override
_E_Takvim_ContainerState createState() => _E_Takvim_ContainerState();
}
class _E_Takvim_ContainerState extends State<E_Takvim_Container> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Takvim"),
backgroundColor: Colors.amber,
),
body: IntrinsicHeight(
child: Container(
child: Column(
children: [
Card(
child: Row(
children: [
Container(
width: 30,
height: 30,
margin: EdgeInsets.all(10),
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage(
'icons/flags/png/de.png',
package: 'country_icons',
),
),
borderRadius:
BorderRadius.all(Radius.elliptical(300, 900))),
),
Text(
"Tüketici Fiyat Endeksi",
style: TextStyle(fontWeight: FontWeight.bold,fontSize: 17),
),
Padding(
padding: const EdgeInsets.only(left:100.0),
child: Icon(Icons.arrow_forward_ios),
)
],
),
),
],
),
),
),
);
}
}
[1]: https://i.stack.imgur.com/nIzkv.png
对于您的代码示例,您可以将 Expanded
用于 TextView
小部件。
Expanded(
flex: 1,
child: Text(
"Tüketici Fiyat Endeksi",
style: TextStyle(fontWeight: FontWeight.bold,fontSize: 17),
),
)
如果你想在不同的屏幕分辨率下获得相同的结果,(例如:小部件的大小或字体大小)你可以看一下包:ScreenUtils
Hi to Everyone. I am setting position of icon widget. But it is changing on different device. How can i fix it? thanks in advance.
> -------------------------------------- ---------------------------------------------- ---------------------------------------------- --------------------------------------------
[for example][1]
import 'package:flutter/material.dart';
import 'package:country_icons/country_icons.dart';
class E_Takvim_Container extends StatefulWidget {
const E_Takvim_Container({Key key}) : super(key: key);
@override
_E_Takvim_ContainerState createState() => _E_Takvim_ContainerState();
}
class _E_Takvim_ContainerState extends State<E_Takvim_Container> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Takvim"),
backgroundColor: Colors.amber,
),
body: IntrinsicHeight(
child: Container(
child: Column(
children: [
Card(
child: Row(
children: [
Container(
width: 30,
height: 30,
margin: EdgeInsets.all(10),
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage(
'icons/flags/png/de.png',
package: 'country_icons',
),
),
borderRadius:
BorderRadius.all(Radius.elliptical(300, 900))),
),
Text(
"Tüketici Fiyat Endeksi",
style: TextStyle(fontWeight: FontWeight.bold,fontSize: 17),
),
Padding(
padding: const EdgeInsets.only(left:100.0),
child: Icon(Icons.arrow_forward_ios),
)
],
),
),
],
),
),
),
);
}
}
[1]: https://i.stack.imgur.com/nIzkv.png
对于您的代码示例,您可以将 Expanded
用于 TextView
小部件。
Expanded(
flex: 1,
child: Text(
"Tüketici Fiyat Endeksi",
style: TextStyle(fontWeight: FontWeight.bold,fontSize: 17),
),
)
如果你想在不同的屏幕分辨率下获得相同的结果,(例如:小部件的大小或字体大小)你可以看一下包:ScreenUtils