赞
踩
- //导入了Material UI组件库 ,快捷操作fim
- import 'package:flutter/material.dart';
- void main(){
- runApp(MyApp());
- }
- //自定义组件
- //StatelessWidget:无状态组件,状态不可变的widget
- //StatefulWidget:有状态组件,状态可以改变
- //fluter中一切都是组件
- //使用MaterialApp和Scaffold 两个组件装饰App
- //MaterialApp一般作为根组件----home、title、color、theme、routes等
- class MyApp extends StatelessWidget{
- @override
- Widget build(BuildContext context) {
- return MaterialApp(
- home: Scaffold(
- //标题栏
- appBar: AppBar(
- title: Text("Flutter Demo"),
- ),
- //内容区域
- body: HomeContent(),
- ),
- //主题
- theme: ThemeData(
- primarySwatch: Colors.red
- ),
- );
- }
- }
-
- class HomeContent extends StatelessWidget{
- @override
- Widget build(BuildContext context) {
- return Center(
- //定义一个容器Container
- child: Container(
- //加载网络图片
- height: 300.0,
- width: 300.0,
- decoration: BoxDecoration(
- color: Colors.yello
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。