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
Widget _createDrawerItem( | |
{IconData icon, String text, GestureTapCallback onTap}) { | |
return ListTile( | |
title: Row( | |
children: <Widget>[ | |
Icon(icon), | |
Padding( | |
padding: EdgeInsets.only(left: 8.0), | |
child: Text(text), | |
) |
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
Widget _createHeader() { | |
return DrawerHeader( | |
margin: EdgeInsets.zero, | |
padding: EdgeInsets.zero, | |
decoration: BoxDecoration( | |
image: DecorationImage( | |
fit: BoxFit.fill, | |
image: AssetImage('res/images/drawer_header_background.png'))), | |
child: Stack(children: <Widget>[ | |
Positioned( |
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
import 'package:flutter/material.dart'; | |
class AppDrawer extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return Drawer( | |
child: ListView( | |
padding: EdgeInsets.zero, | |
children: <Widget>[ ], |
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
class MyHomePage extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
appBar: AppBar( | |
title: Text("NotificationListener example"), | |
), | |
body: NotificationListener<TimeNotification>( | |
child: Timer(), | |
onNotification: (notification) { |
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
class MyHomePage extends StatelessWidget { | |
final _counter = new ValueNotifier(0); | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
appBar: AppBar( | |
title: Text("ValueListenableBuilder example"), | |
), | |
body: CounterListenableProvider( |
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
class CounterText extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return ValueListenableBuilder<int>( | |
valueListenable: CounterListenableProvider.of(context), | |
builder: (context, value, child) { | |
return new Text(value.toString()); | |
}); | |
} |
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
static ValueListenable<int> of(BuildContext context) { | |
return (context.inheritFromWidgetOfExactType(CounterListenableProvider) | |
as CounterListenableProvider) | |
.counter; | |
} |
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
class CounterListenableProvider extends InheritedWidget { | |
final ValueListenable<int> counter; | |
CounterListenableProvider({Key key, @required this.counter, Widget child}) | |
: super(key: key, child: child); | |
@override | |
bool updateShouldNotify(InheritedWidget oldWidget) { | |
return true; | |
} |
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
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
appBar: AppBar( | |
title: Text("ValueListenableBuilder example"), | |
), | |
body: Center( | |
child: Column( | |
mainAxisAlignment: MainAxisAlignment.center, | |
children: <Widget>[ |
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
class MyHomePage extends StatelessWidget { | |
final _counter = new ValueNotifier<int>(0); | |
} |