home page: avoid refetching sheets on rebuild
This commit is contained in:
@@ -25,11 +25,13 @@ class _MyHomePageState extends State<MyHomePage> {
|
|||||||
String? appName;
|
String? appName;
|
||||||
String? appVersion;
|
String? appVersion;
|
||||||
bool shuffling = false;
|
bool shuffling = false;
|
||||||
|
late final Future<List<Sheet>> sheets;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
_loadAppInfo();
|
_loadAppInfo();
|
||||||
|
sheets = acquireSheets();
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _loadAppInfo() async {
|
Future<void> _loadAppInfo() async {
|
||||||
@@ -148,7 +150,7 @@ class _MyHomePageState extends State<MyHomePage> {
|
|||||||
appBar: AppBar(title: const Text("Sheetless")),
|
appBar: AppBar(title: const Text("Sheetless")),
|
||||||
endDrawer: _buildDrawer(),
|
endDrawer: _buildDrawer(),
|
||||||
body: FutureBuilder(
|
body: FutureBuilder(
|
||||||
future: acquireSheets(),
|
future: sheets,
|
||||||
builder: (BuildContext context, AsyncSnapshot<List<Sheet>> snapshot) {
|
builder: (BuildContext context, AsyncSnapshot<List<Sheet>> snapshot) {
|
||||||
if (snapshot.hasData) {
|
if (snapshot.hasData) {
|
||||||
return SheetsWidget(
|
return SheetsWidget(
|
||||||
|
|||||||
Reference in New Issue
Block a user