Flutter Drawer when menu icon is tapped - flutter

I am currently trying out drawer widget. I have constructed an appbar with a hamburger menu icon, title text and a search icon.
Here is my code:
`
import 'package:flutter/material.dart';
import 'package:hexcolor/hexcolor.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
#override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: HomePage(),
);
}
}
class HomePage extends StatefulWidget {
#override
_HomePageState createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
#override
Widget build(BuildContext context) {
return SafeArea(
child: Scaffold(
appBar: PreferredSize(
child: Container(
color: Colors.white,
padding:
EdgeInsets.only(left: 10, right: 10, top: 10, bottom: 10),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Icon(Icons.menu),
Text(
'Appbar',
style: TextStyle(fontWeight: FontWeight.bold),
),
Icon(Icons.search)
],
),
),
preferredSize: Size.fromHeight(40)),
backgroundColor: Hexcolor('#e9f1fe'),
body: Center(
child: Text('Experimenting drawer'),
)));
}
}
`
Here is the output :,
Also I have a separate dart file for a custom drawer I want to be displayed when the hamburger menu icon is tapped. How can I make that possible?
Here is the code for custom drawer:
import 'package:flutter/material.dart';
class DrawerScreen extends StatefulWidget {
#override
_DrawerScreenState createState() => _DrawerScreenState();
}
class _DrawerScreenState extends State<DrawerScreen> {
#override
Widget build(BuildContext context) {
return Scaffold(
drawer: Drawer(
child: Column(
children: [
ListTile(
leading: CircleAvatar(
radius: 28,
backgroundColor: Colors.blueGrey,
child: CircleAvatar(
radius: 50,
backgroundImage: AssetImage('assets/images/joker.jpg'),
),
),
title: Text(
'Joaquin Phoenix',
style: TextStyle(
color: Colors.black,
fontFamily: 'Roboto',
fontWeight: FontWeight.bold,
fontSize: 14,
),
),
subtitle: Text(
"You wouldn't get it",
style: TextStyle(
color: Colors.black,
fontFamily: 'Roboto',
fontWeight: FontWeight.w400,
fontSize: 10.0),
),
)
],
)),
backgroundColor: Colors.blue[50],
);
}
}

