Skip to content

Instantly share code, notes, and snippets.

@anilcancakir
Created January 23, 2023 23:20
Show Gist options
  • Save anilcancakir/1f169201fd90c64cda38228b7819f20c to your computer and use it in GitHub Desktop.
Save anilcancakir/1f169201fd90c64cda38228b7819f20c to your computer and use it in GitHub Desktop.
import 'dart:developer';
import 'package:flutter/material.dart';
import 'package:medium_story_app/config.dart';
void main() {
// Init the default timezone
Config.instance.set('timezone', 'Europe/London');
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
void _changeTimezone() {
Config.instance.set('timezone', 'Europe/Istanbul');
log('Timezone is updated.');
}
void _logTimezone() {
log('Current timezone is ' + Config.instance.get('timezone'));
}
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Singleton Demo',
home: Scaffold(
appBar: AppBar(
title: const Text('Change Timezone'),
),
body: Center(
child: IconButton(
icon: const Icon(Icons.print),
onPressed: _logTimezone,
)
),
floatingActionButton: FloatingActionButton(
onPressed: _changeTimezone,
child: const Icon(Icons.update),
),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment