Code Monkey home page Code Monkey logo

flutter_app's Introduction

flutter_app

A new Flutter application.

Getting Started

For help getting started with Flutter, view our online documentation.

添加或更新依赖

查找packages

dependencies:
	  flutter:
	    sdk: flutter
	
	  # The following adds the Cupertino Icons font to your application.
	  # Use with the CupertinoIcons class for iOS style icons.
	  cupertino_icons: ^0.1.2
	  english_words: ^3.1.0
	
	dev_dependencies:
	  flutter_test:
	    sdk: flutter

语法结构类似kotlin

入口类:

./libs/main.dart 是app的主入口

导包:

import 'package:english_words/english_words.dart'

创建包名路径:

1、在lib下创建views目录 2、在views目录下dart文件类,如Deatil.dart 3、在main.dart下导包

	import './views/detail.dart' as DetailAs;

在main.dart下引入代码,必须使用 在类名前 as . 类名

	new DetailAs.Detail();

flutter 系统组件分两种:

  • 1、StatelessWidget 不可自定义组件

  • 2、StatefulWidget 可自定义组件

    个人理解 StatelessWidget是运行时不可动态改变属性的组件,StatefulWidget是运行时可以动态调整的组件。

自定义StatefulWidget组件需要继承StatefulWidget, 需要重载createState方法并返回State对象,State,State类似一个空的activity,需要往里面填充UI组件

  • 3 常见的UI组件

      const Text(this.data, {
          Key key,
          this.style,
          this.textAlign,
          this.textDirection,
          this.softWrap,
          this.overflow,
          this.textScaleFactor,
          this.maxLines,
    	})
    
        const Icon(this.icon, {
          Key key,
          this.size,
          this.color,
          this.semanticLabel,
          this.textDirection,
        })
    
         AppBar({
          Key key,
          this.leading,
          this.automaticallyImplyLeading: true,
          this.title,
          this.actions,
          this.flexibleSpace,
          this.bottom,
          this.elevation: 4.0,
          this.backgroundColor,
          this.brightness,
          this.iconTheme,
          this.textTheme,
          this.primary: true,
          this.centerTitle,
          this.titleSpacing: NavigationToolbar.kMiddleSpacing,
          this.toolbarOpacity: 1.0,
          this.bottomOpacity: 1.0,
        }
    
        ListView.builder({
          Key key,
          Axis scrollDirection: Axis.vertical,
          bool reverse: false,
          ScrollController controller,
          bool primary,
          ScrollPhysics physics,
          bool shrinkWrap: false,
          EdgeInsetsGeometry padding,
          this.itemExtent,
          @required IndexedWidgetBuilder itemBuilder,
          int itemCount,
          bool addAutomaticKeepAlives: true,
          bool addRepaintBoundaries: true,
          double cacheExtent,
        })
      	......
    

    以上列举的UI组件都继承StatelessWidget,都继承了父类StatelessWidget,这个Key就是tap事件方法,类似android中的View的SetOnClickListner()方法,

    复杂布局需要熟悉flutter的横向布局row和纵向布局cloumn

    • 4 跳转:

          Navigator.of(context).push(
          new MaterialPageRoute(
            builder: (context) {
              return new DetailAs.Detail();
            },
          ),
        );
      
      
          Navigator.pop(context);
      

    这个命名有没有和ios API很像?

    5 、网络

    6、 row

    7、 cloumn

    8、截图:

    net news list

    net news detail

    todo 新闻详情页富文本

    未(you)完(kong)待(zai)续(shuo)

flutter_app's People

Watchers

James Cloos avatar

Forkers

cpvhunter

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.