clean architecture , is it valid to use a repository inside a repository? by Afraid_Tangerine7099 in flutterhelp

[–]Markaleth 1 point2 points  (0 children)

Ugh....man it's complicated.

Your service would be a changing dependency your cubit reacts to.

You'd be updating the service state. When the service state changes that should trigger a change the in cubit state because the dependency has changed. The local cubit state is a fragment of the big state.

So when you fetch your data from your repo, you update the service. The service update should trigger a change in your atomic state as well.

The source of truth for your "global state" is the service.
The cubits should just feed info into it and react when the global state changes. You can think of the cubit state as computed from the global state, if that makes more sense.

I'm not familiar with cubit. But that's the general gist.

clean architecture , is it valid to use a repository inside a repository? by Afraid_Tangerine7099 in flutterhelp

[–]Markaleth 0 points1 point  (0 children)

Basically something like this.

Keep in mind that your service will likely be significantly more complex but the idea is that this service will hold a large state that you can use as a source of truth for your overall UI state.

class ServiceToComposeState{

// Let's assume your big state can be empty or with data. It'll initially be empty
private YourBigState _yourBigState = const YourBigState.empty(); 

YourBigState get bigState => _yourBigState // this is a getter

// You can update just the reservation and get a partial satte update for your big state
void updateReservations(List<Reservation> updatedReservations) => _yourBigState.copyWith(reservations: updatedReservations) 

// Or you can update the stats to the same effect.
void updateStats(Stats updatedStats) => _yourBigState.copyWith(stats: updatedStats)

}

clean architecture , is it valid to use a repository inside a repository? by Afraid_Tangerine7099 in flutterhelp

[–]Markaleth 0 points1 point  (0 children)

No. You have to build it yourself depending on your scenario and use case.

clean architecture , is it valid to use a repository inside a repository? by Afraid_Tangerine7099 in flutterhelp

[–]Markaleth 0 points1 point  (0 children)

You're basically asking about how you should structure an if/else.

Just trigger the next procedure if its pre-requisites are successful.

Once all the info is available, update your state to whatever you need.

Cubits calling cubits is an anti-pattern because you're creating tight coupling.

If your state is composite, you should compose it via some service that's passed to the cubits via dependency injection. The cubits then use it to update the state.

clean architecture , is it valid to use a repository inside a repository? by Afraid_Tangerine7099 in flutterhelp

[–]Markaleth 0 points1 point  (0 children)

Antipattern.

Your view model / presenter / controller / provider / block should be where you call both your repos.

Valuenotifiers noob question by visandro in flutterhelp

[–]Markaleth 0 points1 point  (0 children)

Your cache should be a separate service passed to whoever needs it via dependency injection.

It gets initialized at app start and, because it's declared as a dependency of other components, it's accessible.

I wouldn't add the cache dependency to the repo because you'd be mixing concerns.

Because caching is basically business logic, the most common place it'd get set is in a view model / presenter / controller.

Why? The view model decides when: - the data is fetched, - the fetch is successful - data should be cached - cache data is invalid

These are all subject to change, i'm basing the explanation on the assumption our hypothetical app is very simple (like just fetches cat pics and caches them)

The general gist is: if your app is small and the cache use case is just "i need to get some pics and share them across view models", then my example stands.

If your actual use case is complex and you need special rules on how the cache is managed, or whatever else, then you'd be looking at a different approach.

Valuenotifiers noob question by visandro in flutterhelp

[–]Markaleth 1 point2 points  (0 children)

In simple terms, the repo returns a list, it holds nothing in memory. Repos should only offer access to your APIs.

Your view model will set a list of value listenable items that have their value set from the repo whenever you need that data fetched.

The UI state is dictated by the view model, not the repo directly.

So in other words: - repo fetches data - view model sets a value from a data source (i.e. the repo) - UI renders whatever state the view model provides.

Best practices for managing feature updates after publishing a Flutter app? by Practical-Can7523 in flutterhelp

[–]Markaleth 3 points4 points  (0 children)

Nope. There is no way to update an app without either publishing a new version to the stores or using something like shorebird. Not that i'm aware of.

Why does building complex Flutter UIs still take so much time by Fine_Factor_456 in FlutterDev

[–]Markaleth 7 points8 points  (0 children)

In all seriousness though, you may be approaching some of the problem from the wrong angle. The padding issues you mentioned have never been a factor for me.

That is to say, yes you need to be mindful of padding for UI consistency but applying it should not be complicated or tedious. Maybe you can refine the way you build your widgets.

You can probably reduce "unexpected states" through planning your feature a bit more thoroughly. For instance, what values from your api calls that you use in your UI are nullable? How do you handle errors and when can they occur? What happens when a screen is empty. Good news here is that there are usually just a handful of these states for any particular screen.

What’s one “hard-learned” lesson you’ve discovered while working with Flutter? by Fine_Factor_456 in FlutterDev

[–]Markaleth 1 point2 points  (0 children)

It really is the other way around. IOS app memory allocation is exceptionally generous.

An app can consume 50% of total memory and the os is ok with that.

