The cat said
Sometimes we need to hide sensitive information in the project, such as your Ali OSS account AccessKey, which is very dangerous to upload into the code to the Git repository, so we need to use the scheme of environment variables to hide it. Remember to add your.env files to the.gitignore file for filtering.
Be sure to retweet brother for more Flutter posts at ~~~~
Ducafecat WeChat group
The body of the
I’m glad to be writing about this topic, because this is an area of which mobile application developers must have little or known knowledge.
As an app developer, developing and deploying apps on the Google game store or the Apple Store doesn’t mean you’ve run out of mobile app development cycles.
The mobile application development cycle also includes improving application security.
That’s why I’m sharing this article so that you’ll learn how to hide sensitive security keys in your Flutter application.
At the end of this article, you’ll learn how to hide sensitive keys in your Flutter application using a Flutter plug-in called Flutter_dotenv.
So let’s get started
Create your Flutter application using Visual Studio, IntelliJ, or Android Studio, then open the “pubspec.yaml” file and install the following package.
Dependencies: flutter_dotenv: ^ 5.0.0
Create an.env file in the root directory of your Flutter project
Add the newly created.env file to the asset bundle in the pubspec.yaml file.
Note: Add the newly created. In the pubspec.yaml file, run the Flutter Pub Get in the Terminal, or click Pub Get in IntelliJ or Android Studio to add the file to the current working directory folder.
In successfully added. Add your sensitive key to the pubspec.yaml file. The env file you created. (For example, see figure below)
The next step is to initialize/load the contents of the.env file in the main.dart file, as shown in the figure below:
The next step will be access. Circular file. You can visit. Use the following code.
Please see the picture below for a proper understanding
Run the project using a physical device or simulator test
Please note: for the sake of this tutorial, I have to show what I added in my Sensitivity key. Because I want you all to be able to see it and see how to store the sensitive key in an env file and access it from anywhere in the Flutter application.
This mode of storing the sensitive key in an ENV file helps to safely boot the sensitive key without exposing it when a hacker decompiles the application.
Always remember to add. File as an entry in your.gitignore file. The.gitignore file is a plain text file. Each line contains files/directories that are not included in git working copy.
If you’ve read this far, congratulations!
This is the source code for the project you just worked on.
If you find this article helpful and educational, please hit the high-five button as many times as possible to show your support
The elder brother of the © cat
The issue of
GetX Quick Start
Strapi manual translation
WeChat discussion group Ducafecat
A series of collections
The open source project
DART programming language basics
Flutter Zero Basics Beginners
Flutter combat news client from scratch
Flutter component development