dart_flutter_version 1.0.3 copy "dart_flutter_version: ^1.0.3" to clipboard
dart_flutter_version: ^1.0.3 copied to clipboard

Retrieve the current Dart and Flutter SDK semantic versions with easy-to-use nullable getters for streamlined version management.

example/lib/main.dart

import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:dart_flutter_version/dart_flutter_version.dart';
import 'package:pub_semver/pub_semver.dart';

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

class MyApp extends StatelessWidget {
  MyApp({Key? key}) : super(key: key);

  /// Create an instance of the [DartFlutterVersion] class
  late final versionInfo = DartFlutterVersion();

  @override
  Widget build(BuildContext context) {
    final dartVersion = versionInfo.dartVersion;
    final flutterVersion = versionInfo.flutterVersion;

    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(title: const Text('Version Info')),
        body: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              // Display the Dart version if known
              Text('Dart SDK Version: ${dartVersion ?? "Unknown"}'),

              // Display the Flutter version if known
              Text('Flutter SDK Version: ${flutterVersion ?? "Unknown"}'),

              ElevatedButton(
                onPressed: () {
                  // Your logic to track the Flutter SDK version
                  if (kDebugMode) {
                    print('Flutter SDK Version: $flutterVersion');
                  }
                },
                child: const Text('Track Flutter SDK Version'),
              ),

              if (flutterVersion != null && flutterVersion >= Version(3, 21, 0))
                const Text(
                  'This widget will be shown only if you run on Flutter 3.21.0 or newer',
                  style: TextStyle(color: Colors.red),
                ),
            ],
          ),
        ),
      ),
    );
  }
}
8
likes
160
points
6.28k
downloads

Publisher

unverified uploader

Weekly Downloads

Retrieve the current Dart and Flutter SDK semantic versions with easy-to-use nullable getters for streamlined version management.

Repository (GitHub)
View/report issues

Topics

#version #sdk #flutter-version-management

Documentation

API reference

Funding

Consider supporting this project:

paypal.me

License

MIT (license)

Dependencies

collection, flutter, pub_semver

More

Packages that depend on dart_flutter_version