What is the correct way to add date picker in flutter app?

A simple app showcasing its use: import ‘dart:async’; import ‘package:flutter/material.dart’; void main() => runApp(MyApp()); class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( title: ‘Flutter Demo’, home: MyHomePage(title: ‘Flutter Demo Home Page’), ); } } class MyHomePage extends StatefulWidget { MyHomePage({Key key, this.title}) : super(key: key); final String title; @override _MyHomePageState createState() … Read more

Custom Card Shape Flutter SDK

You can use it this way Card( shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(15.0), ), child: Text( ‘Card with circular border’, textScaleFactor: 1.2, ), ), Card( shape: BeveledRectangleBorder( borderRadius: BorderRadius.circular(10.0), ), child: Text( ‘Card with Beveled border’, textScaleFactor: 1.2, ), ), Card( shape: StadiumBorder( side: BorderSide( color: Colors.black, width: 2.0, ), ), child: Text( ‘Card with Stadium border’, … Read more

Flutter – Wrap text on overflow, like insert ellipsis or fade

You should wrap your Container in a Flexible to let your Row know that it’s ok for the Container to be narrower than its intrinsic width. Expanded will also work. Flexible( child: new Container( padding: new EdgeInsets.only(right: 13.0), child: new Text( ‘Text largeeeeeeeeeeeeeeeeeeeeeee’, overflow: TextOverflow.ellipsis, style: new TextStyle( fontSize: 13.0, fontFamily: ‘Roboto’, color: new Color(0xFF212121), … Read more

How to refresh an AlertDialog in Flutter?

Use StatefulBuilder to use setState inside Dialog and update Widgets only inside of it. showDialog( context: context, builder: (context) { String contentText = “Content of Dialog”; return StatefulBuilder( builder: (context, setState) { return AlertDialog( title: Text(“Title of Dialog”), content: Text(contentText), actions: <Widget>[ TextButton( onPressed: () => Navigator.pop(context), child: Text(“Cancel”), ), TextButton( onPressed: () { setState(() … Read more

How do I do the “frosted glass” effect in Flutter?

You can use the BackdropFilter widget to achieve this effect. import ‘dart:ui’; import ‘package:flutter/material.dart’; void main() { runApp(new MaterialApp(home: new FrostedDemo())); } class FrostedDemo extends StatelessWidget { @override Widget build(BuildContext context) { return new Scaffold( body: new Stack( children: <Widget>[ new ConstrainedBox( constraints: const BoxConstraints.expand(), child: new FlutterLogo() ), new Center( child: new ClipRect( child: … Read more

How to change background color of Elevated Button in Flutter from function?

You can style ElevatedButton by using the styleFrom static method or the ButtonStyle class. The first one is more convenience than the second one. Using styleFrom to style an ElevatedButton: ElevatedButton( child: Text(‘Button’), onPressed: () {}, style: ElevatedButton.styleFrom({ Color primary, // set the background color Color onPrimary, Color onSurface, Color shadowColor, double elevation, TextStyle textStyle, … Read more