You can copy paste run two full code below
Step 1: _DrawerScreenState remove Scaffold
Step 2: For drawer background color, you can wrap with Theme
class _DrawerScreenState extends State<DrawerScreen> {
#override
Widget build(BuildContext context) {
return Theme(
data: Theme.of(context).copyWith(
canvasColor: Colors.blue[50],
),
child: Drawer(
Step 3: Use DrawerScreen() in main.dart
SafeArea(
child: Scaffold(
drawer: DrawerScreen(),
Step 4: wrap Icons.menu with Builder and open with openDrawer()
Builder(
builder: (context) => GestureDetector(
onTap: () {
Scaffold.of(context).openDrawer();
},
child: Icon(Icons.menu)),
),
working demo
full code main.dart
import 'package:flutter/material.dart';
import 'package:hexcolor/hexcolor.dart';
import 'drawer.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
#override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: HomePage(),
);
}
}
class HomePage extends StatefulWidget {
#override
_HomePageState createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
#override
Widget build(BuildContext context) {
return SafeArea(
child: Scaffold(
drawer: DrawerScreen(),
appBar: PreferredSize(
child: Container(
color: Colors.white,
padding:
EdgeInsets.only(left: 10, right: 10, top: 10, bottom: 10),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Builder(
builder: (context) => GestureDetector(
onTap: () {
Scaffold.of(context).openDrawer();
},
child: Icon(Icons.menu)),
),
Text(
'Appbar',
style: TextStyle(fontWeight: FontWeight.bold),
),
Icon(Icons.search)
],
),
),
preferredSize: Size.fromHeight(40)),
backgroundColor: Hexcolor('#e9f1fe'),
body: Center(
child: Text('Experimenting drawer'),
)));
}
}
full code drawer.dart
import 'package:flutter/material.dart';
class DrawerScreen extends StatefulWidget {
#override
_DrawerScreenState createState() => _DrawerScreenState();
}
class _DrawerScreenState extends State<DrawerScreen> {
#override
Widget build(BuildContext context) {
return Theme(
data: Theme.of(context).copyWith(
canvasColor: Colors.blue[50],
),
child: Drawer(
child: Column(
children: [
ListTile(
leading: CircleAvatar(
radius: 28,
backgroundColor: Colors.blueGrey,
child: CircleAvatar(
radius: 50,
backgroundImage: AssetImage('assets/images/joker.jpg'),
),
),
title: Text(
'Joaquin Phoenix',
style: TextStyle(
color: Colors.black,
fontFamily: 'Roboto',
fontWeight: FontWeight.bold,
fontSize: 14,
),
),
subtitle: Text(
"You wouldn't get it",
style: TextStyle(
color: Colors.black,
fontFamily: 'Roboto',
fontWeight: FontWeight.w400,
fontSize: 10.0),
),
)
],
)),
);
}
}

Related

Why am I getting dart:html not found?

I am trying to make a quiz app and the app is running perfectly but there is this passive error
lib/main.dart:4:8: Error: Not found: 'dart:html'
import 'dart:html';
Here is my code
import 'package:flutter/material.dart';
import 'dart:html';
void main() {
runApp(QuizApp());
}
List questionBank = [...];
class QuizApp extends StatefulWidget {
#override
State<QuizApp> createState() => _MyAppState();
}
class _MyAppState extends State<QuizApp> {
#override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: Home(),
);
}
}
class Home extends StatefulWidget {
#override
State<Home> createState() => _HomeState();
}
class _HomeState extends State<Home> {
int _currentQuestion = 0;
#override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(
"Quiz App",
style: TextStyle(
fontSize: 22,
fontWeight: FontWeight.bold,
color: Colors.black87,
),
),
centerTitle: true,
backgroundColor: Colors.lightBlueAccent.withOpacity(0.8),
),
backgroundColor: Colors.lightBlueAccent.withOpacity(0.8),
body: Builder(
builder: (BuildContext context) {
return Container(
child: Column(
children: [
Center(
child: Image.asset(
"images/quiz_icon_3.png",
height: 265,
)),
Container(
height: 120,
width: 350,
decoration: BoxDecoration(
border: Border.all(color: Colors.black87, width: 1.5),
borderRadius: BorderRadius.circular(22),
),
child: Center(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
questionBank[_currentQuestion].questionText,
style: TextStyle(
fontSize: 18.5,
color: Colors.black87,
),
),
)),
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
ElevatedButton(
onPressed: () => _checkAnswer(true, context),
child: Text(
"True",
style: TextStyle(
fontSize: 20.5,
fontWeight: FontWeight.bold,
color: Colors.black87,
),
),
style: ElevatedButton.styleFrom(
backgroundColor: Colors.blueGrey.shade700,
),
),
ElevatedButton(
onPressed: () => _checkAnswer(false, context),
child: Text(
"False",
style: TextStyle(
fontSize: 20.5,
fontWeight: FontWeight.bold,
color: Colors.black87,
),
),
style: ElevatedButton.styleFrom(
backgroundColor: Colors.blueGrey.shade700),
),
ElevatedButton(
onPressed: () => setState(() {
_nextQuestion();
}),
child: Icon(
Icons.arrow_forward_ios,
color: Colors.black87,
),
style: ElevatedButton.styleFrom(
backgroundColor: Colors.blueGrey.shade700),
)
],
)
],
),
);
}
),
);
}
_nextQuestion() {
if (_currentQuestion == questionBank.length - 1) {
_currentQuestion = 0;
} else {
_currentQuestion++;
}
}
_checkAnswer(bool useChoice, BuildContext context) {
if (questionBank[_currentQuestion].isTrue = useChoice) {
var correctBar = SnackBar(content: Text("CORRECT !"));
ScaffoldMessenger.of(context).showSnackBar(correctBar);
} else {
var falseBar = SnackBar(content: Text("False !"));
ScaffoldMessenger.of(context).showSnackBar(falseBar);
}
}
}
class Questions {
String questionText;
bool isTrue;
Questions(this.questionText, this.isTrue);
}
I have tried importing both dart:html and io, each seperate, but nothing
I suspect the error is related to the snackBar function, or the build widget I added.
Any help will be appreciated, thank you.
just curious.
Are you using "dart:html" for something?
I faced similar issues, and just removing
'import 'dart:html';
works for me, unless you really need it.
using import 'dart:html' in flutter - Do I need additional dependencies?

Text loses style during hero animation in Flutter

