(三)最简 Flutter 实例 Hello Flutter

版权声明:本文为博主原创文章,转载文章须附上文章来源与作者。 https://blog.csdn.net/ChangerJJLee/article/details/88338396
import 'package:flutter/material.dart';

void main() => runApp(
    new Center(
      child: new Text(
        'Hello, world!',
        textDirection: TextDirection.ltr,
      ),
    ),
);
  • 运行效果
    在这里插入图片描述
  • 箭头函数

getUserInfo(name,  account){
  return name + ', ${account}';
}
// 等同于
getUserInfo(name,  account) => name+ ', $account' ; 
  • 该runApp函数接受给定的Center Widget并使其成为widget树的根。 ‘Hello, world!’ 会显示在Center其子widget下的Text。框架强制根widget覆盖整个屏幕,这意味着文本“Hello, world”会居中显示在屏幕上。文本显示的方向需要在Text实例中指定。

猜你喜欢

转载自blog.csdn.net/ChangerJJLee/article/details/88338396
今日推荐