Created
January 23, 2023 23:20
-
-
Save anilcancakir/1f169201fd90c64cda38228b7819f20c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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