Flutter-UI icon indicating copy to clipboard operation
Flutter-UI copied to clipboard

To Use Media Query to make APP more dynamic

Open HARSHBHUDOLIA opened this issue 3 years ago • 8 comments

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.

HARSHBHUDOLIA avatar Jun 09 '21 16:06 HARSHBHUDOLIA

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.

Mohitmadhav avatar Jun 09 '21 16:06 Mohitmadhav

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 avatar Jun 09 '21 16:06 HARSHBHUDOLIA

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, ), ), ], ); })

HARSHBHUDOLIA avatar Jun 09 '21 16:06 HARSHBHUDOLIA

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

AyushTripathi28 avatar Oct 03 '21 07:10 AyushTripathi28

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

Mohitmadhav avatar Oct 03 '21 10:10 Mohitmadhav

Thank you so much to assign me this issue.

AyushTripathi28 avatar Oct 05 '21 08:10 AyushTripathi28

@AyushTripathi28, any updates?

Mohitmadhav avatar Oct 25 '21 15:10 Mohitmadhav

Hi Ali,

I don't know why your comment is not being displayed in GitHub. Can you please type this again in the Github chat?

Regards Mohit

On Tue, Jan 31, 2023 at 4:48 PM Ali Asar Khowaja @.***> wrote:

Hi @Mohitmadhav https://github.com/Mohitmadhav @ankitoscar https://github.com/ankitoscar Can you assign me this issue? I want to contribute to this issue.

— Reply to this email directly, view it on GitHub https://github.com/Project-Easter/Flutter-UI/issues/50#issuecomment-1410179590, or unsubscribe https://github.com/notifications/unsubscribe-auth/AOEVZOI6TH4S7AREJQTF6S3WVDYI5ANCNFSM46MK4ZNQ . You are receiving this because you were mentioned.Message ID: @.***>

Mohitmadhav avatar Feb 10 '23 14:02 Mohitmadhav