如何在Flatter中以正确的方式存储登录凭证_flutter_secure_storage

自我介绍一下,小编13年上海交大毕业,曾经在小公司待过,也去过华为、OPPO等大厂,18年进入阿里一直到现在。

深知大多数HarmonyOS鸿蒙开发工程师,想要提升技能,往往是自己摸索成长或者是报班学习,但对于培训机构动则几千的学费,着实压力不小。自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!

因此收集整理了一份《2024年HarmonyOS鸿蒙开发全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友,同时减轻大家的负担。
img

img
img
htt

既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,基本涵盖了95%以上HarmonyOS鸿蒙开发知识点,真正体系化!

由于文件比较大,这里只是将部分目录大纲截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频,并且会持续更新

如果你觉得这些内容对你有帮助,可以添加VX:vip204888 (备注鸿蒙获取)
img

一个人可以走的很快,但一群人才能走的更远。不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎扫码加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!

这是一个简单的登录 UI,其背后包含任何类型的登录业务逻辑。我不会使用任何一种状态管理,只会使用旧的好setState()。这只是一个简单的代码示例来展示包的使用。

好的,让我们编码。

首先,我们需要将包添加到pubspec.yaml文件中。


是的,但是…如何flutter_secure_storage工作?

正如报告中的那样README.md,我们所要做的就是:


这是一个非常简单的包,是的。

如您所见,在第 4 行,我们创建了一个存储,使我们能够读取和存储数据。

在第 7 行,我们读取并解密由标签标识的 String 值,如果不在存储中,则为keynull 。key请记住:key不应为空。

在第 19 行,我们存储并加密value由标签标识的对象key。如果key已经在存储中,则其关联value将被更改。如果value为空,则删除与value给定的关联key。

对于我们的用例,我们需要:

  • FlutterSecureStorage存储实例;
  • 两个TextEditingController与两个TextInputField小部件关联以收集用户凭据;
  • 一种将write数据存储起来的方法;
  • 一种read从存储中获取数据的方法;

所以让我们定义前两点:)


然后,我们定义_onFormSubmit()存储用户凭据的方法。Sing In此方法是与按钮关联的操作。仅当验证表单时,该方法才会负责将数据保存在存储中。


然后,我们定义方法_readFromStorage()。我们从 中调用这个方法initState(),这样在构建我们的 UI 之前就会检索到存储中的信息。

在创建 State 时,从框架中调用 initState() 方法。(所以它只被调用一次,在 UI 被绘制之前)。


通过这种方式,我们得到了以下屏幕截图中显示的行为。
在第一次登录时,用户输入他们的凭据并按下登录按钮。
稍后,当他再次打开应用程序时,他会发现他的凭据已经输入到表单中。



做得好!这些简单的说明将允许您向应用程序添加自动登录功能,但最重要的是,存储的信息将在安全存储中加密。
通过这些简单的步骤,您的应用程序将升级。

结论

flutter_secure_storage 是一个非常简单的包,只需几个简单的步骤,我们就可以将用户数据加密保存在安全存储中。

【Android 详细知识点思维脑图(技能树)】

其实Android开发的知识点就那么多,面试问来问去还是那么点东西。所以面试没有其他的诀窍,只看你对这些知识点准备的充分程度。so,出去面试时先看看自己复习到了哪个阶段就好。

虽然 Android 没有前几年火热了,已经过去了会四大组件就能找到高薪职位的时代了。这只能说明 Android 中级以下的岗位饱和了,现在高级工程师还是比较缺少的,很多高级职位给的薪资真的特别高(钱多也不一定能找到合适的),所以努力让自己成为高级工程师才是最重要的。

