Giter VIP home page Giter VIP logo

application_version's Introduction

application_version

Pub

A Flutter plugin to retrieve the application's version and build number for both Android and iOS.

Features

  • Get App Version: Retrieve the app's version and build number.
  • VersionData Class:
    • Parsing: Parses version strings and ensures semantic versioning (e.g., "1.0" becomes "1.0.0").
    • Comparison: Implements Comparable<VersionData> interface for comparing versions.
    • Equality: Overrides == and hashCode for proper equality checks and use in collections.
    • String Representation: Provides a toString method to display the version in a readable format.

Why This Project?

Many developers use the package_info package, which provides a wide range of features. However, the extensive functionality of package_info comes with many dependencies that can potentially conflict with other packages you use. Therefore, this small package was created to do just one thing: show the version of your application. It aims to be lightweight with minimal dependencies, reducing the risk of conflicts.

Installation

Add application_version as a dependency in your pubspec.yaml file:

dependencies:
 application_version: "^0.0.1"

How To Use

Import the following package in your dart file

import 'package:application_version/application_version.dart';

 // then you need it:
 VersionData? version = await ApplicationVersion.getVersion();

VersionData class

The VersionData class includes methods for comparison, which can be useful in scenarios where you receive a minimum required version for an update from the backend.

  final version1 = VersionData.parse('1.2+100');
  final version2 = VersionData.parse('1.2.0+101');
  final version3 = VersionData.parse('1.3');
  final version4 = VersionData.parse('1.2.0')

  print(version1 < version2); // true
  print(version1 > version3); // false
  print(version2 >= version1); // true
  print(version3 <= version2); // false
  print(version1 == version4); // true The build number is ignored during comparison if one of the objects does not have it.

  // Example of checking if the current version meets the minimum required version
  final currentVersion = VersionData.parse('2.0.1');
  final minRequiredVersion = VersionData.parse('2.0.0');

  if (currentVersion >= minRequiredVersion) {
    print('Current version meets the minimum required version.');
  } else {
    print('Current version does not meet the minimum required version.');
  }

application_version's People

Contributors

kherel avatar

Stargazers

Andy Chentsov avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.