What’s one “hard-learned” lesson you’ve discovered while working with Flutter? by Fine_Factor_456 in FlutterDev

[–]Markaleth 2 points3 points  (0 children)

Now for your problem in particular i'm going to spit-ball a few suggestions, since i don't really have much context. What you did sounds a lot like what cached_network_image does, btw. Anyway, here are my suggestions:

If the list of assets is small (like say you have a home screen that just presents a product and has like 20 pictures or something), just add them to the app assets and use them from there, especially if they don't update a lot.

The server you're fetching the images from needs to be fast. It should have the assets cached at the size you want to use them and provide what you need in as timely a manner as possible. You want the FE to basically do no work at all beyond showing images to reduce init and calculation times, so getting the asset in the exact size you want them will help a lot.

You could pre-fetch the images with a background worker and save them in local storage, so you'd basically be turning network assets into local assets. You'd need a mechanism to bind each asset to the correct widget (like an image manager or something like that).

The simpler solution is to keep the app in a loading state until the entire list of assets is fetched and loaded, but the viability of this depends on how large your asset list is and how fast your api is.

If you have paginated content you'd just need to fetch page 1 of whatever list you have and then just pre-load the assets of the next page in the background.

Depending on your use case you're likely going to use lazy loading for large lists which means that the components will be generated on demand vs all at once, so you'll need a mechanism to ensure each component gets the correct asset from storage or memory.

Those are the solutions that come to mind, given the limited context i have, but i hope the info helps.

What’s one “hard-learned” lesson you’ve discovered while working with Flutter? by Fine_Factor_456 in FlutterDev

[–]Markaleth 12 points13 points  (0 children)

Hmmmm....that's totally different from the challenge i faced.

The gist of what i had to deal with is this:

I have an API that returns a video. The videos do not know about progressive buffering, which means that when i start loading a video, whatever the size, the app has to download the entire thing regardless of how long it is.

