flutter-layout

Flutter - Can a ListView contain a static widget and a stream

心已入冬 提交于 2020-03-23 03:53:43
问题 Currently my I have a ListView that is warped by a StreamBuilder which gets data from firebase firestore (e.g a list of users). This is how it looks: Widget UsersList = new StreamBuilder( stream: Firestore.instance .collection('users') .snapshots(), builder: (context, snapshot) { if (!snapshot.hasData) return const Text("loading"); return new ListView.builder( itemCount: snapshot.data.documents.length, itemBuilder: (context, index) => _buildItem(context, snapshot.data.documents[index]), ); }

Flutter - Can a ListView contain a static widget and a stream

眉间皱痕 提交于 2020-03-23 03:53:11
问题 Currently my I have a ListView that is warped by a StreamBuilder which gets data from firebase firestore (e.g a list of users). This is how it looks: Widget UsersList = new StreamBuilder( stream: Firestore.instance .collection('users') .snapshots(), builder: (context, snapshot) { if (!snapshot.hasData) return const Text("loading"); return new ListView.builder( itemCount: snapshot.data.documents.length, itemBuilder: (context, index) => _buildItem(context, snapshot.data.documents[index]), ); }

How to overlay a widget on top of a flutter App?

倾然丶 夕夏残阳落幕 提交于 2020-03-22 05:52:14
问题 I want a widget that will sit on top of the entire application. When I have tried to do this with Overlay.of(context).insert the overlay would later disappear after replacing that route. Is there a way I can have a widget on top of my app even if the screen is later popped? 回答1: may be more optimal way is existed but as an option this is example with two pages, local navigator and Overlay import 'package:flutter/material.dart'; void main() => runApp(MyApp()); class MyApp extends

How to overlay a widget on top of a flutter App?

北城余情 提交于 2020-03-22 05:51:05
问题 I want a widget that will sit on top of the entire application. When I have tried to do this with Overlay.of(context).insert the overlay would later disappear after replacing that route. Is there a way I can have a widget on top of my app even if the screen is later popped? 回答1: may be more optimal way is existed but as an option this is example with two pages, local navigator and Overlay import 'package:flutter/material.dart'; void main() => runApp(MyApp()); class MyApp extends

Flutter - cannot use Flexible inside Padding for text wrapping purpose

霸气de小男生 提交于 2020-03-17 03:22:33
问题 In my flutter app, I want to have a card and four boxes aligned horizontally with equal width and height inside it. Code follows ; @override Widget build(BuildContext context) { return MaterialApp( home: Scaffold( body: Container( padding: EdgeInsets.fromLTRB(20,10,10,0), height: 220, width: double.maxFinite, child: Card( elevation: 5, child: Column( children: <Widget>[ Row( children: <Widget>[ Expanded( child: Container( height:25, color:Color(0xff6898F7), child: Text('Online Pharmacy',

Flutter: How to open Drawer programmatically

你离开我真会死。 提交于 2020-03-13 06:34:09
问题 I want to open Drawer programmatically not by sliding it, how to disable that sliding functionality (touch functionality of Drawer) 回答1: Hacky but it works. To disable the slide to open functionality you can set the property drawerEdgeDragWidth on Scaffold to 0. @override Widget build(BuildContext context) { return Scaffold( drawerEdgeDragWidth: 0, // THIS WAY IT WILL NOT OPEN drawer: Drawer(), appBar: AppBar( leading: IconButton( icon: Icon(Icons.menu), onPressed: () { Scaffold.of(context)

Flutter app on start it is showing white screen for few second

守給你的承諾、 提交于 2020-03-12 02:12:20
问题 Why my flutter app showing white screen for few sec on start and how to solve this issue ? 回答1: You can overwrite this splash screen inside platform specific code. See here examples of how to do that. 回答2: If you see the black window background of the activity showing until Flutter renders its first frame, add this on your AndroidManifest , between < activity> ... < /activity> <meta-data android:name="io.flutter.embedding.android.SplashScreenDrawable" android:resource="@drawable/launch

TextInput in TextFormField Get Bottom Padded If suffixIcon or prefixIcon Property of InputDecoration is Used

眉间皱痕 提交于 2020-03-05 03:11:27
问题 Top picture: Normal good looking TextFormField without supplying any Widget for suffixIcon Bottom picture: Suppyling Icon Widget for suffixIcon makes the Text input floating unnecessarily Any idea what's causing this? Code: It's a plain TextFormField with suffixIcon TextFormField( decoration: InputDecoration( suffixIcon: Icon(Icons.search), ) ) 回答1: This may not the best approach, but it works. You can wrap TextFormField with a Container . This can make the text and icon in same row. Padding(

How to crop the png image and remove its unused space using Canvas in flutter?

坚强是说给别人听的谎言 提交于 2020-03-04 20:48:07
问题 This attachment is from the rendered canvas image which is saved locally via canvas. In image I have drawn the square box which I want to render in canvas and save locally without left and right extra spaces . I just want to save the square box and remove that unnecessary space of PNG-image. So, how to do this? widget-source-code: return CustomPaint( painter: PngImageCropper(image: image), ); PngImageCropper-code class PngImageCropper extends CustomPainter { PngImageCropper({ this.image, });

Detect when user is not interacting the app in Flutter

妖精的绣舞 提交于 2020-03-01 05:21:36
问题 I want to show some Screensaver type of screen when the user is not interacting the app for 5 minutes. So is anyone know how to achieve this kind of functionality in flutter. import 'dart:async'; import 'package:flutter/material.dart'; const timeout = const Duration(seconds: 10); const ms = const Duration(milliseconds: 1); Timer timer; void main() => runApp(MyApp()); class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { var home = MyHomePage(title: 'Flutter Demo