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

To Use Media Query to make APP more dynamic #50

Open
HARSHBHUDOLIA opened this issue Jun 9, 2021 · 8 comments
Open

To Use Media Query to make APP more dynamic #50

HARSHBHUDOLIA opened this issue Jun 9, 2021 · 8 comments
Labels
bug Something isn't working easy Easy level issue good first issue good issue for first-time contributors normal-priority Something that has a normal priority

Comments

@HARSHBHUDOLIA
Copy link
Collaborator

HARSHBHUDOLIA commented Jun 9, 2021

Description

The app needs to be user friendly when the orientation and sizes of mobile devices differ, it also needs to be responsive and adaptive to both android and IOS which might be a problem with some segments of code used

Screenshots

image

Steps to Reproduce

Please provide detailed steps for reproducing the issue.

  1. Use the above-mentioned file (size_config.dart) to add MediaQuery to all the required files
  2. Comment the names of the files here before adding MediaQuery
  3. Check for the Renderflex issue (It will be device-specific) before adding the MediaQuery feature

Additional data

You can post the screenshot of the renderflex page or the dart file to have a discussion here.

@Mohitmadhav Mohitmadhav added bug Something isn't working low-priority Something that has a low priority refactor Improve code quality labels Jun 9, 2021
@Mohitmadhav
Copy link
Member

Okay, @HARSHBHUDOLIA.
We can make a separate dart file for all orientations and MediaQuery stuff.
Note this @wick3ds0ul and you can do the add ons.

@HARSHBHUDOLIA
Copy link
Collaborator Author

Don't do anything like making more dart files, using the ternary operator, and if statement is enough to take care of such issues.
Example
MediaQuery.of(context).size.width > 360
? FlatButton.icon(
onPressed: () {
deleteTransaction(transactions[index].id);
},
icon: Icon(Icons.delete),
textColor: Theme.of(context).errorColor,
label: Text('Delete'),
)
: IconButton(
onPressed: () {
deleteTransaction(transactions[index].id);
},
icon: Icon(Icons.delete),
color: Theme.of(context).errorColor,
),

Here we have different widgets rendered according to different sizes.

Another example will be

final isLandScape = mediaQuery.orientation == Orientation.landscape
if (!isLandScape)
Container(
height: (mediaQuery.size.height -
appBar.preferredSize.height -
mediaQuery.padding.top) *
0.3,
child: Chart(_recentTransactions)),
if (!isLandScape) txListWidget,
if (isLandScape)
_showChart
? Container(
height: (mediaQuery.size.height -
appBar.preferredSize.height -
mediaQuery.padding.top) *
0.7,
child: Chart(_recentTransactions))
: txListWidget
],
),

@HARSHBHUDOLIA
Copy link
Collaborator Author

This is an example of using LayoutBuilder for dynamic height calculations

LayoutBuilder(builder: (ctx, constraints) {
return Column(
children: [
Text(
'No Transactions added yet',
style: Theme.of(context).textTheme.title,
),
SizedBox(
height: 10,
),
Container(
height: constraints.maxHeight * 0.6,
child: Image.asset(
'assets/images/waiting.png',
fit: BoxFit.cover,
),
),
],
);
})

@Mohitmadhav Mohitmadhav added easy Easy level issue good first issue good issue for first-time contributors normal-priority Something that has a normal priority Hacktoberfest For Hacktoberfest 2021 and removed refactor Improve code quality low-priority Something that has a low priority labels Oct 1, 2021
@Project-Easter Project-Easter deleted a comment from wick3ds0ul Oct 2, 2021
@AyushTripathi28
Copy link

Hello, I am participating in Hacktoberfest this year. I want to contribute to this issue. Kindly assign me this issue.

@Mohitmadhav
Copy link
Member

Sure @AyushTripathi28, and make sure to follow the updated guidelines mentioned in README.

@AyushTripathi28
Copy link

Thank you so much to assign me this issue.

@Mohitmadhav
Copy link
Member

@AyushTripathi28, any updates?

@Mohitmadhav Mohitmadhav removed the Hacktoberfest For Hacktoberfest 2021 label May 31, 2022
@Mohitmadhav
Copy link
Member

Mohitmadhav commented Feb 10, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working easy Easy level issue good first issue good issue for first-time contributors normal-priority Something that has a normal priority
Projects
None yet
Development

No branches or pull requests

3 participants