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 method '*' was called on null. #15

Closed
pratikbutani opened this issue Mar 24, 2021 · 4 comments
Closed

The method '*' was called on null. #15

pratikbutani opened this issue Mar 24, 2021 · 4 comments

Comments

@pratikbutani
Copy link

Implemented sizer: ^1.1.8 but getting error when I set it as following:

SizedBox(height: 20.0.h),

Error:

======== Exception caught by widgets library =======================================================
The following NoSuchMethodError was thrown building LoginWithSet(dirty, dependencies: [_FocusMarker, MediaQuery, _InheritedTheme, _LocalizationsScope-[GlobalKey#39772]], state: _LoginWithSetState#2e207):
The method '*' was called on null.
Receiver: null
Tried calling: *(20.0)

The relevant error-causing widget was: 
  
When the exception was thrown, this was the stack: 
#0      Object.noSuchMethod (dart:core-patch/object_patch.dart:51:5)
#1      SizerUtil.height (package:sizer/sizer_util.dart:32:20)
#2      SizerExt.h (package:sizer/sizer_ext.dart:7:29)
#3      StatefulElement.build (package:flutter/src/widgets/framework.dart:4744:28)
...


@fayisode
Copy link

Same issue here.

@pratikbutani
Copy link
Author

pratikbutani commented Mar 28, 2021

Solved. May you forgot this lines to add in main.dart

return LayoutBuilder(
      builder: (context, constraints) {
        return OrientationBuilder(
          builder: (context, orientation) {
            SizerUtil().init(constraints, orientation);
            return MaterialApp(
              debugShowCheckedModeBanner: false,
              title: 'Sizer',
              theme: ThemeData.light(),
              home: HomeScreen(),
            );
          },
        );
      },
    );

@fayisode
Copy link

fayisode commented Apr 4, 2021

It's working fine now.

@harshilishere
Copy link

I have these lines in my main.dart but still getting this error. What is the basic reason for this error!?!!?
Please someone help.

`import 'package:flutter/material.dart';
import 'home_page.dart';

void main() {
runApp(MyApp());
}

class MyApp extends StatelessWidget {
// This widget is the root of your application.
@OverRide
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,),
home: HomePage(),
);
}
}
`

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

3 participants