Provider: Widget Function(BuildContext) can't be assigned to a builder parameter
The argument type 'Widget Function(BuildContext)' can't be assigned to the parameter type 'Widget Function(BuildContext, Widget)'Short answer
Provider builders pass more than the BuildContext. Consumer's builder receives (context, value, child), and the builder on ChangeNotifierProvider is a TransitionBuilder that receives (context, child). A closure with only context has the wrong type. Add the missing parameters, or use create to build the model.
Fix it fast
1Find out which cause you have
Find the exact call the analyzer underlines and note whether it is Consumer or a Provider class.
grep -rnE "Consumer<|ChangeNotifierProvider\(" lib/2Match what you see, then jump to its fix
- 1
The underlined call is Consumer<Model>(builder: (context) => ...)Consumer builder written with one parameterFix - 2
The underlined call is ChangeNotifierProvider(builder: (context) => CartModel())ChangeNotifierProvider builder is used as if it built the modelFix - 3
Code copied from an old tutorial that passes builder where a model is expectedOld code that used the removed builder parameter on providersFix
- 1
What does the error look like?
The argument type 'Widget Function(BuildContext)' can't be assigned to the parameter type 'Widget Function(BuildContext, Widget)'Consumer builder with only a BuildContext parameter is rejected by the analyzer
Cause 1 of 3
Consumer builder written with one parameter
1Check
Consumer's builder has the signature Widget Function(BuildContext context, T value, Widget? child).
grep -rn "Consumer<" lib/2Fix
Take the value (and the child, even if you ignore it with an underscore).
Consumer<CartModel>(
builder: (context, cart, child) => Text('${cart.count}'),
)3Verify
The analyzer error disappears.
flutter analyzeConfirmed by pub.dev
Cause 2 of 3
ChangeNotifierProvider builder is used as if it built the model
1Check
In provider the model is created by the create parameter. builder is a TransitionBuilder, syntax sugar for getting a BuildContext that can read the new provider. The rename of builder to create dates from provider 4.0.0.
grep -rn "builder:" lib/main.dart2Fix
Create the model in create. Use builder only when a descendant needs a context below the provider, and give it both arguments.
ChangeNotifierProvider(
create: (_) => CartModel(),
builder: (context, child) => const CartScreen(),
)3Verify
The app starts and context.watch<CartModel>() works inside CartScreen.
flutter runConfirmed by pub.dev
Cause 3 of 3
Old code that used the removed builder parameter on providers
1Check
The changelog for 4.0.0 records that builder of the Provider classes was renamed to create (deprecated in 3.2.0).
flutter pub deps | grep provider2Fix
Rename builder to create, and change the closure to take a context as before.
// before
ChangeNotifierProvider(builder: (context) => CartModel())
// after
ChangeNotifierProvider(create: (context) => CartModel())3Verify
The analyzer is clean.
flutter analyzeConfirmed by pub.dev
How do I stop it coming back?
- Let the analyzer, not a tutorial, tell you the builder signature of the provider version in pubspec.lock.
- Use create for building models and keep builder for the rare case that needs a descendant context.
- Pass the child argument to Consumer for parts of the tree that do not depend on the model.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
- TaxiDexMy own multi-tenant taxi dispatch SaaS: API, dispatcher portal, driver and passenger apps, and the servers underneath.
- Dispatch ProA real-time logistics platform: Flutter apps, Spring Boot services and a Kafka event pipeline on AWS.
- Qist BazaarA buy-now-pay-later marketplace built from a blank repo, now past 100K downloads on Google Play.
Related fixes
Mobile apps
Google Play says the app does not support 16 KB memory pages
check_elf_alignment.sh reports UNALIGNED for a library under lib/arm64-v8a
Google Play requires apps that target Android 15 or higher and ship native .so libraries to run on devices with 16 KB memory pages; from 1 February 2027 it will block updates that do not.
5 causes, each with a fixMobile apps
Gradle cannot find com.google.firebase:firebase-analytics-ktx
Required by: project :app
Firebase moved the Kotlin extensions into the main modules and stopped releasing the -ktx modules in July 2025.
2 causes, each with a fixMobile apps
Gradle cannot create LibraryVariantBuilderImpl in a Flutter Android build
Could not create an instance of type com.android.build.api.variant.impl.LibraryVariantBuilderImpl
This error appears when the Android Gradle plugin (AGP) cannot run in the Gradle or IDE you use.
3 causes, each with a fixMobile apps
Flutter release build cannot open the keystore: HmacPBESHA256 not available
Algorithm HmacPBESHA256 not available
The keystore is a PKCS12 file protected by a newer algorithm than the Java that is reading it understands.
3 causes, each with a fixMobile apps
Android install error: the package conflicts with an existing package of the same name
The package conflicts with an existing package by the same name
Android allows only one app per application ID, and an update must be signed with the same certificate as the installed version.
3 causes, each with a fixMobile apps
Android resource linking fails with resource android:attr/lStar not found
error: failed linking references.
The lStar attribute exists only from Android API 31.
2 causes, each with a fix