I am in the process of updating a Flutter project from v2 to v3 and running into some weird issues. Everywhere anything Material related is being used, i get this prop does not exist. Here are some examples:
_uiViewPort(MaterialApp(
home: StreamBuilder<bool>(
stream: _authenticationService.loginStatusChangeStream,
builder: (context, snapshot) {
if (snapshot.data == true) {
return Scaffold(
key: locator<DialogService>().scaffoldKey,
resizeToAvoidBottomInset: true,
drawer: DrawerView(),
appBar: AppBarCustom(),
body: _initializeViewPort(),
bottomNavigationBar: BottomNavigationView(),
);
}
return Scaffold(
resizeToAvoidBottomInset: true,
body: _initializeViewPort(),
bottomNavigationBar: BottomNavigationView(),
);
}),
));
I get The named parameter home
isn’t defined and The named parameter stream
isn’t defined, etc. etc.
This is the same for other fields too like:
Text(
title,
style: AppTheme.instance
.textStyleSmall(color: Colors.black, fontWeight: FontWeight.w600),
),
It tells me that style is not defined. I upgraded the project to current Flutter and am trying to remediate all the errors.
Can anyone help me out at all? It seems like Material just isn’t installed. But I don’t get an error when importing it at the top of the page?
2
Answers
Try running
flutter clean flutter pub get
if you are using android studio do file -> Invalidate cache and restart (find this at top bar)
make sure to
import 'package:flutter/material.dart';
at top of your file