app_install_date 0.1.1 copy "app_install_date: ^0.1.1" to clipboard
app_install_date: ^0.1.1 copied to clipboard

outdated

This plugin helps you to get install date of the application

example/lib/main.dart

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

import 'package:app_install_date/app_install_date.dart';

void main() {
  runApp(MaterialApp(home: MyApp()));
}

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

class _MyAppState extends State<MyApp> {
  String _appInstallDate = 'Unknown';

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

  // Platform messages are asynchronous, so we initialize in an async method.
  Future<void> _initPlatformState() async {
    late String installDate;
    // Platform messages may fail, so we use a try/catch PlatformException.
    try {
      final DateTime date = await AppInstallDate().installDate;
      installDate = date.toString();
    } catch (e, st) {
      print('Failed to load install date due to $e\n$st');
      installDate = 'Failed to load install date';
    }

    // If the widget was removed from the tree while the asynchronous platform
    // message was in flight, we want to discard the reply rather than calling
    // setState to update our non-existent appearance.
    if (!mounted) return;

    setState(() {
      _appInstallDate = installDate;
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('App install date loading example'),
        centerTitle: true,
      ),
      body: Center(
        child: Text('App install date is $_appInstallDate'),
      ),
    );
  }
}
20
likes
0
pub points
91%
popularity

Publisher

unverified uploader

This plugin helps you to get install date of the application

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

flutter, path_provider

More

Packages that depend on app_install_date