I am writing an application in flutter that has 4 tabbed views, kinda like the stock android phone app or clock app. One of those views hash a floating action button that when pressed will add some text in a list. However, when I scroll to one of the other views and come back, all of the text is gone. Is there a way to fix this?
Here is my code:
import 'package:flutter/material.dart';
import 'Screens/Dashboard.dart';
import 'Screens/CreateQuestionnaire.dart';
import 'Screens/AccountScreen.dart';
void main() => runApp(new MyApp());
class MyApp extends StatefulWidget {
@override
createState() => new MyAppState();
}
class MyAppState extends State<MyApp> {
final primaryColour = const Color(0xFF5CA1CA);
final secondaryColour = const Color(0xFFC36B42);
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return new MaterialApp(
home: new DefaultTabController(
length: 4,
child: new Scaffold(
appBar: new AppBar(
actions: <Widget>[
new IconButton(icon: new Icon(Icons.account_circle),
onPressed: (){
Navigator.push(context, new MaterialPageRoute(builder: (context) => new AccountScreen()));
}),
],
bottom: new TabBar(
tabs: <Widget>[
new Tab(icon: new Icon(Icons.home)),
new Tab(icon: new Icon(Icons.contacts)),
new Tab(icon: new Icon(Icons.description)),
new Tab(icon: new Icon(Icons.settings))
],
),
title: new Text("NLPro Questionnaire"),
),
body: new TabBarView(
children: <Widget>[
new Dashboard(),
new CreateQuestionnaire(),
new Text("Surveys"),
new Text("Settings")
],
),
),
),
theme:new ThemeData(
primaryColor: primaryColour,
accentColor: secondaryColour,
),
);
}
}