cingh-jasdeep / final_exam_eu_fall_21

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Final Exam Fall 2021, Mobile Apps

Eternal University, Baru Sahib

Waheguru Ji Ka Khalsa Waheguru Ji Ki Fateh ji

Welcome to the final exam of Mobile Apps. Time is 120 minutes. This exam/exercise assumes you are familiar with Topics covered in this class for Fall 2021 Semester at Eternal University, Baru Sahib.

We shall be designing and implementing a news app, named as 'Good News App' :)

Final Working Demo

Apart from making the reader happy 👼, in the process of making this app, you will apply concepts you covered in class.

This is an open internet test. Apart from communicating to your fellow students (which is not allowed) ⚠️, you are encouraged to lookup Lecture Notes and other sources online including https://api.flutter.dev/, stackoverflow etc.

So with God's grace, let's get started. You are given a series of steps, feel free to ask your invigilator if you have any doubts understanding any step.

Step 1 - Create project (5 points)

  • First create a new Flutter 'Application' inside Visual Studio Code. and name it 'good_news_app' REFERENCE LINK

Step 2 - Add app icon (10 points)

Step 3 - Copy assets (5 points)

  • Copy fonts and images folder to your project directory, as these contain assets needed for the app.

Step 4 - Create a StatefulWidget - NewsPage (10 points)

  • Create a new file, news_page.dart inside your project's lib folder.

  • Inside this file, create a new StatefulWidget (using VSCode snippets) named NewsPage (you may need to import the material library to for StatefulWidget to be recognized)

  • Set NewsPage as home of your MaterialApp in main.dart (Be sure to import files correctly) (you may refer to the BMI and Quizzler app to see how you did this)

Step 5 - Design NewsPage layout (25 points)

  • Use your knowledge of layout widgets (Columns, Rows, Scaffold, AppBar, Expanded etc.. like you did in Dicee, BMI Calculator) design a layout for the NewsPage widget as given in the Google Drawing link below https://docs.google.com/drawings/d/1q3afjuS3paoDp-6t46MqTd5hgP6eluNFRDEYUFKJ8VM/edit?usp=sharing

    • You may find it useful to run the app and design side-by-side, taking advantage of HotReload and HotRestart.
  • For mock image you can use 'images/Disabilities_Act.jpg' (Asset Image) and for mock test you can use this text:

