مقابلات العمل2:42
مقابلات العمل · مبرمج · متقدّم
مقابلة مطوّر Flutter: إدارة الحالة والبيانات دون إنترنت وقائمة متقطعةFlutter Developer: State, Offline Data and a Janky List
- Dalia
- Omar
0:00 / 2:42
النص
- DaliaHi Omar. Let's start with something simple. Tell me about a Flutter app you built and one decision you'd change.
- OmarI built a food delivery app for a restaurant group, with menus, a cart and order tracking. I'd change one thing: I kept too much logic inside the widgets at first, so it was hard to test. Later I moved it into separate classes.
- DaliaWhich state management approach did you use, and why?
- OmarI used Riverpod in the later version. The main reason was testing: I can replace a provider with a fake one in a test. Before that I used setState for everything, which is fine for small local state but doesn't scale when many screens share data.
- DaliaHave you used Bloc?
- OmarOnly in a small course project. I understand the idea of events and states, but I haven't used it in production, so I won't claim I'm an expert. I'd learn quickly because the concepts are similar.
- DaliaNow a requirement: the app must show the last orders even without internet. How would you design it?
- OmarI'd store data in a local database, for example SQLite or a similar package. The screen would always read from the local database, and a repository would fetch from the server in the background and update the database. That way the screen works the same online and offline.
- DaliaWhat if the user creates an order while offline?
- OmarI'd save it locally as pending, show it with a clear 'waiting to send' label, and send it when the connection returns. I'd give every order a unique ID created on the device, so a retry can't create a duplicate. The harder part is conflicts, for example if the price changed meanwhile, so the server should have the final decision.
- DaliaDifferent topic. A list of products scrolls with dropped frames, especially with images. How would you investigate?
- OmarI'd run the app in profile mode, not debug mode, and open DevTools to see which frames take too long. Then I'd check three things: whether the list uses a builder constructor so it builds only visible items, whether the images are much bigger than the screen size, and whether something rebuilds the whole list on every scroll.
- DaliaWhy profile mode and not debug?
- OmarDebug mode includes extra checks and is much slower, so the numbers aren't realistic. Also, I'd test on a real, low-end phone, because that's where users will see the problem.
- DaliaGood. Last question: how do you keep your skills current?
- OmarI read the release notes for each new Flutter version, I build a small side project to try new ideas, and I read other people's code on GitHub. Right now I'm learning more about testing.
- DaliaThanks, Omar. We'll let you know by Thursday.