This file contains hidden or 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
// register that SearchBar will need these callbacks | |
SearchBar({ | |
Key key, | |
@required this.onCancelSearch, | |
@required this.onSearchQueryChanged, | |
}) : super(key: key); | |
final VoidCallback onCancelSearch; | |
final Function(String) onSearchQueryChanged; |
This file contains hidden or 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
// add this method to default app bar class | |
// this will get executed when user pressed back arrow on search bar | |
cancelSearch() { | |
// remove search bar from stack | |
setState(() { | |
isInSearchMode = false; | |
}); | |
// change search value to '' | |
onSearchQueryChange(''); |
This file contains hidden or 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
class SearchBar extends StatefulWidget implements PreferredSizeWidget { | |
@override | |
Size get preferredSize => Size.fromHeight(56.0); | |
@override | |
_SearchBarState createState() => _SearchBarState(); | |
} | |
class _SearchBarState extends State<SearchBar> with SingleTickerProviderStateMixin { | |
String searchQuery = ''; |
This file contains hidden or 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
bool isInSearchMode = false; | |
// inside initState register our status listener | |
_controller.addStatusListener(animationStatusListener); | |
// add this method to our DefaultAppBar widget | |
animationStatusListener(AnimationStatus animationStatus) { | |
if (animationStatus == AnimationStatus.completed) { | |
setState(() { | |
isInSearchMode = true; |
This file contains hidden or 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
// add SingleTickerProviderStateMixin to our State widget | |
class _DefaultAppBarState extends State<DefaultAppBar> with SingleTickerProviderStateMixin { | |
} | |
// intialize animation and controller | |
AnimationController _controller; | |
Animation _animation; | |
@override | |
initState() { |
This file contains hidden or 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
class MyPainter extends CustomPainter { | |
final Offset center; | |
final double radius, containerHeight; | |
final BuildContext context; | |
Color color; | |
double statusBarHeight, screenWidth; | |
MyPainter({this.context, this.containerHeight, this.center, this.radius}) { | |
ThemeData theme = Theme.of(context); |
This file contains hidden or 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
double rippleStartX, rippleStartY; | |
void onSearchTapUp(TapUpDetails details) { | |
setState(() { | |
rippleStartX = details.globalPosition.dx; | |
rippleStartY = details.globalPosition.dy; | |
}); | |
print("pointer location $rippleStartX, $rippleStartY"); | |
} |
This file contains hidden or 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
class DefaultAppBar extends StatefulWidget implements PreferredSizeWidget { | |
@override | |
Size get preferredSize => Size.fromHeight(56.0); | |
@override | |
_DefaultAppBarState createState() => _DefaultAppBarState(); | |
} | |
class _DefaultAppBarState extends State<DefaultAppBar> { | |
@override |
This file contains hidden or 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
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 |