flutter-layout

In Flutter, how can a positioned Widget feel taps outside of its parent Stack area?

本小妞迷上赌 提交于 2019-12-06 06:02:30
A Stack contains MyWidget inside of a Positioned . Stack( overflow: Overflow.visible, children: [ Positioned( top: 0.0, left: 0.0, child: MyWidget(), )], ); Since overflow is Overflow.visible and MyWidget is larger than the Stack , it displays outside of the Stack , which is what I want. However, I can't tap in the area of MyWidget which is outside of the Stack area. It simply ignores the tap there. How can I make sure MyWidget accepts gestures there? This behavior occurs because the stack checks whether the pointer is inside its bounds before checking whether a child got hit: Class: RenderBox

Flutter - Why slider doesn't update in AlertDialog?

天大地大妈咪最大 提交于 2019-12-06 01:04:05
问题 I doing a AlertDialog, so when I tried to insert Slider widget inside the state of value sound realy stranger, and this doesn't happens if Slider is outside of AlertDialog new Slider( onChanged: (double value) { setState(() { sliderValue = value; }); }, label: 'Oi', divisions: 10, min: 0.0, max: 10.0, value: sliderValue, ) The complete widget code of AlertDialog Future<Null> _showDialog() async { await showDialog<Null>( context: context, builder: (BuildContext context) { return new

How to Move bottomsheet along with keyboard which has textfield(autofocused is true)?

爷,独闯天下 提交于 2019-12-05 21:28:20
问题 I'm trying to make a bottomsheet which has a text field and autofocus is set to true so that the keyboard pops up. But, bottomsheet is overlapped by keyboard. Is there a way to move bottomsheet above the keyboard? Padding( padding: EdgeInsets.only(bottom: MediaQuery.of(context).viewInsets.bottom), child: Column(children: <Widget>[ TextField( autofocus: true, decoration: InputDecoration(hintText: 'Title'), ), TextField( decoration: InputDecoration(hintText: 'Details!'), keyboardType:

bottom sheet with initial height half of screen and if it scroll then height is increase to full screen

可紊 提交于 2019-12-05 20:17:22
I have a bottom sheet with below code in where i put a height 300.0 but I want increase height to full screen when user scroll ..how can i do that ..please void _showBottomSheet() { setState(() { _showPersBottomSheetCallBack = null; }); _scaffoldKey.currentState .showBottomSheet((context) { return new Container( height: 300.0, color: Colors.greenAccent, child: new Center( child: new Text("Hi BottomSheet"), ), ); }) .closed .whenComplete(() { if (mounted) { setState(() { _showPersBottomSheetCallBack = _showBottomSheet; }); } }); } The flutter package bottom sheet is not meant to occupy the full

Flutter expand TextField using dragging and button click

六眼飞鱼酱① 提交于 2019-12-05 20:12:10
问题 How can I increase/decrease the number of maxLines in TextField with dragging and clicking button? 回答1: Screenshot: Full code: class YourPage extends StatefulWidget { @override _YourPageState createState() => _YourPageState(); } class _YourPageState extends State<YourPage> { double _maxHeight = 200, _minHeight = 44, _height = 44, _dividerHeight = 56, _offset = 19; int _maxLines = 1; static final Duration _fixDuration = Duration(milliseconds: 500); Duration _duration = _fixDuration; @override

FLUTTER | Right Align not working

给你一囗甜甜゛ 提交于 2019-12-05 16:42:45
问题 Trying to right align a container with text view child, it has a row parent which is inside another column, tried number of solutions from Stack Overflow, didn't work. Code ///Transactions Heading new Column( children: <Widget>[ new Row( children: <Widget>[ new Container( alignment: Alignment.centerLeft, margin: new EdgeInsets.only(top: 20.0, left: 10.0), child: new Text( "Transactions", style: new TextStyle( color: primaryTextColor, fontSize: 25.0, fontWeight: FontWeight.w700, letterSpacing:

Find out which items in a ListView are visible

六眼飞鱼酱① 提交于 2019-12-05 16:16:42
How can I find out which items are currently visible or invisible in a ListView ? For example, I have 100 items in ListView and when i scroll to top of screen or list, I want to detect which items appear or disappear from the viewport. Illustration: There is no easy way to do this. Here is the same question, however, it does not have an answer. There is an active GitHub issue about this. There are multiple solutions for the problem in that issue. This Gist features one that requires the rect_getter package . Alternatively, you could take a look at this proposal . TL;DR This is not yet

Flutter Container height same as parent height

点点圈 提交于 2019-12-05 14:32:07
I want to overlay a Card with a white container, but the container always needs a height (otherwise it's not displayed). I want it to be as big as its parent, the stack. How can I make this work? The height of the card varies. I guess I'm missing something ;) return new Stack( children: <Widget>[ new Card( ... ), new Container(color: Colors.white70), ] ); You can use a Positioned.fill to force a stack child to fill Stack . Stack( children: [ Card(), Positioned.fill( child: Container(color: Colors.red), ) ] ); 来源: https://stackoverflow.com/questions/51078707/flutter-container-height-same-as

Non-center alignment for PageView with viewportFraction < 1.0

柔情痞子 提交于 2019-12-05 14:31:16
When you create a PageView with a viewportFraction value of <1.0 for the PageController, the pages are snapped to the center of the viewport, like so: I want the current pages to be snapped to the top of the viewport, while the next page is rendered under the bottom bar. I've tried applying a transform to each page: Transform.translate(offset: Offset(0.0, -36.0), child: page) This appears to work at first glance (see first image), but fails to render the next page when it would be hidden without the transform (see second image): I've thought of using a ListView with PageScrollPhysics (which

Multidirectional scroll in flutter

我与影子孤独终老i 提交于 2019-12-05 12:45:55
I come from a web development background, and am used to being able to create an element that has both x and y overflow (allowing scrolling in any direction). I'm struggling to achieve the same functionality with Flutter. Looking through the documentation, I've found SingleChildScrollView, but it only allows Axis.horizontal or Axis.vertical, not both. So I have tried the following: return SingleChildScrollView( // horizontal scroll widget scrollDirection: Axis.horizontal, child: SingleChildScrollView( // vertical scroll widget scrollDirection: Axis.vertical, child: ...content of the container