How to create toolbar searchview in flutter

With the help @aziza answer i write detail code snippet of search view with list filter below. it will help for others import ‘package:flutter/material.dart’; class SearchList extends StatefulWidget { SearchList({ Key key }) : super(key: key); @override _SearchListState createState() => new _SearchListState(); } class _SearchListState extends State<SearchList> { Widget appBarTitle = new Text(“Search Sample”, style: … Read more

How to overlap SliverList on a SliverAppBar

I found an easier way to achieve that: import ‘package:flutter/material.dart’; void main() => runApp(MyApp()); class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( title: ‘How to overlap SliverList on a SliverAppBar’, debugShowCheckedModeBanner: false, theme: ThemeData( primarySwatch: Colors.blue, ), home: Home(), ); } } class Home extends StatelessWidget { @override Widget build(BuildContext context) … Read more

Flutter: Bottom sheet with TextField/TextFormField

You will have to provide a specific width to the TextField, simply provide width in your Container or wrap your Column in Expanded. Solution 1 Container( width: 100, // do it in both Container child: TextField(), ), Solution 2 Row( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: <Widget>[ Expanded( // wrap your Column in Expanded child: Column( … Read more

Error: RenderBox was not laid out, Failed assertion: line 1940 pos 12: ‘hasSize’

This happens when ListView has no constrained height which makes it gets an infinite height, you can solve this using two solutions add shrinkWrap: true as a parameter which will tell the ListView to use a little space as possible, Wrap your ListView with a constrained height widget, such as a SizedBox or a Container, … Read more

How to add drop shadow to TextFormField In Flutter

You can Wrap your TextFormField with a Material widget and edit its properties such as elevation and shadowColor. Example: Material( elevation: 20.0, shadowColor: Colors.blue, child: TextFormField( obscureText: true, autofocus: false, decoration: InputDecoration( icon: new Icon(Icons.lock, color: Color(0xff224597)), hintText: ‘Password’, fillColor: Colors.white, filled: true, contentPadding: EdgeInsets.fromLTRB(20.0, 10.0, 20.0, 10.0), enabledBorder: OutlineInputBorder(borderRadius:BorderRadius.circular(5.0), borderSide: BorderSide(color: Colors.white, width: 3.0)) … Read more

How can I put a widget above another widget in Flutter?

@override Widget build(BuildContext context) { // TODO: implement build return new Container( width: 150.0, height: 150.0, child: new Stack(children: <Widget>[ new Container( alignment: Alignment.center, color: Colors.redAccent, child: Text(‘Hello’), ), new Align(alignment: Alignment.bottomRight, child: FloatingActionButton( child: new Icon(Icons.add), onPressed: (){}), ) ], ), ); }

Sizing a container to exact half the screen size in flutter

If you want the container’s height to be the half of the available space, you can use LayoutBuilder widget. With LayoutBuilder widget, you can know inside the builder function what the max available width and height would be. The example usage in your case would be like this: Scaffold( appBar: AppBar(), body: Align( alignment: Alignment.topCenter, … Read more

What is the difference between ListView and SingleChildScrollView in Flutter?

You could consider ListView as an optimisation to the combination of SingleChildScrollView + Column. By using ListView, only the items that are visible are mounted and painted. On the other hand, by using SingleChildScrollView+Column, the entire item list is mounted+painted, even if only a few items are visible. The tradeoff is that ListView is less … Read more