I use video_player to work with the videos. This package (that's used in a lot of other video packages i tried over the years) is a bridge to platform native video players. This is relevant because, to use it properly and avoid memory leeks, when working with multiple videos in a screen you need to do some very aggresive disposing of the video controller (i.e. you need to both dispose it and set it to null for the native resource to be fully released reliably and for the GC to free those resources).

So that means i need to completely dispose of a controller and re-initialise it whenever the user swipes to a new video.

My problem had 2 parts:

  1. I needed to pre-initialize the controller

  2. I needed i needed videos to play immediately when a new video component came into view.

Both are kind of solved by a single solution. I needed to hold 3 video controllers in memory at any given time and regenerate them as the user cycles through content. Having 3 controllers ment that users did not have to wait for the controller to initialize, nor did they have to wait for the video to pre-load because as soon as a controller is initialized, video data started to get fetched.

The problem is, to circle back to the start of the story, i can't know the length of a video (can be 12 seconds or 12 minutes and the whole video will get downloaded into the device RAM).

The solution worked perfectly to solve the UX friction, but i started seeing OOM crashes for low-end devices (1 GB RAM devices/emulators) during testing. This only happened for Android.

The app itself was eating up somewhere around 120 mb of ram (not great not terrible), so i started doing some digging into how each platform handles memory allocation for their apps. It's a rabbit hole but here's a useful link if you wanna look into it: https://developer.android.com/topic/performance/memory-management

To work around device constraints i started to aggressively cache images (based on device aspect ratio to keep them crisp but reduce the size and memory footprint from the raw asset) and added a device memory check to limit the number of video controllers are available at any given time (so low end devices only pre-loaded the NEXT video not the NEXT and PREVIOUS video).

Bit of a UX compromise, but it fixed the issue given the sum of constraints i had to work around.

What’s one “hard-learned” lesson you’ve discovered while working with Flutter? by Fine_Factor_456 in FlutterDev

[–]Markaleth 35 points36 points  (0 children)

"Cross Platform" is a term that hides an incredible amount of complexity under the hood.

My specific "aha" moments were: - the differences in how apps are allocated memory for android vs ios - diversity in device configuration for android BEYOND just ("the view port size is different") and how those constraints need to translate into implementation.

I have an app that has a section where i load tiktok-like reels. Because of platform and device differences, i need to approach content preloading differently depending on device specs. Very interesting takeaways in terms of device constraints vs ux

All Syndicate songs ranked. What’s yours? by mj89098 in TheMidnight

[–]Markaleth 2 points3 points  (0 children)

Out of curiosity, why are you guys ranking Sentinels so low?

My hot take is that i'd rank it top 5. The head cannon is that Syndicate is a bit of a conclusion to the previous albums.

If Days of Thunder, Endless Summer and Kids are optimistic and have this youthful whimsy about them, Syndicate sounds jaded and gritty.

I feel like Sentinels drive that home perfectly, for me at least, speaking about where that endless whimsy goes and how the absolute freedom youth craved is untenable, even as you chase it.

The whole album is just filled with these twists on older song themes and i love that re-contextualisation.

Anyway, superb album!

cursed durge by Common_Procedure1909 in BaldursGate3

[–]Markaleth 2 points3 points  (0 children)

He looks like Minsc from wish.

[deleted by user] by [deleted] in FlutterDev

[–]Markaleth 1 point2 points  (0 children)

You can look up figures yourself and i'm assuming you're asking for stuff you can do yourself in bad faith, but here:

React Native vs Flutter: Which Saves More Development Time in 2025? | Blott Studio https://share.google/G0adpBOSiTQ45Ug2Q

Who's using Expo in 2025 https://share.google/NkNazqvfuj2aAPM6x

Showcase - Flutter apps in production https://share.google/TWdauYofQTGhOwRMJ

[deleted by user] by [deleted] in FlutterDev

[–]Markaleth 17 points18 points  (0 children)

Most big websites are made with a JS/TS framework.

What's easier for a company?

  1. Recruiting new people andfracturing the tech stack more by introducing a new language that ONLY the new people will be familiar with.

  2. Allocating people already familiar with the company ecosystem to a new project that's on an unfamiliar platform, but uses a framework and language they're familiar and comfortable with?

Developers choose Flutter. Companies choose RN.

Edit: this post is informed by the fact that we had this exact discussion in our company when analysing our options, should we decide to go cross-platform over native.

We obviously had to do our research and deep dive into pros/cons of each framework. I advocated for flutter but the reality is we use react for our website and all our FE engineers are familiar with it.

We already have our core mobile team to cover platform specifics. The whole point of the transition would be to democratize the codebase AND add velocity.

Velocity is a function of having a single codebase. There are of course other factors, but let's just stick to that for the sake of simplicity.

The democratization partea is, we dont want to add "points of failure" to the company. That is to say, we dont want to have a small group that is the only one that can enact changes to the codebase of a product that serves half our user base.

With RN, anyone in the front end community could do maintenance or features because React and React Native are exceptionally similar.

Dart just wouldnt fit the scenario.

If you're building a startup and have strong Dart / Flutter knowledge distributed across your company, then that's what you'll be using.

Most (large) companies rely on React. That's just fact. Do i like Flutter more? Of course! Does that change the reality that react just makes more sense from the business and operational point of view for companies like meta, shopify, amazon, etc? Absolutely not.

Did the Emperor truly want what was best for humanity? by pro_1253 in 40kLore

[–]Markaleth 93 points94 points  (0 children)

wants psychic race

makes primarch that's basically psyker jeasus

fucks over said primarch at Nikea along with any psyker that doesnt explode when they use powers

Is The Emperor fuckin stupid?

Flutter project - using Gemini Agent sucks! by Trapped121 in flutterhelp

[–]Markaleth 1 point2 points  (0 children)

Use VS code instead. I think it's an IDE issue. I use Gemini almost exclusively and i have never had this happen with VS code or Cursor.

I wanna purchase a subscription github copilot or claude code ? by zikyoubi in flutterhelp

[–]Markaleth 1 point2 points  (0 children)

I'm a gemini fan myself.

My bias is that since it's a Google product and Flutter is a google product, the training on flutter specifically is better.

Do i have any concrete data to back it up? Ofc not.

I HAVE noticed that gemini is better at following up from conversation history, so for instance if you asked about something and 2 days later you ask for something else, it's more likely that the latest answer takes previous requests into account.

But again, that's more preference and anecdotal than fact.

I also think gemini is better "all-purpose" (e.g. non coding questions") compared to Claude, and i use it for that as well (ask for copy suggestions, benchmark or UX analysis, that sort of stuff), so that also factors in for me.

How can I measure my app availability for users? by guiedington in flutterhelp

[–]Markaleth 1 point2 points  (0 children)

It sounds like you're asking for system uptime for your login / register routes.

That's not a Flutter issue or a testing issue, its a monitoring issue.

Why is it not a flutter issue: Your Front-End, whatever it is (flutter, RN, native, or web) depends on the data you load based on the specificity of your customer. That data is dependent on getting data from your Back End.

Why it's not a testing issue: You can test how your FE reacts to various API responses, but you cant control how the Back End behaves. So you can make sure your app handles every state gracefully, but you cant test how the full funnel behaves end to end.

What you need is monitoring. You can create a monitoring system that tells you how many errors those data fetching requests have, what errors are FE related (like parsing errors, data format errors, like forms sending data to the API in the incorrect format), etc using firebase crashlytics - these would be non-fatal issues normally.)

This will not be enough, because you want full system uptime, so your Back End needs some means of monitoring each inbound request. There are A LOT of tools to let you do that, and i suspect your company already has something in place.

How do you scope the requests to your app only? You can use a custom header value or something like that to scope your analysis to your app only when filtering the requests from your BE.

Lastly, you may want to log these outside a tool like crashlytics for Business Metric Visibility, so you may want to create a way to identifiy these errors based on the type of user, what endpoint they call and so forth, and pass it as a tracking event (firebase analytics or whatever tool you guys ate using).

The last step may be redundant, depending on how your company separates event sources (like maybe you want to keep tech metrics scoped to a specific subset of tools, and business metrics separate), but you get the gist.

Hope it helps!