flutter_heyteacher_meta 4.4.2+124 copy "flutter_heyteacher_meta: ^4.4.2+124" to clipboard
flutter_heyteacher_meta: ^4.4.2+124 copied to clipboard

A Flutter meta project implementing utilities for Flutter package and app project.

example/lib/main.dart

import 'dart:async';

import 'package:flutter/material.dart';
import 'package:flutter_heyteacher_meta/fake_pubspec_version.dart'
    show FakePubspecVersion;
import 'package:flutter_heyteacher_meta/pubspec_version.dart'
    show PubspecVersionCommand;

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

/// This Widget is the main application widget.
class MyApp extends StatelessWidget {
  /// Creates the [MyApp].
  const MyApp({super.key});

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Pubspec Version Example',
      theme: ThemeData(
        colorScheme: .fromSeed(seedColor: Colors.deepPurple),
      ),
      home: const _MyHomePage(title: 'Pubspec Version Example'),
    );
  }
}

class _MyHomePage extends StatefulWidget {
  const _MyHomePage({required this.title});

  final String title;

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

class _MyHomePageState extends State<_MyHomePage> {
  String? _version;
  String? _build;
  final _fakePubspecVersion = FakePubspecVersion();

  Future<void> _pubspecVersion(PubspecVersionCommand command) async {
    debugPrint('<_pubspecVersion>: command $command');
    _version = await _fakePubspecVersion.version(
      versionCommand: command,
    );
    _build = await _fakePubspecVersion.version(
      versionCommand: PubspecVersionCommand.showBuild,
    );
    debugPrint('(_pubspecVersion): version $_version build $_build');
    setState(() {});
  }

  @override
  void initState() {
    super.initState();
    WidgetsBinding.instance.addPostFrameCallback(
      (_) => unawaited(_pubspecVersion(PubspecVersionCommand.show)),
    );
  }

  @override
  Widget build(BuildContext context) => Scaffold(
    appBar: AppBar(
      backgroundColor: Theme.of(context).colorScheme.inversePrimary,
      title: Text(widget.title),
    ),
    body: Center(
      child: Column(
        mainAxisAlignment: .center,
        spacing: 16,
        children: [
          const Text('pubspec.yaml version'),
          Text(
            '$_version',
            style: Theme.of(context).textTheme.displayLarge,
          ),
          const Text('pubspec.yaml build'),
          Text(
            '$_build',
            style: Theme.of(context).textTheme.displayMedium,
          ),
        ],
      ),
    ),
    floatingActionButton: Row(
      mainAxisAlignment: MainAxisAlignment.center,
      spacing: 16,
      children: [
        FloatingActionButton(
          onPressed: () => _pubspecVersion(PubspecVersionCommand.major),
          tooltip: 'Major',
          backgroundColor: Colors.greenAccent,
          child: const Text(
            'Major',
            textAlign: TextAlign.center,
          ),
        ),
        FloatingActionButton(
          onPressed: () => _pubspecVersion(PubspecVersionCommand.minor),
          tooltip: 'Minor',
          backgroundColor: Colors.yellowAccent,
          child: const Text(
            'Minor',
            textAlign: TextAlign.center,
          ),
        ),
        FloatingActionButton(
          onPressed: () => _pubspecVersion(PubspecVersionCommand.patch),
          tooltip: 'Patch',
          backgroundColor: Colors.redAccent,
          child: const Text(
            'Patch',
            textAlign: TextAlign.center,
          ),
        ),
        FloatingActionButton(
          onPressed: () => _pubspecVersion(PubspecVersionCommand.build),
          tooltip: 'Build',
          backgroundColor: Colors.blueAccent,
          child: const Text(
            'Build',
            textAlign: TextAlign.center,
          ),
        ),
      ],
    ),
  );
}
0
likes
0
points
40
downloads

Publisher

unverified uploader

Weekly Downloads

A Flutter meta project implementing utilities for Flutter package and app project.

Repository (GitHub)
View/report issues

Topics

#firebase #fastlane #firestore

Documentation

Documentation

Funding

Consider supporting this project:

github.com

License

unknown (license)

Dependencies

clock, flutter, intl, yaml_edit

More

Packages that depend on flutter_heyteacher_meta