Skip to main content

gst_calculation_package 0.0.2 copy "gst_calculation_package: ^0.0.2" to clipboard
gst_calculation_package: ^0.0.2 copied to clipboard

A utility package for calculating Goods and Services Tax (GST) for both exclusive and inclusive amounts at various tax rates.

example/lib/main.dart

// gst_calculation_package/example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:gst_calculation_package/gst_calculation_package.dart'; // Import your package

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

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

  @override
  Widget build(BuildContext context) {
    // Demonstrate GST Exclusive
    final exclusiveResult = GstCalculator.calculateExclusive(
      basePrice: 500.0,
      gstRate: 5.0, // 5% GST
    );

    // Demonstrate GST Inclusive
    final inclusiveResult = GstCalculator.calculateInclusive(
      totalAmount: 525.0,
      gstRate: 5.0, // 5% GST included
    );

    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(title: const Text('GST Package Example')),
        body: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              const Text(
                'GST Calculation Demo (using 5% rate)',
                style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
              ),
              const Divider(),
              _buildResultTile(
                'Exclusive (Base: 500)',
                'GST: ${exclusiveResult['gstAmount']}',
                'Total: ${exclusiveResult['totalAmount']}',
              ),
              const Divider(),
              _buildResultTile(
                'Inclusive (Total: 525)',
                'Extracted GST: ${inclusiveResult['gstAmount']}',
                'Base Price: ${inclusiveResult['basePrice']}',
              ),
            ],
          ),
        ),
      ),
    );
  }

  Widget _buildResultTile(String title, String line1, String line2) {
    return Padding(
      padding: const EdgeInsets.all(8.0),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Text(title, style: const TextStyle(fontWeight: FontWeight.w600)),
          Text(line1),
          Text(line2),
        ],
      ),
    );
  }
}
0
likes
135
points
13
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

A utility package for calculating Goods and Services Tax (GST) for both exclusive and inclusive amounts at various tax rates.

License

unknown (license)

Dependencies

flutter

More

Packages that depend on gst_calculation_package