flutter-layout

What is unit of measurement in flutter

与世无争的帅哥 提交于 2019-12-18 19:07:02
问题 as usual, we use dp for Android and pt(point) for ios as a unit of measurement. 1 pt = 1/72 inch 1 dp = 1/160 inch But i don't what is unit of measurement in flutter example: SizedBox(height: 16.0) or TextStyle(fontSize: 23.0) It just a double number, how many dp or pt equal to 1.0 (flutter)? How is it calculated? 回答1: From https://docs.flutter.io/flutter/dart-ui/Window/devicePixelRatio.html : The number of device pixels for each logical pixel. This number might not be a power of two. Indeed,

how to create horizontal and vertical scrollable widgets in flutter

送分小仙女□ 提交于 2019-12-18 17:29:52
问题 sample Layout image I am trying to crate attached layout. It has two containers. - First a fixed size box that scrolls horizontally - second card is a that takes up remaining space with list view inside it. How can I achieve this layout ? As you can see, the scroll direction is different for both containers. The code is working till the Tags view (first box) but as soon as I am adding a second box i.e card, it is not showing anything and getting errors at console as below.. I/flutter ( 9412):

How to remove extra padding around AppBar leading icon in Flutter

孤街醉人 提交于 2019-12-18 15:24:17
问题 In my Flutter app, I have this AppBar Widget setAppBar(){ return new AppBar( title: addAppBarTextWidget('Explore'), elevation: 0.0, leading: addLeadingIcon(), actions: <Widget>[ addAppBarActionWidget(Constant.iconNotification, 22.0, 16.0, 8.0), addAppBarActionWidget(Constant.iconProfile, 30.0, 30.0, 15.0) ], ); } Widget addLeadingIcon(){ return new Container( height: 25.0, width: 25.0, padding: const EdgeInsets.fromLTRB(0.0, 0.0, 0.0, 0.0), margin: const EdgeInsets.fromLTRB(0.0, 0.0, 0.0, 0.0

How to detect orientation change in layout in Flutter?

China☆狼群 提交于 2019-12-18 14:07:06
问题 How to find out Orientation is portrait or landscape in Flutter if(portrait){ return ListView.builder() }else{ return GridView.count() } 回答1: In order to determine the Orientation of the screen, we can use the OrientationBuilder Widget. The OrientationBuilder will determine the current Orientation and rebuild when the Orientation changes. new OrientationBuilder( builder: (context, orientation) { return new GridView.count( // Create a grid with 2 columns in portrait mode, or 3 columns in //

how to create toolbar searchview in flutter

半世苍凉 提交于 2019-12-18 10:24:15
问题 i need to implement searchview in toolbar my app to achieve list view list filter. like below image, i searched lot still not get proper answer. Any help will be appreciated, thank you in advance. 回答1: With the help @aziza answer i write detail code snippet of search view with list filter below. it will help for others import 'package:flutter/material.dart'; class SearchList extends StatefulWidget { SearchList({ Key key }) : super(key: key); @override _SearchListState createState() => new

How to change status and navigation bar color in Flutter?

孤人 提交于 2019-12-18 05:43:51
问题 I'm trying to change the color of system status bar to black. The configuration seems to be overridden by the AppBar class. I can achieve what I want by assigning theme: to ThemeData.dark() when creating the Material App, and then specifying an appBar attribute . But I don't want an AppBar, and also, doing it this way changes all the font colors. A possible solution is to inherit ThemeData.bright() into new class, then add something that only changes the system status bar through

Flutter custom Google Map marker info window

丶灬走出姿态 提交于 2019-12-18 04:42:30
问题 I am working on Google Map Markers in Flutter. On the click of each Marker, I want to show a Custom Info Window which can include a button, image etc. But in Flutter there is a property TextInfoWindow which only accept String . How can i achieve adding buttons, images to the map marker's InfoWindow . 回答1: I stumbled across the same problem just today, I couldn't get a multiline string to show properly in TextInfoWindow. I ended up circumventing the problem by implementing a modal bottom sheet

How to implement a Custom dialog box in flutter?

巧了我就是萌 提交于 2019-12-18 04:14:40
问题 I'm a new one to flutter and need to create a gallery app and it needs a custom dialog box to visible the selected image, How to implement that? 回答1: Use Dialog class which is a parent class to AlertDialog class in Flutter. Dialog widget has a argument , "shape" which you can use to shape the Edges of the Dialog box. Here is a code sample: Dialog errorDialog = Dialog( shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12.0)), //this right here child: Container( height: 300.0,

Flutter Layout Row / Column - share width, expand height

和自甴很熟 提交于 2019-12-17 21:55:32
问题 I'm still having a bit of trouble with the layouting in Flutter. Right now I want to have the available space shared between 3 widgets, in a quadrant layout. The width is evenly shared (this works fine via 2 Expanded widgets in a Row), but now I also want the height to adjust automatically so widget3.height == widget1.height + widget2.height . If the content of widget3 is larger, I want widget1 and widget2 to adjust their height and vice versa. Is this even possible in Flutter? 回答1: Have a

Horizontally scrollable cards with Snap effect in flutter

不问归期 提交于 2019-12-17 17:41:03
问题 I want to create a list of cards scrolling horizontally with snap to fit effect when swiped either from left or right. Each card has some spacing between them and fit to screen similar to below image Apart from that these horizontally scrollable list elements should be contained inside a vertically scrollable list. I all I am able to achieve is only displaying a list of horizontal scrolling cards after following example in flutter docs. class SnapCarousel extends StatelessWidget { @override