Giter Club home page Giter Club logo

xuexiangjys / flutter_template Goto Github PK

View Code? Open in Web Editor NEW
889.0 30.0 181.0 148 KB

The project of the empty template with Flutter has built the basic framework to realize the functions of internationalization, theme peeling, login and registration, etc.(Flutter空壳模板工程,已搭建基础框架,实现国际化、主题换肤、登录注册、自动路由注册等功能,可在此基础上简单修改实现自己的应用功能)

Home Page: https://github.com/xuexiangjys/flutter_template/wiki

License: Apache License 2.0

Kotlin 0.38% Ruby 1.21% Swift 0.36% Objective-C 0.03% Dart 98.01%
template flutter x-templateproject template-project flutter-template

flutter_template's Introduction

flutter_template

Flutter空壳模板工程,已搭建基础框架,实现国际化、主题换肤、登录注册等功能,可在此基础上简单修改实现自己的应用功能。

关于我

公众号 掘金 知乎 CSDN 简书 思否 哔哩哔哩 今日头条
我的Android开源之旅 点我 点我 点我 点我 点我 点我 点我

效果

flutter_template.gif

Star趋势图

Stargazers over time

视频教程

运行

  • 查看一下版本号是否正确, 要求flutter的版本是2.x.x的版本。
flutter --version

这里推荐的flutter版本为2.0.6, 下载地址如下:

【注意】 如果你的flutter版本是1.x.x版本,那么请将你的flutter版本进行升级,或者使用flutter/1.0的分支。

  • 运行以下命令查看是否需要安装其它依赖项来完成安装
flutter doctor
  • 运行启动您的应用
flutter packages get 
flutter run

项目集成介绍

本项目精选了目前Flutter最实用的几个库,可大大提高开发的效率。

使用指南

1.克隆项目

git clone https://github.com/xuexiangjys/flutter_template.git

2.修改项目名(文件夹名),并删除目录下的.git文件夹(隐藏文件)

3.使用AS或者VSCode打开项目,然后分别修改flutter、Android、ios项目的包名、应用ID以及应用名等信息。

最简单的替换方法就是进行全局替换,搜索关键字flutter_template,然后替换你想要的项目包名,如下图所示:

flutter_replace.png

Flutter目录修改

  • 修改项目根目录pubspec.yaml文件, 修改项目名、描述、版本等信息。

flutter_1.png

【注意】这里修改完pubspec.yaml中的name属性后,flutter项目的包名将会修改,这里我推荐大家使用全局替换的方式修改比较快。例如我想要修改nameflutter_app,在VSCode中你可以选择lib文件夹之后右击,选择在文件夹中寻找, 进行全局替换:

flutter_2.png

  • 修改lib/core/http/http.dart中的网络请求配置,包括:服务器地址、超时、拦截器等设置

  • 修改lib/core/utils/privacy.dart中隐私服务政策地址

  • 修改lib/core/utils/xupdate.dart中版本更新检查的地址

Android目录修改

  • 修改android目录下的包名。

在VSCode中你可以选择android文件夹之后右击,选择在文件夹中寻找, 进行全局替换。

android_1.png

【注意】修改包名之后,记住需要将存放MainActivity.kt类的文件夹名也一并修改,否则将会找不到类。

  • 修改应用ID。修改android/app/build.gradle文件中的applicationId

  • 修改应用名。修改android/app/src/main/res/values/strings.xml文件中的app_name

IOS目录修改

ios修改相对简单,直接使用XCode打开ios目录进行修改即可。如下图所示:

ios_1.jpeg

ios_2.png

更新插件版本

flutter packages upgrade
flutter pub outdated
flutter pub upgrade --major-versions

如果觉得项目还不错,可以考虑打赏一波

你的打赏是我维护的动力,我将会列出所有打赏人员的清单在下方作为凭证,打赏前请留下打赏项目的备注!

pay.png

微信公众号

更多资讯内容,欢迎扫描关注我的个人微信公众号:【我的Android开源之旅】

gzh_weixin.jpg

flutter_template's People

Contributors

shiyu-sz avatar xuexiangjys avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

flutter_template's Issues

auto_route版本

可以将auto_route更新至2.0.1么 这个版本有大的支持
Navigator也从1升级到了2

项目启动时遇到的一个问题

运行flutter run 时,报错信息如下

fatal error: 'Flutter/Flutter.h' file not found
#import <Flutter/Flutter.h>
^~~~~~~~~~~~~~~~~~~
1 error generated.

