flutter实战项目01 基本资源和目录结构

一,资源
引入插件包pubspec.yaml

dependencies:
  flutter:
    sdk: flutter
  cupertino_icons: ^0.1.2
  dio: ^2.0.7//异步请求
  flutter_swiper: ^1.1.4//轮播
  flutter_screenutil: ^0.5.1//尺寸适配
  flutter_easyrefresh: ^1.2.7//下拉刷新
  provide: ^1.0.2//状态管理
  url_launcher: ^5.0.1
  fluttertoast: ^3.0.1
  fluro: ^1.4.0
  flutter_html: ^0.9.6
  sqflite: ^1.1.0
  shared_preferences: ^0.5.1
//静态资源引入 一般使用远程图片 本地资源需要每次重启才能加载
  assets:
   - assets/images/logo.png

二,目录结构

config//配置
---color.dart//配置网站颜色
---font.dart//字体
---http_conf.dart//http服务
---string.dart//配置网站文字
---index.dart//导入上面所有文件 引入时就只引入这个文件
model//模型
pages//页面
provide//状态
routers//路由
service//服务

3基本使用
color.dart

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

class KeyColor{
  static const Color primayColor = Color.fromRGBO(132, 95, 63, 1.0);//默认主题颜色
}

http_conf.dart

const base_url = "https://www.fastmock.site/mock/18e030d9e667d42b22dc9abd9637b30b/flutter";
const servicePath = {
  "homePageServer": base_url + '/indexPage'
};

string.dart

class KeyString{
  static const String mainTitle = "flutter商城";
  static const String homeTitle = "首页";
  static const String category = "分类";
  static const String shopping_cart = "购物车";
  static const String person = "会员中心";
}

你可能感兴趣的:(Flutter)