build_info_android 1.1.0 copy "build_info_android: ^1.1.0" to clipboard
build_info_android: ^1.1.0 copied to clipboard

PlatformAndroid

Android implementation of Flutter plugin that retrieves build date and time and installation date and time.

example/lib/main.dart

// Copyright 2024 Craftsoft LLC. All rights reserved.
// Use of this source code is governed by a MIT-style license that can be
// found in the LICENSE file.

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:build_info_platform_interface/build_info_data.dart';
import 'package:build_info_android/build_info_android.dart';

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

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

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  BuildInfoData? _buildInfoData;
  final _buildInfoAndroidPlugin = BuildInfoAndroid();

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

  // Platform messages are asynchronous, so we initialize in an async method.
  Future<void> initBuildInfoState() async {
    BuildInfoData? buildInfoData;
    // Platform messages may fail, so we use a try/catch PlatformException.
    // We also handle the message potentially returning null.
    try {
      buildInfoData = await _buildInfoAndroidPlugin.fromPlatform();
    } on PlatformException catch (e, stackTrace) {
      debugPrint(e.message);
      debugPrintStack(stackTrace: stackTrace);
    }

    // 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(() {
      _buildInfoData = buildInfoData;
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              Text('BuildDate: ${_buildInfoData?.buildDate}'),
              Text('InstallDate: ${_buildInfoData?.installDate}'),
            ],
          ),
        ),
      ),
    );
  }
}
1
likes
160
points
4.17k
downloads

Documentation

API reference

Publisher

verified publishercraftsoft.dev

Weekly Downloads

Android implementation of Flutter plugin that retrieves build date and time and installation date and time.

Homepage
Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

build_info_platform_interface, flutter

More

Packages that depend on build_info_android

Packages that implement build_info_android