flutter_native_timezonev2 1.0.2 copy "flutter_native_timezonev2: ^1.0.2" to clipboard
flutter_native_timezonev2: ^1.0.2 copied to clipboard

discontinued

A flutter plugin for getting native timezone in android and ios.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'dart:async';

import 'package:flutter_native_timezone/flutter_native_timezonev2.dart';

void main() => runApp(new MyExampleApp());

class MyExampleApp extends StatefulWidget {
  @override
  _MyExampleState createState() => new _MyExampleState();
}

class _MyExampleState extends State<MyExampleApp> {
  String _timezone = 'Unknown';

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

  // Platform messages are asynchronous, so we initialize in an async method.
  Future<bool> initTimezone() async {
    String timezone;
    // Platform messages may fail, so we use a try/catch PlatformException.
    try {
      timezone = await FlutterNativeTimezone.getLocalTimezone();
    } on PlatformException {
      timezone = 'Failed to get local timezone.';
    }

    // If the widget was removed from the tree while the asynchronous platform
    // message was in flight, we want to discard the reply rather than calling
    // setState to update our non-existent appearance.
    if (!mounted) return false;

    setState(() {
      _timezone = timezone;
    });
    return true;
  }

  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      home: new Scaffold(
        appBar: new AppBar(
          title: new Text('Local timezone'),
        ),
        body: new Center(
          child: new Text('Local timezone: $_timezone\n'),
        ),
      ),
    );
  }
}
0
likes
15
pub points
0%
popularity

Publisher

unverified uploader

A flutter plugin for getting native timezone in android and ios.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

flutter

More

Packages that depend on flutter_native_timezonev2