Giter VIP home page Giter VIP logo

effectively_scale_ui_according_to_different_screen_sizes's People

Contributors

dancamdev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

effectively_scale_ui_according_to_different_screen_sizes's Issues

Trying to add this to my theme file

I'm fairly new to flutter and not that experienced - I want to be able to use this for my theme, particularly with regard to my Text Theme. It's in a separate file. There is nowhere at the top of the theme file to add "SizeConfig().init(context)," so I am getting flutter tester errors. also - do i need to put anything into my main.dart, even if it never really appears in the multi-screen app? I hope you can help, thank you!

Error:

======== Exception caught by widgets library =======================================================
The following NoSuchMethodError was thrown building MyApp(dirty, state: _MyAppState#7175d):
The method '*' was called on null.
Receiver: null
Tried calling: *(6)

The relevant error-causing widget was:
MyApp file:///......./lib/main.dart:9:10
When the exception was thrown, this was the stack:
#0 Object.noSuchMethod (dart:core-patch/object_patch.dart:54:5)
#1 _mmTextTheme (package:meeting_maker/utils/themes.dart:129:52)
#2 mmLite (package:meeting_maker/utils/themes.dart:85:16)
#3 _MyAppState.build (package:meeting_maker/main.dart:39:14)
#4 StatefulElement.build (package:flutter/src/widgets/framework.dart:4691:27)

Here is part of my theme file which shows the issue perhaps...

TextTheme _mmTextTheme(TextTheme base) {
return base
.copyWith(
headline1: base.headline1.copyWith(
color: mmMidBlue,
fontWeight: FontWeight.w300,
fontSize: 30,
letterSpacing: -1.0,
),
headline2: base.headline2.copyWith(
color: mmDarkBlue,
fontWeight: FontWeight.w800,
fontSize: 30,
letterSpacing: -1.0,
),
headline3: base.headline3.copyWith(
color: mmMidBlue,
fontWeight: FontWeight.w300,
fontSize: SizeConfig.safeBlockHorizontal * 6,
letterSpacing: -1.0,
),
headline4: base.headline4.copyWith(
color: mmDarkBlue,
fontWeight: FontWeight.w800,
fontSize: SizeConfig.safeBlockHorizontal * 6,
letterSpacing: -1.0,

ask about 100?

hi, can I ask what is 100?
blockSizeHorizontal = screenWidth / 100;

doesn't work if root widget is NOT Scaffold.

Works only if Scaffold is parent/root

class NextPage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Container(
        height: SizeConfig.blockSizeVertical * 50, //occupy 50% of screen
        width: SizeConfig.blockSizeHorizontal * 25, //occupy 25% of screen
        color: Colors.red,
      ),
    );
  }
}

Doesn't work Other Widget is Parent/Root

class NextPage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Container(
      height: SizeConfig.blockSizeVertical * 50, //occupy 50% of screen
      width: SizeConfig.blockSizeHorizontal * 25, //occupy 25% of screen
      color: Colors.red,
    );
  }
}

Is this expected?
Is there any other widget apart from Scaffold where this works

safeBlockVertical, safeBlockHorizontal NOT working as expected

In your main.dart, If Center is removed from build() method of _MyHomePageState, UI is not rendering after status bar in Android. It is also covering status bar. Then, what is the use of safeBlockVertical and safeBlockHorizontal

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    SizeConfig().init(context);
    return Scaffold(
      body: Container(
        height: SizeConfig.safeBlockVertical * 25,
        width: SizeConfig.safeBlockHorizontal * 55,
        color: Colors.black,
      ),
    );
  }
}

Instead I had to wrap inside SafeArea, and use blockSizeVertical, blockSizeHorizontal to make it work

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    SizeConfig().init(context);
    return Scaffold(
      body: SafeArea(
        child: Container(
          height: SizeConfig.blockSizeVertical * 25,
          width: SizeConfig.blockSizeHorizontal * 55,
          color: Colors.black,
        ),
      ),
    );
  }
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.