Flutter-3创建项目

1.打开vscode ,安装dart  flutter 插件

2.File  open Floder打开项目根目录,不溶于andriod studio骑在android目录

3.终端运行 flutter run -d all    修改内容之后重新run  输入r即可,输入大R表示热重启

按下p键显示网格,以便于布局,网格出现,要等一会

     o:切换android和ios模式,感觉标题位置不同

   q或  ctrl+c 退出

flutter devices :看当前有多少设备

flutter提示工具

创建flutter项目

推荐使用andoird studio,可以指定包名,命令行则自动生成包名

ios等只能找到要创建的目录输入 flutter create flutter02     ,然后通过Xcode修改包名

进入目录,输入 vscode .  打开vscode

主要关注lib目和pubspec.yaml中的依赖,其余不必在意

重写main.dart

import 'package:flutter/material.dart';   //输入importm快捷引入
void main() {
  runApp(const Center(  //注意const加上意义是只有一份,也可以不加,会有语法检查提示
      child: Text("你好, www.i7i8i9.com",textDirection: TextDirection.ltr,),  //因为Center加const,这里可以不加


  ));//runApp是flutter的入口方法,参数是组件,也就是类
}

查看Text属性

String this.data是构造函数所需要传入的数据,{}内是命名参数

  const Text(
    String this.data, {    //
    super.key,
    this.style,
    this.strutStyle,
    this.textAlign,
    this.textDirection,
    this.locale,
    this.softWrap,
    this.overflow,
    this.textScaleFactor,
    this.maxLines,
    this.semanticsLabel,
    this.textWidthBasis,
    this.textHeightBehavior,
    this.selectionColor,
  }) : assert(

 最基本构成

     MaterialApp(   //MaterialApp所有组件的根组件

    其命名参数home下一定放Scaffold组件,其里面再放appBar body

import 'package:flutter/material.dart';

void main() {

  runApp(MaterialApp(   //MaterialApp所有组件的根组件

    home:Scaffold(

      appBar: AppBar(title:const Text("www.i7i8i9.com") ), //title是widget类型,所以后面要加Text

     

      body: const Center(  //注意const加上意义是只有一份,也可以不加,会有语法检查提示

              child: Text("你好, www.i7i8i9.com",textDirection: TextDirection.ltr,//这个都可以通过构造函数分析

              style:TextStyle( //TextStyle是一个类,通过命名函数传值

              color: Colors.red,

              // color:Color.fromRGBO(244,244, 122, 1),

                fontSize: 40,



      ),),  //因为Center加const,这里可以不加




  )

     

      ,)




  ));

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值