secure_ist_time_guard 0.0.2+1 copy "secure_ist_time_guard: ^0.0.2+1" to clipboard
secure_ist_time_guard: ^0.0.2+1 copied to clipboard

A secure, tamper-resistant, and offline-capable Indian Standard Time (IST) provider for Flutter. Anchors NTP time to native device uptime.

example/lib/main.dart

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

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

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'IST Service Example',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: const MyHomePage(title: 'Secure IST Time Guard'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});

  final String title;

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

class _MyHomePageState extends State<MyHomePage> {
  final ISTService _istService = ISTService();
  String _timeString = 'Initializing...';
  bool _isTampered = false;

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

  Future<void> _syncTime() async {
    setState(() {
      _timeString = 'Syncing...';
    });
    await _istService.sync();
    _updateTime();
  }

  void _updateTime() {
    setState(() {
      _timeString = _istService.currentDateTime.toString();
      _isTampered = _istService.isTampered;
    });

    if (_isTampered) {
      WidgetsBinding.instance.addPostFrameCallback((_) {
        _istService.showTimeManipulationBottomSheet(context);
      });
    }
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
        title: Text(widget.title),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            const Text(
              'Secure IST Time:',
              style: TextStyle(fontSize: 18),
            ),
            const SizedBox(height: 16),
            Text(
              _timeString,
              style: Theme.of(context).textTheme.headlineMedium,
            ),
            const SizedBox(height: 16),
            Text(
              'Tampered: $_isTampered',
              style: TextStyle(
                color: _isTampered ? Colors.red : Colors.green,
                fontWeight: FontWeight.bold,
              ),
            ),
            const SizedBox(height: 32),
            ElevatedButton(
              onPressed: _syncTime,
              child: const Text('Force Sync'),
            ),
            const SizedBox(height: 16),
            ElevatedButton(
              onPressed: _updateTime,
              child: const Text('Update Time UI'),
            )
          ],
        ),
      ),
    );
  }
}
1
likes
0
points
40
downloads

Publisher

verified publishertechnoamaze.in

Weekly Downloads

A secure, tamper-resistant, and offline-capable Indian Standard Time (IST) provider for Flutter. Anchors NTP time to native device uptime.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

app_settings, connectivity_plus, flutter, flutter_kronos, plugin_platform_interface, shared_preferences

More

Packages that depend on secure_ist_time_guard

Packages that implement secure_ist_time_guard