flutter-layout

Flutter Network Image does not fit in Circular Avatar

浪子不回头ぞ 提交于 2019-11-30 14:32:46
问题 I am trying to retrieve bunch of images from an api. I want the images to be displayed in Circular form so I am using CircleAvatar Widget, but I keep getting images in square format. Here is a screenshot of images Here is the code I am using ListTile(leading: CircleAvatar(child: Image.network("${snapshot.data.hitsList[index].previewUrl}",fit: BoxFit.scaleDown,)),), I tryied using all the properties of BoxFit like cover , contain , fitWidth , fitHeight etc but none of them works. 回答1: This

Horizontal ListView inside a Vertical ScrollView in Flutter

时光毁灭记忆、已成空白 提交于 2019-11-30 12:13:52
问题 I am trying to achieve a very common behavior nowadays which is to have a horizontal List within another widget which is at the same time scrollable. Think something like the homescreen of the imdb app: So I want to have a widget that scrolls vertically with few items on them. At the top of it there should be a horizontal ListView , followed up with some items called motivationCard . There are some headers in between the list and the cards as well. I got something like this on my Widget :

How to create a modal bottomsheet with circular corners in Flutter?

こ雲淡風輕ζ 提交于 2019-11-30 11:36:59
showModalBottomSheet does not provide any styling or decorations. I want to create something like the Google Tasks bottomsheet. This is the modalBottomSheet function needed. void _modalBottomSheetMenu(){ showModalBottomSheet( context: context, builder: (builder){ return new Container( height: 350.0, color: Colors.transparent, //could change this to Color(0xFF737373), //so you don't have to change MaterialApp canvasColor child: new Container( decoration: new BoxDecoration( color: Colors.white, borderRadius: new BorderRadius.only( topLeft: const Radius.circular(10.0), topRight: const Radius

How to detect orientation change in layout in Flutter?

天涯浪子 提交于 2019-11-30 11:14:08
How to find out Orientation is portrait or landscape in Flutter if(portrait){ return ListView.builder() }else{ return GridView.count() } 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 // landscape mode. crossAxisCount: orientation == Orientation.portrait ? 2 : 3, ); }, ); you can find the

Horizontal ListView inside a Vertical ScrollView in Flutter

我的未来我决定 提交于 2019-11-30 07:28:32
I am trying to achieve a very common behavior nowadays which is to have a horizontal List within another widget which is at the same time scrollable. Think something like the homescreen of the imdb app: So I want to have a widget that scrolls vertically with few items on them. At the top of it there should be a horizontal ListView , followed up with some items called motivationCard . There are some headers in between the list and the cards as well. I got something like this on my Widget : @override Widget build(BuildContext context) => BlocBuilder<HomeEvent, HomeState>( bloc: _homeBloc,

How to change status bar color in Flutter?

假如想象 提交于 2019-11-30 04:55:21
I am trying to change the status bar color to white. I found this pub on flutter. I tried to use the example code on my dart files. Works totally fine in my app import 'package:flutter_statusbarcolor/flutter_statusbarcolor.dart'; void main() => runApp(new MyApp()); class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { FlutterStatusbarcolor.setStatusBarColor(Colors.white); return MaterialApp( title: app_title, theme: ThemeData( primarySwatch: Colors.blue, ), home: HomePage(title: home_title), ); } } UPD: Another solution SystemChrome.setSystemUIOverlayStyle

How to refresh an AlertDialog in Flutter?

寵の児 提交于 2019-11-30 01:37:12
问题 Currently, I have an AlertDialog with an IconButton . The user can click on the IconButton, I have two colors for each click. The problem is that I need to close the AlertDialog and reopen to see the state change of the color icon. I want to change the IconButton color immediately when the user clicks it. Here is the code: bool pressphone = false; //.... new IconButton( icon: new Icon(Icons.phone), color: pressphone ? Colors.grey : Colors.green, onPressed: () => setState(() => pressphone =

How do I add margins to my widget ? Understanding the effect of EdgeInsets

我怕爱的太早我们不能终老 提交于 2019-11-30 01:24:46
问题 I am trying to wrap my head around ui placement in Flutter. So I currently have something that looks like this I would like to add a little space b/w search Textfield and the button. This is what the controlling part of my code looks like. I am trying to style my textFieldSearchBox so it has a little margin on the right, I tried trying to increase the Edge insets but it seems to increase the size of the TextField I don't know why? I know I could adding a padding element after TextField but I

Button Width Match Parent : Flutter

白昼怎懂夜的黑 提交于 2019-11-30 01:12:39
I am new in Flutter so I want to know that how can I set a width to match parent layout width new Container( width: 200.0, padding: const EdgeInsets.only(top: 16.0), child: new RaisedButton( child: new Text( "Submit", style: new TextStyle( color: Colors.white, ) ), colorBrightness: Brightness.dark, onPressed: () { _loginAttempt(context); }, color: Colors.blue, ), ), I know about little bit on Expanded tag but Expanded expand view to both direction, i dont know how to do it. Help me if you know, Thanks in Advance. The correct solution would be to use the SizedBox.expand widget, which enforces

Either drawImage or paintImage doesn't work properly in Flutter

久未见 提交于 2019-11-29 23:22:31
问题 I basically want to show an image that I have in the assets folder onto the canvas. import 'package:flutter/material.dart' as ui; ... ui.Image img = ui.Image.asset("images/some_image.png"); ui.paintImage(canvas: canvas, image: img); And have got the following error message when I tried to assign img to paintImage's image. The argument type 'Image (C:\ABC\flutter\packages\flutter\lib\src\widgets\image.dart)' can't be assigned to the parameter type 'Image (C:\ABC\flutter\bin\cache\pkg\sky