As you can see from the gif and from the code below I have a container and a text widget, both wrapped in a hero widget.
When the container is clicked the second page opens. I would like to have a hero animation for both widgets.
The animations of the container works great. The text however seems to lose the style while the transition is happening.
Any idea on how to fix it?
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
#override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: const HomeScreen(),
routes: {
HomeScreen.routName: (context) => const HomeScreen(),
SecondSceen.routeName: (context) => const SecondSceen(),
},
);
}
}
class HomeScreen extends StatelessWidget {
static const routName = '/home-screen';
const HomeScreen({super.key});
#override
Widget build(BuildContext context) {
return Scaffold(
body: Stack(children: [
Align(
alignment: Alignment.bottomCenter,
child: InkWell(
onTap: () => Navigator.of(context).pushNamed(SecondSceen.routeName),
child: Hero(
tag: 'box',
child: Container(
color: Colors.amber,
width: MediaQuery.of(context).size.width * 0.8,
height: 210,
),
),
),
),
Align(
alignment: Alignment.bottomCenter,
child: SizedBox(
width: MediaQuery.of(context).size.width * 0.8,
height: 210,
child: Padding(
padding: const EdgeInsets.fromLTRB(16, 16, 8, 16),
child: Column(
children: const [
Hero(
tag: 'text',
child: Text(
"MY HEADER",
style:
TextStyle(fontSize: 28, fontWeight: FontWeight.bold),
),
),
],
),
),
),
),
]),
);
}
}
class SecondSceen extends StatelessWidget {
static const routeName = '/note-screen';
const SecondSceen({super.key});
#override
Widget build(BuildContext context) {
return Scaffold(
extendBodyBehindAppBar: true,
appBar: AppBar(
backgroundColor: Colors.transparent,
shadowColor: Colors.transparent,
foregroundColor: Colors.black,
centerTitle: true,
title: const Hero(
tag: 'text',
child: Text(
"MY HEADER",
style: TextStyle(fontSize: 28, fontWeight: FontWeight.bold),
),
),
),
body: Stack(children: [
Hero(
tag: 'box',
child: Container(
color: Colors.amber,
),
),
]),
);
}
}
Instead of using individual TextStyle objects, use some style coming from the context. This way even during the animation, the styles will be based on the Theme of your MaterialApp.
For both Text widgets, instead of:
style: TextStyle(fontSize: 28, fontWeight: FontWeight.bold),
try:
style: Theme.of(context).textTheme.headline6, // or some other style
(You will need to remove const keywords because these are no longer constants.)
You can easily customize any built in style using copyWith, for example:
style: Theme.of(context).textTheme.headline6!.copyWith(
fontSize: 28,
fontWeight: FontWeight.bold),
In general it is a good practice in my opinion to use Theme styles.

BottomNavigationBar covered by body colour in Flutter

I am using the convex_bottom_bar as my bottom navigation bar in Flutter.
With Style: TabStyle.react if I set a colour of the container widget in the body it covers the convex ‘curve’ of the active tab of the navigation bar. If no colour is set the curve can be seen fine.
main.dart
import 'package:convex_bottom_bar/convex_bottom_bar.dart';
import 'package:flutter/material.dart';
import 'custom.dart';
import 'game_start.dart';
import 'news.dart';
import 'settings.dart';
import 'share.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
#override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: MainPage(title: 'Flutter Convex BottomBar Sample'),
);
}
}
class MainPage extends StatefulWidget {
MainPage({Key? key, required this.title}) : super(key: key);
final String title;
#override
_MainPageState createState() => _MainPageState();
}
class _MainPageState extends State<MainPage> {
int selectedIndex = 2;
List<Widget> listWidgets = [
News(),
Custom(),
GameStart(),
Share(),
Settings()
];
#override
Widget build(BuildContext context) {
return Scaffold(
body: Container(
child: listWidgets[selectedIndex],
),
bottomNavigationBar: ConvexAppBar(
style: TabStyle.react,
items: [
TabItem(icon: Icons.star, title: 'News'),
TabItem(icon: Icons.fact_check, title: 'Custom'),
TabItem(icon: Icons.play_arrow, title: 'Play'),
TabItem(icon: Icons.share, title: 'Share'),
TabItem(icon: Icons.settings, title: 'Settings'),
],
onTap: onItemTapped,
color: Color(0xFFffc400),
activeColor: Color(0xFFffc400),
backgroundColor: Colors.black87,
height: 50,
initialActiveIndex: 2,
),
);
}
void onItemTapped(int index) {
setState(() {
selectedIndex = index;
});
}
}
game_start.dart
import 'package:flutter/material.dart';
class GameStart extends StatelessWidget {
#override
Widget build(BuildContext context) {
return Container(
color: Color(0xFF000000),
child: Center(
child: Text(
"Start Game",
style: TextStyle(
fontWeight: FontWeight.bold, fontSize: 22, color: Colors.green),
),
),
);
}
}
news.dart
import 'package:flutter/material.dart';
class News extends StatelessWidget {
#override
Widget build(BuildContext context) {
return Container(
color: Color(0xFF000000),
child: Center(
child: Text(
"News",
style: TextStyle(
fontWeight: FontWeight.bold, fontSize: 22, color: Colors.green),
),
),
);
}
}
The issue is with the plugin. The body container applies to the convex part. You can overcome this issue by stacking the body and convexappbar.
class _MainPageState extends State<MainPage> {
int selectedIndex = 2;
List<Widget> listWidgets = [
Container(color: Colors.black,),
Container(color: Colors.red),
Container(color: Colors.yellow),
Container(color: Colors.amber,),
Container(color: Colors.white,)
];
#override
Widget build(BuildContext context) {
return Scaffold(
body: Stack(
alignment: Alignment.bottomCenter,
children: [
Container(
child: listWidgets[selectedIndex],
),
ConvexAppBar(
style: TabStyle.react,
items: [
TabItem(icon: Icons.star, title: 'News'),
TabItem(icon: Icons.fact_check, title: 'Custom'),
TabItem(icon: Icons.play_arrow, title: 'Play'),
TabItem(icon: Icons.share, title: 'Share'),
TabItem(icon: Icons.settings, title: 'Settings'),
],
onTap: onItemTapped,
color: Color(0xFFffc400),
activeColor: Color(0xFFffc400),
backgroundColor: Colors.black87,
height: 50,
initialActiveIndex: 2,
elevation: 5
)
],
),
);
}
void onItemTapped(int index) {
setState(() {
selectedIndex = index;
});
}
}
The is no visual difference between the bottom navbar and body.
black87 doesn't mean it is grey. It is black with an opacity of 87% and the alpha fills based on the body colour. If possible try to switch the colour for the body and bottom navbar.
The issue is both GameStart'sContainer color and backgroundColor ofConvexAppBar are black, That's why it makes no difference in our eyes.
If you change the color of the container, you will be alble see the curve,
class GameStart extends StatelessWidget {
#override
Widget build(BuildContext context) {
return Center(
child: Container(
color: Color.fromARGB(255, 17, 255, 49),
child: Center(
child: Text(
"Start Game",
style: TextStyle(
fontWeight: FontWeight.bold, fontSize: 22, color: Colors.green),
),
),
),
);
}
}

