Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The argument type 'AuthWrapper Function(BuildContext, Map<String, dynamic>)' can't be assigned to the parameter type 'Widget? Function(BuildContext?, Map<String, List<String>>)'. #240

Open
SeifAlmoatazBellah opened this issue Jul 11, 2021 · 4 comments

Comments

@SeifAlmoatazBellah
Copy link

Hello i have an error with Fluro when i set handlerFunc
this is my codes:
`
class AppRouter {
static final router = FluroRouter();

var usersHandler = Handler(
handlerFunc: (BuildContext context, Map<String, dynamic> params) {
return AuthWrapper();
},
);

void defineRoutes(FluroRouter router) {
router.define("/auth", handler: usersHandler);
}
}
AuthWrapper screen:class AuthWrapper extends StatefulWidget {
const AuthWrapper({Key? key}) : super(key: key);

@OverRide
_AuthWrapperState createState() => _AuthWrapperState();
}

class _AuthWrapperState extends State {
bool loading = false;

@OverRide
Widget build(BuildContext context) {
ThemeSetting theme = Provider.of(context);
return AnnotatedRegion(
value: SystemUiOverlayStyle(
statusBarIconBrightness: Brightness.light,
statusBarColor: Colors.transparent,
systemNavigationBarIconBrightness: Brightness.light,
systemNavigationBarColor: Colors.transparent,
),
child: loading
? Scaffold(
backgroundColor: theme.primary,
body: Center(
child: LoadingWidget(),
),
)
: Scaffold(
backgroundColor: theme.primary,
bottomNavigationBar: BottomAppBar(
elevation: 0,
color: Colors.transparent,
child: TabBar(
labelColor: theme.secondary,
unselectedLabelColor: theme.secondary.withOpacity(.8),
indicatorColor: theme.secondary,
tabs: [
Tab(text: 'SignIn'),
Tab(text: 'SignUp'),
],
),
),
body: TabBarView(
children: [
SignUp(),
SignIn(),
],
),
),
);
}
}
`

@surpass404
Copy link

有解决吗

@surpass404
Copy link

How to deal with it?

@RemcoSchrijver
Copy link

Instatiate your handler function like this:
var usersHandler = Handler( handlerFunc: (BuildContext? context, Map<String, dynamic> params) { return AuthWrapper(); }, );

You need to allow BuildContext to be null to actually match the right parameter for the constructor of Handler. So use BuildContext? context

@GenPingYuan
Copy link

Instatiate your handler function like this: var usersHandler = Handler( handlerFunc: (BuildContext? context, Map<String, dynamic> params) { return AuthWrapper(); }, );

You need to allow BuildContext to be null to actually match the right parameter for the constructor of Handler. So use BuildContext? context

Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants