graviton_utils_package 0.0.1 copy "graviton_utils_package: ^0.0.1" to clipboard
graviton_utils_package: ^0.0.1 copied to clipboard

A package which supports multiple features like fetching location, rotating image.

example/lib/main.dart

import 'dart:io';
import 'package:file_picker/file_picker.dart';
import 'package:flutter/material.dart';
import 'package:graviton_utils_package/graviton_utils_package.dart';
import 'package:path_provider/path_provider.dart';

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

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

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

class _MyAppState extends State<MyApp> {
  final _gravitonUtilsPackagePlugin = GravitonUtilsPackage();
  File? _image;
  dynamic _location = {};

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Graviton Utils Example'),
        ),
        body: SingleChildScrollView(
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.center,
            children: [
              const Text(
                "Don't Forgot to allow Application for Storage and Location permission through App Settings",
                style: TextStyle(fontSize: 12, color: Colors.red),
                textAlign: TextAlign.center,
              ),
              const SizedBox(height: 10),
              Center(
                child: ElevatedButton(
                    onPressed: () async {
                      FilePickerResult? result =
                          await FilePicker.platform.pickFiles(
                        type: FileType.custom,
                        allowedExtensions: ['jpg', 'pdf', 'doc'],
                      );
                      if (result != null) {
                        _image = File(result.files.single.path!);
                        setState(() {});
                      }
                    },
                    child: const Text("Test Image Rotate Feature")),
              ),
              if (_image != null)
                Padding(
                  padding: const EdgeInsets.all(15.0),
                  child: Column(
                    children: [
                      Row(
                        mainAxisAlignment: MainAxisAlignment.center,
                        children: [
                          IconButton(
                            onPressed: () async {
                              var bytesArray = await _gravitonUtilsPackagePlugin
                                  .rotateImage(_image!.path, -90);
                              final tempDir = await getTemporaryDirectory();
                              final file = File(
                                  '${tempDir.path}/rotated_image${DateTime.now().millisecondsSinceEpoch}.jpg');
                              file.writeAsBytesSync(bytesArray);
                              _image = file;
                              setState(() {});
                            },
                            icon: const Icon(Icons.rotate_left),
                          ),
                          IconButton(
                            onPressed: () async {
                              var bytesArray = await _gravitonUtilsPackagePlugin
                                  .rotateImage(_image!.path, 90);
                              final tempDir = await getTemporaryDirectory();
                              final file = File(
                                  '${tempDir.path}/rotated_image${DateTime.now().millisecondsSinceEpoch}.jpg');
                              file.writeAsBytesSync(bytesArray);
                              _image = file;
                              setState(() {});
                            },
                            icon: const Icon(Icons.rotate_right),
                          ),
                        ],
                      ),
                      Center(child: Image.file(_image!)),
                    ],
                  ),
                ),
              const Divider(),
              ElevatedButton(
                onPressed: () async {
                  _location =
                      await _gravitonUtilsPackagePlugin.getCurrentLocation();
                  print(_location);
                  setState(() {});
                },
                child: const Text("Test Current Location Feature"),
              ),
              if (_location.isNotEmpty) ...[
                const Text("Your Current Location is : "),
                Text(
                    "longitude: ${_location['longitude']}, latitude: ${_location['latitude']}")
              ],
            ],
          ),
        ),
      ),
    );
  }
}
4
likes
0
points
14
downloads

Publisher

unverified uploader

Weekly Downloads

A package which supports multiple features like fetching location, rotating image.

License

unknown (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on graviton_utils_package

Packages that implement graviton_utils_package