package_info_kit 0.0.1 copy "package_info_kit: ^0.0.1" to clipboard
package_info_kit: ^0.0.1 copied to clipboard

A comprehensive Flutter package for querying information about the application package, such as CFBundleVersion on iOS or versionCode on Android. Enhanced with additional features like install time an [...]

example/lib/main.dart

// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// ignore_for_file: public_member_api_docs

import 'dart:async';

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

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

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'PackageInfoKit Demo',
      theme: ThemeData(
        useMaterial3: true,
        colorSchemeSeed: const Color(0x9f4376f8),
      ),
      home: const MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key});

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  PackageInfo _packageInfo = const PackageInfo(
    appName: 'Unknown',
    packageName: 'Unknown',
    version: 'Unknown',
    buildNumber: 'Unknown',
    buildSignature: 'Unknown',
    installerStore: 'Unknown',
  );

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

  Future<void> _initPackageInfo() async {
    final info = await PackageInfo.fromPlatform();
    setState(() {
      _packageInfo = info;
    });
  }

  Widget _infoTile(String title, String subtitle) {
    return ListTile(
      title: Text(title),
      subtitle: Text(subtitle.isEmpty ? 'Not set' : subtitle),
    );
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('PackageInfoKit example'),
        elevation: 4,
      ),
      body: ListView(
        children: <Widget>[
          _infoTile('App name', _packageInfo.appName),
          _infoTile('Package name', _packageInfo.packageName),
          _infoTile('App version', _packageInfo.version),
          _infoTile('Build number', _packageInfo.buildNumber),
          _infoTile('Build signature', _packageInfo.buildSignature),
          _infoTile(
            'Installer store',
            _packageInfo.installerStore ?? 'not available',
          ),
          _infoTile(
            'Install time',
            _packageInfo.installTime?.toIso8601String() ??
                'Install time not available',
          ),
          _infoTile(
            'Update time',
            _packageInfo.updateTime?.toIso8601String() ??
                'Update time not available',
          ),
          // New Android-specific information
          if (_packageInfo.androidVersion != null)
            _infoTile('Android Version', _packageInfo.androidVersion!),
          if (_packageInfo.androidSdkVersion != null)
            _infoTile('Android SDK Version', _packageInfo.androidSdkVersion.toString()),
          if (_packageInfo.androidCodename != null)
            _infoTile('Android Codename', _packageInfo.androidCodename!),
        ],
      ),
    );
  }
}
0
likes
150
points
2
downloads

Publisher

verified publishertelegrambotmaker.app

Weekly Downloads

A comprehensive Flutter package for querying information about the application package, such as CFBundleVersion on iOS or versionCode on Android. Enhanced with additional features like install time and update time information.

Repository (GitHub)
View/report issues

Topics

#information #identifier #utils #package #app-info

Documentation

Documentation
API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on package_info_kit

Packages that implement package_info_kit