flutter-layout

Can Flutter efficiently layout nested lists?

╄→гoц情女王★ 提交于 2019-12-04 19:16:56
Can a layout like this be achieved and rendered efficiently in Flutter? Example: Yellow and blue blocks can both be around 30 elements, so I guess something like ListView.builder should be used. I have tried nesting 2 ListView.builder, the inner with shrinkWrap = true. The yellow block is being built just when is needed, but the blue list, although it has an itemBuilder, it builds all children elements at once, causing performance problems. new ListView.builder( itemCount: 20, itemBuilder: (BuildContext context, int blockIdx) { print("Building block $blockIdx"); return new Column( children: [

How to create a horizontally scrolling table with fixed column in Flutter?

寵の児 提交于 2019-12-04 16:27:09
I would like to create a series of tables that you can scroll through vertically, each of which may have a different number of rows/columns from each other. Within each table, I would like to have the leftmost column frozen in place, and the remaining columns in that table to be horizontally scrollable, in case there are a number of columns that do not fit in the width of the screen. See screenshot: My initial plan was to use a ListView for the page-level vertical scrolling between tables, and within each table, there is a Row of Columns, where the first column is a static width, and the

Flutter: How to make a button expand to the size of its parent?

别说谁变了你拦得住时间么 提交于 2019-12-04 15:42:28
问题 I am trying to create square buttons, but Expanded doesn't seem to work the same as it does with containers. Take the following code for example new Expanded( flex: 2, child: new Column( children: <Widget>[ new Expanded( child:new Row( children: <Widget>[ new Expanded(child: new MaterialButton(...)), new Expanded(child: new MaterialButton(....)), new Expanded(child: new Container(color: Colors.red)), new Expanded(child: new Container(color: Colors.green)), ] ) ) ], ) ) .... It displays two

Flutter Stream Builder Triggered when Navigator Pop or Push is Called

烈酒焚心 提交于 2019-12-04 13:53:59
I have a stream builder in the app's home/root page. This stream builder gets triggered whenever I do a page-navigation elsewhere, which has nothing to do with the stream itself. My understanding, according to here and here , is when a page is popped/pushed in the navigator, it triggers a rebuild on the app, so the stream builder gets re-attached and so it fires. However this seems inefficient, so is there a way to prevent the stream builder from firing when a page is popped/pushed? Additionally, according to the logs, when I push a page, the page is built and shown first, then the stream

ListView inside Column causes 'Vertical viewport was given unbounded height'

帅比萌擦擦* 提交于 2019-12-04 12:08:13
I am new to flutter and having trouble with layouts. I want something like this: A sticky header and a scroll view below it. I thought of using Column widget with two children - first being the header and second being the ListView. Here is my code Widget build(BuildContext context) { return Material( elevation: 8.0, child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ Padding( padding: const EdgeInsets.all(16.0), child: Text( title, style: Theme.of(context).textTheme.subhead.copyWith(fontSize: 18.0), textAlign: TextAlign.left, ), ), Divider(height: 4.0), ListView

Flutter TabBar and SliverAppBar that hides when you scroll down

百般思念 提交于 2019-12-04 10:54:55
问题 I am trying to create an app with a top application bar and a tab bar below. When you scroll down, the bar should hide by moving off the screen (but tabs should stay), and when you scroll back up, the application bar should show again. This behaviour can be seen in WhatsApp. Please see this video for a demonstration. (Taken from Material.io). This is a similar behaviour, although the app bar and tab bar are hidden on scroll, so it is not exactly the behaviour I am looking for. I have been

Flutter - Why slider doesn't update in AlertDialog?

我们两清 提交于 2019-12-04 06:49:39
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 AlertDialog( title: const Text('Criar novo cartão'), actions: <Widget>[ new FlatButton(onPressed: () { Navigator

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

不问归期 提交于 2019-12-04 05:38:15
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: TextInputType.multiline, maxLines: 4, ), TextField( decoration: InputDecoration(hintText: 'Additional details!')

Nested FutureBuilder vs nested calls for lazy loading from database

寵の児 提交于 2019-12-04 05:31:56
问题 I need to choose best approach between two approaches that I can follow. I have a Flutter app that use sqflite to save data, inside the database I have two tables: Employee: +-------------+-----------------+------+ | employee_id | employee_name |dep_id| +-------------+-----------------+------+ | e12 | Ada Lovelace | dep1 | +-------------+-----------------+------+ | e22 | Albert Einstein | dep2 | +-------------+-----------------+------+ | e82 | Grace Hopper | dep3 | +-------------+------------

Drop down button in flutter not switching values to the selected value

旧城冷巷雨未停 提交于 2019-12-04 03:17:56
I've recently started programming using dart and flutter and everything has been going smoothly for my app, although recently i wanted to add drop down menu to provide the user with multiple options to pick from. everything worked as planned however when i pick a value from the list it doesn't change the value in the box, it goes back to the hint or an empty box. any help would be appreciated! here is my code for the dropdownbutton: Widget buildDropdownButton() { String newValue; return new Padding( padding: const EdgeInsets.all(24.0), child: new Column( mainAxisAlignment: MainAxisAlignment