过去了会四大组件就能找到高薪职位的时代了。这只能说明 Android 中级以下的岗位饱和了,现在高级工程师还是比较缺少的,很多高级职位给的薪资真的特别高(钱多也不一定能找到合适的),所以努力让自己成为高级工程师才是最重要的。

  • 6
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
# Global Planner Parameters # maximum distance to the goal point goal_distance_tolerance: 0.1 # maximum allowed numerical error for goal position xy_goal_tolerance: 0.2 # maximum allowed numerical error for goal orientation yaw_goal_tolerance: 0.3 # weight for the heuristic function used in the A* algorithm # higher values prefer straighter paths, lower values prefer paths with less turning heuristic_weight: 3.0 # minimum distance to travel before attempting to replan min_replan_distance: 1.0 # minimum amount of time to wait before attempting to replan min_replan_time: 1.0 # tolerance on the robot's heading (in radians) when planning # during rotation commands this is an additional error that gets added to # yaw_goal_tolerance heading_lookahead: 0.325 # minimum lookahead to do during path planning. A shorter lookahead is more # cautious (especially in tight spaces) but may be more effective at avoiding # collisions with complex obstacles min_lookahead_distance: 0.4 # maximum lookahead to do during path planning max_lookahead_distance: 2.0 # if true, the global planner will only plan one step at a time # rather than to the final goal state intermediate_planning: false # what topic the planner should use for status feedback planner_frequency: 0.5 planner_topic: "planner_status" # how close the robot must be to the global plan before updating it with # a new one plan_update_distance: 0.5 # how often the planner should be allowed to make new plans. A value of 0 # means plans will be made as often as possible planner_patience: 5.0 # penalty for robot rotation during path planning. A higher penalty will # cause the planner to prefer straighter paths with less turns rotation_penalty: 0.8 # maximum absolute rotation speed allowed while navigating along the global # plan max_rotation_speed: 1.0 # maximum speed to travel along the global plan max_velocity: 0.6 # If true, the global planner will try to avoid obstacles with a combination # of steering and braking. Otherwise, it will only steer around obstacles braking_enabled: true # how many times to retry a goal update if the previous attempt resulted in a # collision or other error. # If set to -1, it will retry indefinitely goal_update_retries: 3 # Whether or not to use the extrinsic rotation control method in the planner use_extrinsic_rotation: true # Enabling this parameter causes the global planner to use # differential constraints for smoother trajectories use_differential_constraints: true # Enabling this parameter causes the planner to assume the # robot is driving on the right-hand side of the street drive_on_right: true # Timeout for the planning process (in seconds). If planning takes longer # than this, the planner will abort and return a failure status planning_timeout: 5.0 # If set, this parameter limits the maximum planning distance the # planner will use. Set to -1 for no limit. max_planning_distance: -1 # Enabling this parameter causes the planner to ignore the robot's ground # clearance when planning. ignore_ground_clearance: false # Whether the planner should try to avoid going backwards avoid_going_backwards: false # The maximum distance (in meters) that the planner will consider changing # the orientation of the robot to better follow the path. Set to -1 to # disable this behavior. max_orientation_change: 0.9 # The minimum distance (in meters) that the planner will consider # detecting a change in orientation of the robot to better follow the path. # Set to -1 to disable this behavior. min_orientation_change: 0.5 # Whether the planner should attempt to use the current local plan when planning. # If set to true, the planner will attempt to connect the current local plan # to the new plan. If set to false, the planner will always start from the robot's # current pose. use_local_plan: true # Whether the planner should attempt to use the current local costmap when planning. # If set to true, the planner will use the local costmap to build an estimate # of the robot's surroundings. If set to false, the planner will only use the # global costmap. use_local_costmap: true # Whether the planner should use the old behavior of setting waypoints to # the right of the global plan. This behavior causes the robot to execute # the plan with a rightward shift. However, it can be problematic if the plan # encounters obstacles on the left side. use_typical_rightward_shift: false # Whether the planner should use a zero velocity as a way to avoid oscillations. # If set to true, the planner will stop the robot and wait for the current goal # to either become unreachable or within the goal tolerance. stop_when_goal_rejected: false # The time (in seconds) that the planner will stop and wait (in case of oscillations) # before trying to replan. stop_and_wait_time: 2.0 # Distance (in meters) to be left before the end of the path. This can be useful # when the robot should stop at a certain distance from the goal pose. path_distance_offset: 0 # Maximum allowed speed deviation from the global plan (in m/s). max_allowed_speed_deviation: 1.0 # Maximum allowed angular deviation from the global plan (in rad). max_allowed_angular_deviation: 1.57 # Whether or not to use a linear navigation function to bias global plan costs toward closer parts of the map. use_linear_navigation_function: false # Whether or not to use a terrain independent cost scale to bias global plan costs toward flatter regions. use_terrain_independent_cost_scale: true # The maximum number of obstacles to check against during planning. max_obstacle_check_count: 500 # If true, the planner will skip planning during the first update cycle after initialization. skip_initial_planning: false # Scaling factor for the distances used in the Adaptive Sampling Path algorithm as_scaler: 1.0 # The maximum length of the Adaptive Sampling Path segments as_max_segment_length: 1.0 # The turning radius for the robot used in the prediction step of the Adaptive Sampling Path algorithm as_robot_radius: 0.3 # The number of areas forward used for heading smoothing in the Adaptive Sampling Path algorithm. # Set to 0 if heading smoothing is not desired. as_heading_smoothing_areas: 0 # The maximum distance the Adaptive Sampling Path algorithm will plan for. # Set to -1 for no limit. as_max_global_plan_distance: -1 # How many layers of costmaps to plan in. A higher value will allow the global # planner to take into account more layers of static and dynamic obstacles. # 0 means only use the base global costmap. planning_layers: 0

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值