Why is the Text widget 's line height changes from English to Chinese?

With this code
Center(
child: Text(
'hello 你好',
style: TextStyle(backgroundColor: Colors.red, fontSize: 24),
),
)
It seems the Chinese will got a larger height than English ? Can i make them have a same height ?
The different text height is caused by different font family.
Would you change font that supports Chinese and English?
https://fonts.google.com/?subset=chinese-simplified&preview.text=%E4%BD%A0%E5%A5%BDHello&preview.text_type=custom
Or if you want to make a text height same, below is the example.
Using 'strutStyle' parameter in Text, althouhg it is not convenient, you can modifying each text height is same.
https://medium.com/#najeira/control-text-height-using-strutstyle-4b9b5151668b
https://github.com/flutter/flutter/issues/38875
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
#override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
visualDensity: VisualDensity.adaptivePlatformDensity,
),
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() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
#override
void initState() {
super.initState();
}
#override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: _buildBody(),
floatingActionButton: FloatingActionButton(
onPressed: () {},
tooltip: 'Increment',
child: Icon(Icons.add),
),
);
}
Widget _buildBody() {
return Column(
children: [
Center(
child: Text(
'hello 你好',
style: TextStyle(backgroundColor: Colors.red, fontSize: 24),
),
),
SizedBox(height: 20),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
child: Text(
"hello",
style: TextStyle(
fontSize: 24,
),
strutStyle: StrutStyle(
height: 1.5,
fontSize: 24,
),
),
color: Colors.red,
),
Container(
child: Text(
"你好",
style: TextStyle(
fontSize: 24,
),
strutStyle: StrutStyle(
height: 1.5,
fontSize: 24,
),
),
color: Colors.red,
),
],
),
],
);
}
}

Theme Data not applying in inherited classes

