简体   繁体   English

如何在Flutter中创建此布局?

[英]How to create this layout in Flutter?

I'm re-writing my application written in Kotlin for Android to Flutter, but I am struggling to re-create layout in Flutter. 我正在将用Kotlin for Android编写的应用程序重新编写为Flutter,但我正在努力重新在Flutter中创建布局。

Look at this image: 看这张图: 应用程式

This is a screenshot from the application I wrote in Native Android. 这是我在Native Android中编写的应用程序的屏幕截图。

I somehow re-created this layout in Flutter, but I have problem with alignment. 我以某种方式在Flutter中重新创建了此布局,但是对齐出现问题。

This is a screenshot from my Flutter app: 这是我的Flutter应用程序的屏幕截图:

汉堡包

I want the text "Jak używać?" 我要输入“ Jakużywać”吗? to be at start, but I don't know how to do it. 一开始,但我不知道该怎么做。

If only the Container widget had "children" instead of "child", I'd know how to do it. 如果只有“容器”小部件具有“子项”而不是“子项”,那么我会知道该怎么做。

Can someone help me re-create the layout? 有人可以帮我重新创建布局吗?

I would be extremely glad, if someone helped me! 如果有人帮助我,我将非常高兴!

My code (I didn't give the whole code, because there's no need to.): 我的代码(我没有给出完整的代码,因为没有必要。):

import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';

class HowToUse extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Container(
      padding: EdgeInsets.only(top: 16.0),
      child: Column(
        children: <Widget>[
          SvgPicture.asset('assets/icons/hamburger.svg', semanticsLabel: 'hamburger', height: 90.0,),
          SizedBox(height: 16.0),
          Text('Makdolan Flutter', style: Theme.of(context).textTheme.title),
          SizedBox(height: 16.0),
          Text('Jak używać?')
        ],
      ),
    );
  }
}

You need to make the Text widget width the same as your screen width. 您需要使“ Text小部件的宽度与屏幕宽度相同。 Therefore, when you change the alignment of that Text widget inner text you will see a difference. 因此,当您更改“ Text小部件内部文本的对齐方式时,您会发现有所不同。

Try wrapping your Text widget with a container with the screen width: 尝试用屏幕宽度的容器包装Text小部件:

Container(
     width: MediaQuery.of(context).size.width,
     child: Text('Jak używać?', textAlign: TextAlign.start,),
)

Edit: 编辑:

Also if the content of each tab is static page consider making them normal HTML pages and view then in the app using this flutter_html package 另外,如果每个标签的内容都是静态页面,请考虑将其设置为普通HTML页面,然后使用此flutter_html包在应用程序中查看

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM