dart_unit_converter 0.0.1+1 copy "dart_unit_converter: ^0.0.1+1" to clipboard
dart_unit_converter: ^0.0.1+1 copied to clipboard

outdated

A data unit converter package.

example/lib/main.dart

import 'package:dart_unit_converter/dart_unit_converter.dart';
import 'package:flutter/material.dart';

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

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Example Data Converter Apps',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: const HomePage(),
    );
  }
}

class HomePage extends StatefulWidget {
  const HomePage({Key? key}) : super(key: key);

  @override
  State<HomePage> createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  final converter = UnitConverter();
  final controller = TextEditingController();
  final valueListener = ValueNotifier<String>('');

  void useConverterFromByte() {
    final parsedValue = int.parse(controller.text);
    valueListener.value = converter.continousDataConvert(parsedValue);
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Example Apps'),
      ),
      body: Padding(
        padding: const EdgeInsets.all(18.0),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            const SizedBox(height: 24),
            const Text('From Byte Value'),
            TextFormField(
              controller: controller,
              keyboardType: TextInputType.number,
            ),
            const SizedBox(height: 50),
            ValueListenableBuilder<String>(
              valueListenable: valueListener,
              builder: (context, value, widget) {
                return Center(
                  child: Text('Value Converted: ${valueListener.value}'),
                );
              },
            ),
          ],
        ),
      ),
      floatingActionButton: ElevatedButton(
        onPressed: () => useConverterFromByte(),
        child: const Padding(
          padding: EdgeInsets.all(8),
          child: Text('Convert Data'),
        ),
      ),
    );
  }
}
2
likes
0
points
10
downloads

Publisher

verified publishervarx.id

Weekly Downloads

A data unit converter package.

Repository (GitLab)
View/report issues

License

unknown (license)

Dependencies

flutter

More

Packages that depend on dart_unit_converter