Last active
September 2, 2021 17:27
-
-
Save kururu-abdo/8f0d97d611abcc549ff23537af427bae to your computer and use it in GitHub Desktop.
This file contains 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 'package:flutter/material.dart'; | |
const Color darkBlue = Color.fromARGB(255, 18, 32, 47); | |
void main() { | |
runApp(EmailApp()); | |
} | |
class EmailApp extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
PersonManager personManager = Overseer().fetch(PersonManager); | |
return MaterialApp( | |
home: Scaffold( | |
appBar: AppBar(title: Text("my app"), centerTitle: true), | |
body: Center (child:ListView( | |
children : personManager.fetchNames().map((name)=>Text(name)).toList() | |
)) | |
)); | |
} | |
} | |
class PersonManager { | |
List<String> names = ["Walaa", "Zikra"]; | |
List<String> fetchNames() => names; | |
} | |
class Overseer { | |
Map<dynamic, dynamic> repository = {}; | |
Overseer() { | |
register(PersonManager, PersonManager()); | |
} | |
register(name, object) { | |
repository[name] = object; | |
} | |
fetch(name) => repository[name]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment