flutter_lifecycle_by_resume 0.0.4

Flutter Android iOS

flutter 息屏显示执行事件

flutter_lifecycle_by_resume #

pub

在用户息灭屏幕后,又重新亮屏,即原生安卓生命周期onResume方法,提供了执行该生命周期代码的功能。

添加依赖 #

flutter_lifecycle_by_resume : ^0.0.3

快速使用 #

将with ResumeMixin

import 'package:flutter/material.dart';
import 'package:flutter_lifecycle_by_resume/minix.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> with ResumeMixin<MyApp>{

  @override
  void initState() {
    super.initState();
  }


  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('测试'),
        ),
        body: Container(),
      ),
    );
  }

  @override
  void onResume(BuildContext context) {
    // TODO: implement onResume
    /// 此处写亮屏后的逻辑代码
    print("todo in this");
  }
}

建议反馈 #

请加qq群1102781545