I have declared a theme in main.dart , and it works fine as long as the context is used in main.dart but when I use Theme.of(context).primaryColor in the child class context doesn't pickup the theme.
Main.dart
class MyApp extends StatelessWidget {
#override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Expenso',
theme: ThemeData(
primarySwatch: Colors.green,
accentColor: Colors.amber
),
home: Expenso(),
);
}
}
class Expenso extends StatefulWidget {
#override
_ExpensoState createState() => _ExpensoState();
}
class _ExpensoState extends State<Expenso> {
final List<Transaction> _transactions=[
];
void _addTransaction(String txTitle,double txAmount)
{
final newTx=Transaction(
title: txTitle,
amount: txAmount,
id: DateTime.now().toString(),
date: DateTime.now()
);
setState(() {
_transactions.add(newTx);
});
}
void _startAddNewTransaction(BuildContext ctx) {
showModalBottomSheet(
context: ctx,
builder: (_) {
return GestureDetector(
onTap: () {},
child: NewTransaction(_addTransaction),
behavior: HitTestBehavior.opaque,
);
},
);
}
#override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
backgroundColor:Theme.of(context).primaryColor,
title: Text('Expenso'),
actions: <Widget>[
IconButton(
icon: Icon(Icons.add),
onPressed: () => _startAddNewTransaction(context),
)
],
),
body:SingleChildScrollView(
child: Column(
//mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
Container(
width: double.infinity,
height: 50,
child: Card(
color: Colors.blue,
child: Text('chart')
)
),
TransactionList(_transactions)
],
),
),
floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat,
floatingActionButton: FloatingActionButton(
child: Icon(Icons.add),
onPressed:() => _startAddNewTransaction(context),
backgroundColor: Theme.of(context).accentColor,
),
)
);
}
}
transaction_list.dart
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
import '../models/transaction.dart';
class TransactionList extends StatelessWidget {
final List<Transaction> tractn;
TransactionList(this.tractn);
#override
Widget build(BuildContext context) {
return Container(
height: 500,
child :tractn.isEmpty? Column(
children: <Widget>[
Text('No Transaction added yet'),
SizedBox(
height: 20,
),
Container(
height:300,
child: Image.asset('assets/Images/waiting.png',
fit: BoxFit.cover,),
)
],
): ListView.builder(
itemBuilder: (ctx,index){
return Card(
child: Row(
children: <Widget>[
Container(
margin: EdgeInsets.symmetric(
vertical: 10,
horizontal: 15,
),
decoration: BoxDecoration(border: Border.all(
color: Theme.of(context).primaryColor,
width: 2,
style: BorderStyle.solid
)
),
padding: EdgeInsets.all(10),
child: Text(
'₹ ${tractn[index].amount.toStringAsFixed(2)}',
style: TextStyle(
fontWeight: FontWeight.bold,
fontStyle: FontStyle.italic ,
fontSize: 20,
color: Colors.green,
),
),
),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
tractn[index].title,
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 15,
color: Theme.of(context).primaryColor
),
),
Text(
DateFormat().format(tractn[index].date) ,
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 15,
color: Colors.grey
),),
Text(
tractn[index].id
)
],
)
],
),
);
},
itemCount: tractn.length,
)
);
}
}
Please guide me the way to implement the theme in inherited classes
I Agree with #Nolence comment.
If you are expecting to achieve the below result
Remove MaterialApp widget and make Scaffold as your primate return widget inside
class _ExpensoState
Sample Code:
import 'package:flutter/material.dart';
import 'package:flutter_app/Transaction.dart';
import 'transaction_list.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
#override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Expenso',
theme: ThemeData(
primarySwatch: Colors.green,
accentColor: Colors.amber
),
home: Expenso(),
);
}
}
class Expenso extends StatefulWidget {
#override
_ExpensoState createState() => _ExpensoState();
}
class _ExpensoState extends State<Expenso> {
final List<Transaction> _transactions=[
];
void _addTransaction(String txTitle,double txAmount)
{
final newTx=Transaction(
title: txTitle,
amount: txAmount,
id: DateTime.now().toString(),
date: DateTime.now()
);
setState(() {
_transactions.add(newTx);
});
}
void _startAddNewTransaction(BuildContext ctx) {
showModalBottomSheet(
context: ctx,
builder: (_) {
return GestureDetector(
onTap: () {},
child: NewTransaction(_addTransaction),
behavior: HitTestBehavior.opaque,
);
},
);
}
#override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor:Theme.of(context).primaryColor,
title: Text('Expenso'),
actions: <Widget>[
IconButton(
icon: Icon(Icons.add),
onPressed: () => _startAddNewTransaction(context),
)
],
),
body:SingleChildScrollView(
child: Column(
//mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
Container(
width: double.infinity,
height: 50,
child: Card(
color: Colors.blue,
child: Text('chart')
)
),
TransactionList(_transactions)
],
),
),
floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat,
floatingActionButton: FloatingActionButton(
child: Icon(Icons.add),
onPressed:() => _startAddNewTransaction(context),
backgroundColor: Theme.of(context).accentColor,
),
);
}
}
If this is not what you wanted, please elaborate your question or comment below.
In the build method of your Expenso widget you define another MaterialApp, which creates its own default theme (different to your first theme). Remove that MaterialApp widget and it should work.