flutter-layout

How to get current tab index in Flutter

倾然丶 夕夏残阳落幕 提交于 2019-11-27 06:53:24
问题 In flutter implementing a tab layout is easy and straightforward. This is a simple example from the official documentation: import 'package:flutter/material.dart'; void main() { runApp(new TabBarDemo()); } class TabBarDemo extends StatelessWidget { @override Widget build(BuildContext context) { return new MaterialApp( home: new DefaultTabController( length: 3, child: new Scaffold( appBar: new AppBar( bottom: new TabBar( tabs: [ new Tab(icon: new Icon(Icons.directions_car)), new Tab(icon: new

How to create a dynamic TabBarView/ Render a new Tab with a function in Flutter?

给你一囗甜甜゛ 提交于 2019-11-27 03:38:01
问题 So I have been learning flutter in a while and I am stuck in this. Sorry if it is a noobish question. I am currently trying to build something like a Card Tab. The information and widget will be stored in a card. Imagine something like Tinder, where they have multiple card stack and swipe left and right to navigate. I plan to create that but I cannot seems to find a way to add/render a new card with a button. It's like adding something to the list, Flutter will use a ListView builder where we

Bottom overflow by 30px

大城市里の小女人 提交于 2019-11-27 03:28:26
问题 I face a problem by wrapping TextField with new Expanded() . When try to search something in textfield its show me bottom overflow by 30px . Below is my code: Widget build(BuildContext context) { return new Scaffold( body: Column( children: <Widget>[ Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: <Widget>[ IconButton(icon: Icon(Icons.search), onPressed: () { setState(() { }); }), new Flexible( child: new TextField( onChanged: (String value) { onchange(value); }, maxLines: 1

Builder versus GlobalKey

纵然是瞬间 提交于 2019-11-27 02:53:42
问题 Numerous questions relating to building Flutter UIs come down to the wrong BuildContext (such as showing a SnackBar ). The answers usually offer either of using a Builder or using a GlobalKey . Both work, but I noticed that the documentation for GlobalKey states: Global keys are relatively expensive. If you don't need any of the features listed above, consider using a Key , ValueKey , ObjectKey , or UniqueKey instead. The features referred to are unique identification and subtree re-parenting

Show alert dialog on app main screen load automatically in flutter

匆匆过客 提交于 2019-11-27 02:45:56
问题 I want to show alert dialog based on a condition. Not based on user interaction such as button press event. If a flag is set in app state data alert dialog is shown otherwise its not. Below is the sample alert dialog which I want to show void _showDialog() { // flutter defined function showDialog( context: context, builder: (BuildContext context) { // return object of type Dialog return AlertDialog( title: new Text("Alert Dialog title"), content: new Text("Alert Dialog body"), actions:

how to animate collapse elements in flutter

断了今生、忘了曾经 提交于 2019-11-27 01:59:22
问题 How can i expand and collapse widget when user taps on different widget ( sibling or parent ) with animation ? new Column( children: <Widget>[ new header.IngridientHeader( new Icon( Icons.fiber_manual_record, color: AppColors.primaryColor ), 'Voice Track 1' ), new Grid() ], ) I want user to be able to tap on header.IngridientHeader and then Grid widget should toggle ( hide if visible and other way around ) edit: im trying to do something that in bootstrap is called Collapse. getbootstrap.com

How to render a local HTML file with flutter dart webview

白昼怎懂夜的黑 提交于 2019-11-27 01:57:41
问题 I want to render a local HTML file stored in my phone memory in webview using flutter and dart. 回答1: Here is an answer with a little more detail. I am using the webview_flutter plugin from the Flutter Team. Steps Add the dependency to pubspec.yaml : dependencies: webview_flutter: ^0.3.4 Put an html file in the assets folder (see this). I'll call it help.html . Get the html string in code and add it to the webview. import 'dart:convert'; import 'package:flutter/material.dart'; import 'package

How to add image in Flutter

点点圈 提交于 2019-11-27 00:42:50
问题 I am developing Flutter app for the first time.. I have an issue in adding a image. I have a below questions : Where to create images folder? Where to add assets tag in pubspec.ymal? Is there any assets folder needed for this? What I tried : assets: - images/lake.jpg inside pubspec.ymal : Full file : name: my_flutter_app description: A new Flutter application. dependencies: flutter: sdk: flutter cupertino_icons: ^0.1.2 dev_dependencies: flutter_test: sdk: flutter flutter: uses-material-design