Home › All › How to add gradient color in AppBar in Flutter How to add gradient color in AppBar in Flutter All Flutter 教學2019-03-25 8,805 2 Share: facebook twitter whatsapp pinterest linkedin You can specify a widget to the flexibleSpace property to change the background of the AppBar. import 'package:flutter/material.dart'; void main() => runApp(MyApp()); class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( title: 'Flutter Demo', home: Scaffold( appBar: AppBar( title: Text('Flutter Demo'), flexibleSpace: Container( decoration: BoxDecoration( gradient: LinearGradient( begin: Alignment.centerLeft, end: Alignment.centerRight, colors: <Color>[ Colors.red, Colors.blue ], ), ), ), ), ), ); } } DartCopy AppBarFluttergradientgradient AppBartutorial
THANKS~
THANKS A LOT!!!