'TNIE Impact: Sivakasi Elwin Center gets disabled friendly toilets\nToilets were constructed after The New Indian Express had highlighted the needs of the school on September 19 and raised the question of whether the funds would reach the cause.\nBy Azeefa Fathima\nExpress News Service\nVIRUDHUNAGAR: In less than two months after Collector J Meghanatha Reddy passed the proceedings for the construction of two disabled-friendly toilets, the funds have found its way for the same. Collector opened two disabled-friendly toilets under the \'Udhayam\' scheme in the CSI school for Elwin Centre in Sivakasi for use on the occasion of World Disability Day here on Friday.\n\nToilets were constructed after The New Indian Express had highlighted the needs of the school on September 19 and raised the question of whether the funds would reach the cause. It looks like the universe has indeed conspired in helping them in achieving their needs.\n\nSpeaking at the inauguration event, the collector said though he was exposed to the issues of Persons with Disabilities (PwDs) through his friends, difficulty in using a toilet did not come into his thought up until it a 16-year-old girl in a pension camp at the collectorate raised it.\n\n"Normally toilets at our houses would be small and cannot be easily accessed by PwDs. After the girl explained their plight, I wanted to do something about this, and we devised the \'Udhayam\' scheme. Though we will not be able to construct toilets for everyone immediately, we are doing it in a phased manner based on CSR funds and other fund availability, prioritising women and girls," he said.  \n\nHe further said under the initiative it has been aimed to build at least 100 toilets by the end of this year. Speaking about the need of the school, he said that when the school approached him, though there was no fund at hand, he had made arrangements from his discretionary funds.\n\nThe funds for two other toilets under construction is sponsored by a private sponsor, he added. Stating a saying, he said, "When you want something, all the universe conspires in helping you to achieve it, and I wanted to do this for the differently-abled people. I got in touch with the like-minded people who supported me in taking the project forward," he said.\n\nSchool correspondent M Dayalan Barnabas demanded three things during the function: a paver block road leading to the school; include the widowed women in the school in the scheme where free goats are distributed by the state government and include Elwin Centre in \'Adult Project\' under the PwD welfare department as nearly 50 adult PwDs are residing in the school. Collecter assured to take action.\n\nBackstory\n\nThe Elwin Centre, located in Sivakasi\'s Satchiyapuram was established in 1980 by Selvabai and her husband Reverend Thavaraj David. The school is now working under the model of self-sustenance with limited funding. The school aims to translate its financial model into the lives of its children. As part of the self-sustenance project, they bought 50 country chickens and reared them. "Everything, from feeding the chicken to cleaning the coops, was done by our children. The money coming from the rearing is re-invested in similar ventures.\n\nDuring the earlier interaction with The New Indian Express, they had highlighted two issues: a crunch in funds despite the self-sustenance model and well-wishers; and the lack of disability-friendly toilets for the children who also have physical disabilities.\n\nWhen the latter issue was highlighted to the collector, he had immediately conducted inspections, following which Rs 94,000 was sanctioned in the first phase for the construction of two toilets and mobilised funds through private sponsor for the construction of another two.\n\nEarlier, the district officials, led by the collector, created a project named Udhayam to build accessible toilets in their houses for PwDs, in the district.\n\n\nhttps://www.newindianexpress.com/good-news/2021/dec/04/tnie-impact-sivakasi-elwin-center-getsdisabled-friendly-toilets-2391706.html'
- Please note to use asset images and fonts, you may need to import them in `pubspec.yaml` (As done in MICard and Magic8Ball app)

Step 6 - Create News and NewsBrain class (20 points)

  • As you can observe, every news item seems to have a text and a image path. So, make a News class inside a new file news.dart, similar to what you did in Quizzler and Destini.

    • Make sure that this class has 2 properties, one for text and one for image path.
  • Create another class NewsBrain in news_brain.dart with one private property, to store a List of news objects provided below

