-
-
Notifications
You must be signed in to change notification settings - Fork 280
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
7 changed files
with
98 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
packages/smooth_app/lib/pages/scan/inherited_data_manager.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
class InheritedDataManager extends StatefulWidget { | ||
const InheritedDataManager({ | ||
Key? key, | ||
required this.child, | ||
}) : super(key: key); | ||
|
||
final Widget child; | ||
|
||
static InheritedDataManagerState of(BuildContext context) { | ||
return context | ||
.dependOnInheritedWidgetOfExactType<_InheritedDataManagerProvider>()! | ||
.data; | ||
} | ||
|
||
@override | ||
State<InheritedDataManager> createState() => InheritedDataManagerState(); | ||
} | ||
|
||
class InheritedDataManagerState extends State<InheritedDataManager> { | ||
late bool showSearchCard; | ||
|
||
@override | ||
void initState() { | ||
showSearchCard = false; | ||
super.initState(); | ||
} | ||
|
||
void resetShowSearchCard(bool newValue) { | ||
setState(() { | ||
showSearchCard = newValue; | ||
}); | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return _InheritedDataManagerProvider( | ||
data: this, | ||
child: widget.child, | ||
); | ||
} | ||
} | ||
|
||
class _InheritedDataManagerProvider extends InheritedWidget { | ||
const _InheritedDataManagerProvider({ | ||
Key? key, | ||
required this.data, | ||
required Widget child, | ||
}) : super(key: key, child: child); | ||
|
||
final InheritedDataManagerState data; | ||
|
||
@override | ||
bool updateShouldNotify(_InheritedDataManagerProvider oldWidget) { | ||
return data.showSearchCard; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters