How can we change appbar background color in flutter

Declare your Color: const primaryColor = Color(0xFF151026); In the MaterialApp level (will change the AppBar Color in the whole app ) change primaryColor return MaterialApp( title: ‘Flutter Demo’, theme: ThemeData( primaryColor: primaryColor, ), home: MyApp(), ); and if you want to change it on the Widget level modify the backgroundColor appBar: AppBar( backgroundColor: primaryColor, ),

Outlined transparent button with gradient border in flutter

I spent about two hours on it 🙂 how to use: import ‘package:flutter/material.dart’; void main() => runApp(App()); class App extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( home: Scaffold( body: SafeArea( child: Center( child: Column( mainAxisSize: MainAxisSize.min, children: <Widget>[ UnicornOutlineButton( strokeWidth: 2, radius: 24, gradient: LinearGradient(colors: [Colors.black, Colors.redAccent]), child: Text(‘OMG’, style: TextStyle(fontSize: 16)), … Read more

Flutter TabBar and SliverAppBar that hides when you scroll down

You need to use SliverOverlapAbsorber/SliverOverlapInjector, the following code works for me (Full Code): @override Widget build(BuildContext context) { return Material( child: Scaffold( body: DefaultTabController( length: _tabs.length, // This is the number of tabs. child: NestedScrollView( headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) { // These are the slivers that show up in the “outer” scroll view. return … Read more

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

Flutter – How to make a custom TabBar

You can use the TabBar widget to achieve this. I added a full example demonstrating how you can create this using the TabBar widget: CODE class StackOver extends StatefulWidget { @override _StackOverState createState() => _StackOverState(); } class _StackOverState extends State<StackOver> with SingleTickerProviderStateMixin { TabController _tabController; @override void initState() { _tabController = TabController(length: 2, vsync: this); … Read more

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

Maybe a more optimal way exists, but as an option this is an example with two pages, local navigator and Overlay. import ‘package:flutter/material.dart’; void main() => runApp(MyApp()); class MyApp extends StatefulWidget { @override _MyAppState createState() => _MyAppState(); } class _MyAppState extends State<MyApp> { final _navigatorKey = GlobalKey<NavigatorState>(); @override Widget build(BuildContext context) { return MaterialApp( debugShowCheckedModeBanner: … Read more

Preserving state between tab view pages

In case you want to keep the state of your screen in your TabBarView, you can use the mixin class called AutomaticKeepAliveClientMixin in your State class. After that you have to override the wantKeepAlive method and return true. It will looks like something that : class _SearchScreenState extends State<SearchScreen> with AutomaticKeepAliveClientMixin<SearchScreen>{ … @override Widget build(BuildContext … Read more

How to detect orientation change in layout in Flutter?

In order to determine the Orientation of the screen, we can use the OrientationBuilder Widget. The OrientationBuilder will determine the current Orientation and rebuild when the Orientation changes. new OrientationBuilder( builder: (context, orientation) { return new GridView.count( // Create a grid with 2 columns in portrait mode, or 3 columns in // landscape mode. crossAxisCount: … Read more