Python: Import from multiple folders

Some learnings with folder structure and import with Python, I was trying to make a REST Api using Python and Mongo db. My initial folder structure was like this I had problems with import, I was creating my Flask app in api.py, and I wanted to import my database functions into api.py and I was doing like this “from app.database.db import….” which somehow strangely conflicted the Flask app instance “app = Flask(name)”. Was giving ModuleNotFoundError: No module named ‘app’ Then I made the structure as below, renamed a few folders Then I had problems in accessing db.py as well as …

Continue Reading

Flutter: Plugin to get iso_countries

Often when we develop apps where we need to populate list of countries, search them etc, you may go by adding the data statically or using apis, but here lets use the power that lies with in your mobile phones. Most of the mobile system OS has these information embedded and we can avail those. I encountered a requirement while I was doing a personal project. I managed to create a plugin so that it benifit others, here you go https://pub.dev/packages/iso_countries

Continue Reading

UICollectionViewCells are resetting their size on refresh

Recently I was working on a scrollable tab bar, where I decided to use collectionview with estimatedSize as automatic as the tab titles were dynamic. I used a stackView inside the cell with all proper constraints and used the default flowlayout. Everything worked well unless there was a requirement to reload the tabs and what happened was once the reload happens, size of the cells became wrong, they shrinked suddenly. I could use the sizeForItem api but then I loose the dynamic behavior. Finally below are the steps that I did. I was creating the layout programmatically Set translatesAutoresizingMaskIntoConstraints false …

Continue Reading