请问您有遇到过类似的情况吗?有的话麻烦和我说一下解决办法,谢谢

一个问题和一个建议

作者辛苦了。

1、请问i18n是用哪个插件完成的?能不能添加一下增加语言、增加翻译后如果生成更新文件?

2、建议再出一个增强版。新项目一般都还需要 相机、定位、扫码、指纹 这四个权限,如果能增加到增强版中去,配置好Android和iOS的插件权限,这个项目一定大货喜欢。

windows下安卓模拟器语言检测错误null问题

更改后代码

// 获取当前用户的APP语言配置Locale类,如果为null,则语言跟随系统语言
  Locale getLocale() {
    if (_locale == null) return null;
    if (_locale.indexOf("_") > 0) {
      var t = _locale.split("_");
      return Locale(t[0], t[1]);
    } else {
      return null;
    }
  }

代码中为字符判断,会报错。

auto_route生成的代码会出现语法错误

image

引入 getTransitions的时候 前面会比示例中多一个点。
我是克隆的2.0分支

命令是 flutter packages pub run build_runner watch --delete-conflicting-outputsflutter packages pub run build_runner build 两个效果是一样的都多一个点

Build failed due to use of deprecated Android v1 embedding.

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Warning
──────────────────────────────────────────────────────────────────────────────
Your Flutter application is created using an older version of the Android
embedding. It is being deprecated in favor of Android embedding v2. Follow the
steps at

https://flutter.dev/go/android-project-migration

to migrate your project. You may also pass the --ignore-deprecation flag to
ignore this check and continue with the deprecated v1 embedding. However,
the v1 Android embedding will be removed in future versions of Flutter.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
The detected reason was:

C:\flutter_template-master\android\app\src\main\AndroidManifest.xml uses android:name="io.flutter.app.FutterApplication"
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Build failed due to use of deprecated Android v1 embedding.

在 Flutter 2.0.1 环境中运行,会有异常,看起来是语法的不兼容

/D:/service/flutter/.pub-cache/hosted/pub.flutter-io.cn/extended_image-1.6.0/lib/src/extended_image.dart:785:44: Error: No named parameter with the name 'nullOk'.
_invertColors = MediaQuery.of(context, nullOk: true)?.invertColors ??
^^^^^^
/D:/service/flutter/packages/flutter/lib/src/widgets/media_query.dart:818:25: Context: Found this candidate, but the arguments don't match.
static MediaQueryData of(BuildContext context) {

报错需要migrate this app to the V2 embedding

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
━━━━━━━━━━━━━━━━━━
Warning
────────────────────────────────────────────────────────────
──────────────────
Your Flutter application is created using an older version
of the Android
embedding. It is being deprecated in favor of Android
embedding v2. Follow the
steps at

https://flutter.dev/go/android-project-migration

to migrate your project. You may also pass the
--ignore-deprecation flag to
ignore this check and continue with the deprecated v1
embedding. However,
the v1 Android embedding will be removed in future versions
of Flutter.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
━━━━━━━━━━━━━━━━━━
The detected reason was:

/Users/jiashaoying/github_projects/flutter_template/androi
d/app/src/main/AndroidManifest.xml uses
android:name="io.flutter.app.FutterApplication"
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
━━━━━━━━━━━━━━━━━━

Running "flutter pub get" in flutter_template... 5.1s
This app is using a deprecated version of the Android
embedding.
To avoid unexpected runtime failures, or future build
failures, try to migrate this app to the V2 embedding.
Take a look at the docs for migrating an app:
https://github.com/flutter/flutter/wiki/Upgrading-pre-1.12-A
ndroid-projects
The plugin package_info_plus requires your app to be
migrated to the Android embedding v2. Follow the steps on
https://flutter.dev/go/android-project-migration and re-run
this command.

抽屉菜单昵称像素移除问题

                  Text(
                        value.nickName != null
                            ? value.nickName
                            : I18n.of(context).title,
                        overflow: TextOverflow.ellipsis,
                        style: TextStyle(
                          fontWeight: FontWeight.bold,
                          fontSize: 20,
                          color: Colors.white,
                        ),
                      )

昵称过长会像素溢出,请用expand包裹下

No named parameter with the name 'nullOk'.

Launching lib/main.dart on macOS in debug mode...
lib/main.dart:1
../.pub-cache/hosted/pub.flutter-io.cn/extended_image-1.6.0/lib/src/extended_image.dart:785:44: Error: No named parameter with the name 'nullOk'.
_invertColors = MediaQuery.of(context, nullOk: true)?.invertColors ??
^^^^^^
../flutter/packages/flutter/lib/src/widgets/media_query.dart:818:25: Context: Found this candidate, but the arguments don't match.
static MediaQueryData of(BuildContext context) {
^^

Command PhaseScriptExecution failed with a nonzero exit code

note: Using new build system
note: Building targets in parallel
note: Planning build
note: Constructing build description
** BUILD FAILED **

Exception: Build process failed
Exited (sigterm)

The parameter 'exception' is required

在app_init.dart文件里

// 构建错误信息
static FlutterErrorDetails makeDetails(Object obj, StackTrace stack) {
return FlutterErrorDetails();//这句话有问题
}

编译报错如下:
The parameter 'exception' is required.

应该怎么改呢

运行失败?是Grade问题吗?

Exception in thread "main" java.util.zip.ZipException: zip END header not found
at java.base/java.util.zip.ZipFile$Source.zerror(ZipFile.java:1567)
at java.base/java.util.zip.ZipFile$Source.findEND(ZipFile.java:1462)
at java.base/java.util.zip.ZipFile$Source.initCEN(ZipFile.java:1469)
at java.base/java.util.zip.ZipFile$Source.(ZipFile.java:1274)
at java.base/java.util.zip.ZipFile$Source.get(ZipFile.java:1237)
at java.base/java.util.zip.ZipFile$CleanableResource.(ZipFile.java:727)
at java.base/java.util.zip.ZipFile$CleanableResource.get(ZipFile.java:844)
at java.base/java.util.zip.ZipFile.(ZipFile.java:247)
at java.base/java.util.zip.ZipFile.(ZipFile.java:177)
at java.base/java.util.zip.ZipFile.(ZipFile.java:191)
at org.gradle.wrapper.Install.unzip(Install.java:214)
at org.gradle.wrapper.Install.access$600(Install.java:27)
at org.gradle.wrapper.Install$1.call(Install.java:74)
at org.gradle.wrapper.Install$1.call(Install.java:48)
at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAccessManager.java:65)
at org.gradle.wrapper.Install.createDist(Install.java:48)
at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:128)
at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:61)
Exception: Gradle task assembleDebug failed with exit code 1