[
    News('images/RIGHT_OF_ADMISSION.jpg','Right of admission reserved for the less fortunate in this TN school\nWhile being in the process though, there is something so innate that makes them capable of, maybe yet unaware of it. It’s called privilege.\nBy P Thiruselvam\nExpress News Service\nARIYALUR: Ever wondered what drives forward a kid caught in the race that education has turned into, these days? It might well be the competitive, demanding aspect of it which always propels them to widen their arms and get hold of every bit of knowledge out there. While being in the process though, there is something so innate that makes them capable of, maybe yet unaware of it. It’s called privilege.\nFor many like the 67 Irular children in Ariyalur’s Olaiyur and Pappankulam villages, however, there is no such air hovering over their heads. Left to sweat it out in a race of unequals, they need an extra push to dive deep into the vast knowledge pool where others are soaked in. That is exactly what D Elavarasan, a 32-year-old teacher, is giving them with his classes and care.\nElavarasan, who works in a private school, has been taking evening classes to these children every day except Sundays for the last five years. Children from classes 1 to 11 attend the classes, which Elavarsan has called ‘Mahatma Gandhi Malai Nera Padippagam’. Apart from teaching them basic subject lessons, special attention is given to their skill development. They are also provided with notebooks, pens, books, school uniforms and are given a nutritious meal thrice a week.\nOther than coordinating the classes, he anchors a collective called ‘Sweet Trust’, which was formed six years ago in view of the drought in the district. The group has so far planted three lakh palm seeds and one lakh other saplings around lakes, ponds, and near roadsides in the district. More than hundreds of youths and college students from various villages have joined him in the efforts for the last five years.\nThe man’s efforts for holding the classes daily are aided by the NGO -- Networking and Development Centre for Service Organisation (NDCSO), which gives him necessary funding. The NGO also helps students who have completed their schooling to pursue higher education. He is helped by graduates from the village who are assigned to monitor the classes.\nSpeaking to TNIE, Elavarasan said, “Most of the people here do not have basic education. Some do not even send their children to school but instead take them to work. We wanted to improve the lives of the Irular children.”\nHe said they are now going to focus on teaching Irular students across the district. Providing them with basic education will help the whole community come forward and benefit their next generations, he added.\nAccording to the NGO’s founder J Prabhakar, the floods of 2015 were the starting point of the programme. “When the floods hit Cuddalore, the Irular community was severely affected. Even though we helped them, we found out that they were backward in education. Many students have so far benefited from this.”\nV Kanagavalli, who studies in class 11 in a government higher secondary school in Keezha Kolathur, said the classes helped clear her doubts. The gratitude for having gotten a push to run in a marathon race for knowledge and better lives was palpable in her soft yet gritty response.\nhttps://www.newindianexpress.com/good-news/2021/dec/05/right-of-admission-reserved-for-the-less-fortunate-in-this-tn-school-2391968.html'),
    News('images/GURGADDI_DIWAS_GURU_GOBIND_SINGH_JI.jpg','Greetings on Gurgaddi Diwas of Guru Gobind Singh Ji\n\nਤਖਤਿ ਰਾਜਾ ਸੋ ਬਹੈ ਜਿ ਤਖਤੈ ਲਾਇਕ ਹੋਈ ॥\nThakhath Raajaa So Behai J Thakhathai Laaeik Hoee ||\nThat king sits upon the throne, who is worthy of that throne.\nਜਿਨੀ ਸਚੁ ਪਛਾਣਿਆ ਸਚੁ ਰਾਜੇ ਸੇਈ ॥\nJinee Sach Pashhaaniaa Sach Raajae Saeee ||\nThose who realize the True Lord, they alone are the true kings.\nToday is the Gurgaddi Diwas of the Tenth Master of Sikhs Sri Guru Gobind Singh Ji. \nGuru Gobind Singh Ji was born as Gobind Rai in the house of Ninth Master Sri Guru Tegh Bahadur Ji and Mata Gujri Ji in Patna in 1666.\nUnder Aurangzeb\'s orders, Kashmiri Brahmins were being forcibly converted to Islam. Flocks of Kashmiri Brahmins, led by Pandit Kirpa Ram, rushed to Anandpur and pleaded their case before Guru Ji: "O Divine Master! Help us save our Hindu Dharma, so that we may keep our frontal mark (Tilak) and sacred thread (Janeu) intact. A reign of terror has been let loose upon us by the Mughal Emperor Aurangzeb to shed our articles of faith and embrace Islam." Hearing their petition, Guru Ji was moved and attuned Himself with the Divine within. The atmosphere became very holy, serene, and pious. The nine-year-old Gobind Rai asked his father, "What do these holy men want? How can these terrified people be saved from the tyranny of Aurangzeb?" Guru Ji told his son that this would be possible only if a Divine person sacrificed his life to protect their Dharma. Gobind Rai submitted with folded hands "O Divine father! Who is greater than You in the Divine Realm?” Hearing the divine words from His young son, Guru Ji pacified and assured the Kashmiri Pandits that their Dharma would be saved by making a great sacrifice. He told them that they should convey to Aurangzeb that if he could succeed in converting Guru Tegh Bahadur to Islam, all Brahmins would then embrace Islam automatically. \nFor this divine cause of saving the Hindu Dharma, Sri Guru Tegh Bahadur Ji left for Delhi where he and his companions refused to embrace Islam and attained martyrdom.\nDuring this period according to the instructions of Sri Guru Tegh Bahadur Ji, Gobind Rai was bestowed with the Guruship by the holy congregation. Baba Ram Kanwar, a direct descendant of Baba Buddha Ji, put the frontal mark on his forehead, and a plume (Kalgi) on his turban. Thus, the nine-year-old Gobind Rai was anointed as the tenth Guru Nanak.\nਹੱਕ ਹੱਕ ਆਗਾਹ ਗੁਰੂ ਗੋਬਿੰਦ ਸਿੰਘ\nHak hak aagaah Guru Gobind Singh\nGuru Gobind Singh is the truth for the connoisseurs of truth,\nਸ਼ਾਹਿ ਸ਼ਹਨਸ਼ਾਹ ਗੁਰੂ ਗੋਬਿੰਦ ਸਿੰਘ ॥\nShahe Shehanshaah Guru Gobind Singh\nGuru Gobind Singh is the king of kings. \n\nSource: ‘Sikh Faith - An Epitome of Inter-Faith for Divine Realisation’, written by Shiromani Panth Ratan Baba Iqbal Singh Ji.\nhttps://www.facebook.com/BaruSahibHP/photos/a.312356885474161/4747909495252189/'),
    News('images/SHAKAR_GANJ_SHEIKH_FARID_JI.jpg','कैसे \'शक्कर गंज\' नाम पड़ा था भक्त फरीद जी का\nसबसे पहले तो आप सभी को हमारी ओर से प्रेम भरी सत श्री अकाल।🙏\nदोस्तो, आज हम आपके लिए एक ऐसे महापुरूष के जीवन साखी लेकर आए है जिनके लिखे पवित्र शब्द सिख पंथ के आदि ग्रंथ धन श्री गुरु ग्रंथ साहिब जी में सम्मानपूर्वक लिखे गए।\nदोस्तो, हम बात कर रहे है सूफी संत बाबा शेख़ फरीद जी की। इन्होंने इस धरती पर ज्ञान और कला का ऐसा रंग बिखेरा कि आज भी एशिया के देशों के साथ साथ पूरी दुनिया में इनका रंग देखने को मिलता है।\nपंजाब की धरती के इस महान सूफी संत को पंजाब की मिटटी का पहला कवि भी कहा जाता है। क्योंकि बाबा जी की प्रेरणादायी और जीवन संबधी कविताएं सिख धर्म के पवित्र ग्रंथ ‘श्री गुरु ग्रंथ साहिब जी’ में बहुत ही आदरपूर्वक लिखी गई हैं।\nहालांकि बाबा जी जन्म से मुस्लिम थे, लेकिन फिर भी हिन्दू, सिख आदि सभी धर्म के लोगों ने उनका बहुत सम्मान किया। आज के समय में पंजाब के साथ साथ पूरे उत्तर भारत और पडोसी मुल्क पकिस्तान में बाबा फरीद जी को बड़े आदर के साथ पूजा जाता है।\nबाबा फरीद जी का जन्म 1173 ईस्वी के रमजान महीने में पंजाब के कोठवाल गाँव (जोकि अब पकिस्तान का हिस्सा है) में हुआ। इनका वंशगत संबंध काबुल के बादशाह फर्रुखशाह से माना जाता है। कहा जाता ही कि महज़ 14 वर्ष की छोटी सी उम्र में ही ये ख्वाजा कुतुबुद्दीन बख्तियार काकी के शिष्य बन गए थे, बाद में इन्हे संत कबीर जी का शिष्य बनने का मौका मिला।\nउन्होंने दुनिया को हमेशा सत्य व् अहिंसा के मार्ग के लिए प्रेरित किया। वे कहते थे:\nफरीदा जो तैं मारण मुक्कियाँ, तिनां ना मारे घुम्म,\nअपनड़े घर जाईए, पैर तिनां दे चुम्म।\nये बचपन से ही ईश्वर की भक्ति और उपासना में बहुत ही विश्वास रखते थे। बालक फरीद को अपनी माँ द्वारा रोजाना नमाज अदा करने के लिए हर रोज़ कहा जाता था। लेकिन वो कहता था कि मुझे भगवान से क्या मिलेगा? मैं क्यों करूँ उसकी बंदगी?\nकहते है कि बाबा फरीद जी को खजूर बहुत पसंद थे इसलिए एक दिन उनकी माँ ने उनसे कहा कि अगर तू नमाज़ अता करेगा तो परमात्मा तुझे खजूर देगा। बाबा फरीद जी की माँ ने नमाज अदा करने के लिए एक चटाई डाली और उस चटाई के नीचे कुछ खजूर छिपा दिए ताकि वह उसे अल्लाह का वरदान समझे। ऐसा कुछ रोज़ चलता रहा।\nएक दिन बाबा फरीद की माँ चटाई के नीचे खजूर रखना भूल गई, लेकिन उसकी नमाज के बाद एक करिश्मा हुआ उसने चटाई के नीचे खजूर रखे पाये। कहते है कि उस दिन से माँ ने बेटे को “शकर गंज” के नाम से बुलाना शुरू कर दिया। इन्हे शुरू से ही किसी की निंदा करना नहीं भाता था। अपने एक दोहे में बाबा जी लिखते है:\nफरीदा जे तू अकल लतीफ, काले लिख ना लेख,\nअपनड़े गिरहबान में, सिर नीवां कर देख।\nबाबा फरीद जी ने बचपन से ही अपने विश्वास और भक्ति के चलते ईश्वर को प्रसन्न किया जिसके चलते उन्हें आज भी दुनिया भर में नमन किया जाता है। उन्होंने अपने दोहों में लोगों को परम ईश्वर और सत्य से मिलवाने के लिए सच्चे ज्ञान का मार्ग दिखाया।\nदोस्तो, यदि हम आज भी बाबा जी के द्वारा दिखाए हुए मार्ग पर चलने का प्रयास करें तो यकीनन हम उस परम पिता परमात्मा से ज़रूर मिल सकेंगे।\nhttps://www.facebook.com/BaruSahibHP/photos/a.312356885474161/4744596568916815/'),
    News('images/Disabilities_Act.jpg','TNIE Impact: Sivakasi Elwin Center gets disabled friendly toilets\nToilets were constructed after The New Indian Express had highlighted the needs of the school on September 19 and raised the question of whether the funds would reach the cause.\nBy Azeefa Fathima\nExpress News Service\nVIRUDHUNAGAR: In less than two months after Collector J Meghanatha Reddy passed the proceedings for the construction of two disabled-friendly toilets, the funds have found its way for the same. Collector opened two disabled-friendly toilets under the \'Udhayam\' scheme in the CSI school for Elwin Centre in Sivakasi for use on the occasion of World Disability Day here on Friday.\n\nToilets were constructed after The New Indian Express had highlighted the needs of the school on September 19 and raised the question of whether the funds would reach the cause. It looks like the universe has indeed conspired in helping them in achieving their needs.\n\nSpeaking at the inauguration event, the collector said though he was exposed to the issues of Persons with Disabilities (PwDs) through his friends, difficulty in using a toilet did not come into his thought up until it a 16-year-old girl in a pension camp at the collectorate raised it.\n\n"Normally toilets at our houses would be small and cannot be easily accessed by PwDs. After the girl explained their plight, I wanted to do something about this, and we devised the \'Udhayam\' scheme. Though we will not be able to construct toilets for everyone immediately, we are doing it in a phased manner based on CSR funds and other fund availability, prioritising women and girls," he said.  \n\nHe further said under the initiative it has been aimed to build at least 100 toilets by the end of this year. Speaking about the need of the school, he said that when the school approached him, though there was no fund at hand, he had made arrangements from his discretionary funds.\n\nThe funds for two other toilets under construction is sponsored by a private sponsor, he added. Stating a saying, he said, "When you want something, all the universe conspires in helping you to achieve it, and I wanted to do this for the differently-abled people. I got in touch with the like-minded people who supported me in taking the project forward," he said.\n\nSchool correspondent M Dayalan Barnabas demanded three things during the function: a paver block road leading to the school; include the widowed women in the school in the scheme where free goats are distributed by the state government and include Elwin Centre in \'Adult Project\' under the PwD welfare department as nearly 50 adult PwDs are residing in the school. Collecter assured to take action.\n\nBackstory\n\nThe Elwin Centre, located in Sivakasi\'s Satchiyapuram was established in 1980 by Selvabai and her husband Reverend Thavaraj David. The school is now working under the model of self-sustenance with limited funding. The school aims to translate its financial model into the lives of its children. As part of the self-sustenance project, they bought 50 country chickens and reared them. "Everything, from feeding the chicken to cleaning the coops, was done by our children. The money coming from the rearing is re-invested in similar ventures.\n\nDuring the earlier interaction with The New Indian Express, they had highlighted two issues: a crunch in funds despite the self-sustenance model and well-wishers; and the lack of disability-friendly toilets for the children who also have physical disabilities.\n\nWhen the latter issue was highlighted to the collector, he had immediately conducted inspections, following which Rs 94,000 was sanctioned in the first phase for the construction of two toilets and mobilised funds through private sponsor for the construction of another two.\n\nEarlier, the district officials, led by the collector, created a project named Udhayam to build accessible toilets in their houses for PwDs, in the district.\n\n\nhttps://www.newindianexpress.com/good-news/2021/dec/04/tnie-impact-sivakasi-elwin-center-getsdisabled-friendly-toilets-2391706.html'),
    News('images/LOVING_LIBRARY.jpg','‘Loving Library’ by a Little Singh for Covid Patients\n\nA 9-year-old Little Singh, Anaik Singh from Phoenix, Arizona, U.S.A. has created a Free Library for the Covid-19 Patients named "Loving Library".\n\nRecently he shared his story on the Famous Ellen Show about how he thought of starting such a kind of library. He shared how his family suffered from Covid-19, and his grandmother was hospitalized. When his family was in isolation, he was all alone and then he found his own escape and jumped into the world of books.\n\nHe also added, "When my family recovered, I started thinking about ways to help other people. That\'s where my experience with books accompanying me through isolation came in handy. I decided to create a "Loving Library" for the hospital patients going through quarantine from the virus."\n\nThe project started with isolated people who suffered from COVID and is now helping the homeless. A donation book program is being run this year for hospitalized COVID patients in underserved communities and homeless patients at the \'Circle the City,\' a medical clinic for those who are homeless.\n\nThe ‘Loving Library’ aims to add a thousand books to its collection this year.\n\nThe Little Singh hopes to provide a variety of genres, including fiction, non-fiction, mystery, books in languages such as Spanish, journals, and more.\nhttps://www.facebook.com/BaruSahibHP/photos/a.312356885474161/4744653975577741/'),
]
  • You may have to adjust your News class constructor for this list to work.

    • Note: Image paths in this list are relevant only if you copy the images folder to you root project directory.
    • Note: Please check that you have imported these images individually or images folder in pubspec.yaml, you may refer to Dicee for this
  • create methods getNewsText(), getNewsImagePath() inside NewsBrain to return current news text and image path.

    • initialize the current news with a random news from the list.
    • Note: You may need to use constructor for this.
  • create a method goToNextNews() in NewsBrain to update the current news to a another random news from the list (just like Quizzler)

Step 7 - use NewsBrain to update NewsPage content (25 points)

  • Now that you have defined a news data source, let's make a new NewsBrain object inside the _NewsPageState class.

  • update NewsPage image and text using this NewsBrain object.

  • when user clicks 'More News 👼', on the bottom of the page, go to next news from the NewsBrain object.

    • Note: You may need to use a GestureDetector to accept taps here
    • Hint: Make sure you update the state of your app correctly, for new news to update.

Step Extra Credit - Refactor news content to NewsContent(10 points)

  • layout with news text and image into a new Widget, , with atleast 2 properties, news text and news image path

Step Extra Credit - Use ScrollController to reset News Text position (10 points)

  • You may notice that news text does not have correct scroll if you go to a new news item and scrolled previously. Use ScrollController to reset the news text position when you switch to new news.

About