ServerpodSwaggerVersion
The ServerpodSwaggerVersion
class provides version information for the Serverpod Swagger package. This class is useful for checking the current version of the package at runtime.
Overview
ServerpodSwaggerVersion
is a simple class that contains a single static property that returns the current version of the Serverpod Swagger package. This can be useful for logging, debugging, or displaying version information in your application.
Properties
Property | Type | Description |
---|---|---|
version | String | The current version of the Serverpod Swagger package. This is a static property that returns the version as a string in semantic versioning format (e.g., 1.0.0 ). |
Usage Example
Here's an example of how to use the ServerpodSwaggerVersion
class to get the current version of the package:
1import 'package:serverpod_swagger/serverpod_swagger.dart';
2
3void main() {
4 // Get the current version of the Serverpod Swagger package
5 String version = ServerpodSwaggerVersion.version;
6
7 // Print the version
8 print('Serverpod Swagger version: $version');
9}
Version Checking
You can use the version information to ensure compatibility with other components or to conditionally enable features based on the package version.
1import 'package:serverpod_swagger/serverpod_swagger.dart';
2import 'package:version/version.dart';
3
4void checkCompatibility() {
5 // Get the current version
6 String versionString = ServerpodSwaggerVersion.version;
7 Version version = Version.parse(versionString);
8
9 // Check if the version is compatible with your requirements
10 if (version < Version.parse('1.0.0')) {
11 print('Warning: You are using an older version of Serverpod Swagger.');
12 print('Some features may not be available.');
13 }
14}
Implementation Details
The ServerpodSwaggerVersion
class is implemented as a simple class with a static property. The version value is hardcoded in the package and is updated with each release.
1class ServerpodSwaggerVersion {
2 static const String version = '1.0.0'; // Example version
3}