Support flutter_easyrefresh

The newest flutter_easyrefresh drop i18n suppport, and I am not familar with the i18n support.

So could you please support it? Thanks
image

flutter_webview_plugin和image_picker_saver需要移除

The plugins flutter_webview_plugin, image_picker_saver use a deprecated version
of the Android embedding.
To avoid unexpected runtime failures, or future build failures, try to see if these
plugins support the Android V2 embedding. Otherwise, consider removing them since a
future release of Flutter will remove these deprecated APIs.
If you are plugin author, take a look at the docs for migrating the plugin to the
V2 embedding: https://flutter.dev/go/android-plugin-migration.

几个问题,i18n是怎么做的,用的AS插件吗

i18n是怎么做的,用的AS插件吗。

项目改名可以,不用搜索,重新改了项目名称,删除ios android web 文件夹,重新flutter create . 也可以。

  • package 里面的需要查找替换改名。

The plugins `flutter_webview_plugin, image_picker_saver` use a deprecated version of the Android embedding.

The plugins flutter_webview_plugin, image_picker_saver use a deprecated version of the Android embedding.
To avoid unexpected runtime failures, or future build failures, try to see if these plugins support the Android V2 embedding. Otherwise, consider removing them since a future release of Flutter will remove these deprecated APIs.
If you are plugin author, take a look at the docs for migrating the plugin to the V2 embedding: https://flutter.dev/go/android-plugin-migration.

Build failed due to use of deprecated Android v1 embedding.

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Warning
──────────────────────────────────────────────────────────────────────────────
Your Flutter application is created using an older version of the Android
embedding. It is being deprecated in favor of Android embedding v2. Follow the
steps at

https://flutter.dev/go/android-project-migration

to migrate your project. You may also pass the --ignore-deprecation flag to
ignore this check and continue with the deprecated v1 embedding. However,
the v1 Android embedding will be removed in future versions of Flutter.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
The detected reason was:

/Users/meichao/DeveloperTools/FlutterProjects/flutter_template/android/app/src/main/AndroidManifest.xml uses android:name="io.flutter.app.FutterApplication"
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Build failed due to use of deprecated Android v1 embedding.

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.