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
| BillTextField( | |
| // 1 | |
| onChanged: (newAmount) { | |
| // 2 | |
| setState(() { | |
| _billAmount = newAmount; | |
| }); | |
| }, | |
| ), | |
| // 3 |
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
| import 'package:flutter/material.dart'; | |
| import 'package:hottip/components/moody_waiter_image.dart'; | |
| class TipCalculator extends StatefulWidget { | |
| // 1 | |
| @override | |
| State<StatefulWidget> createState() => _TipCalculatorState(); | |
| } | |
| class _TipCalculatorState extends State<TipCalculator> { |
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 _HotTipApp extends StatelessWidget { | |
| @override | |
| Widget build(BuildContext context) { | |
| // 1 | |
| return MaterialApp( | |
| home: _HomePage(), | |
| theme: ThemeData( | |
| // 2 | |
| primaryColor: Color.fromRGBO(144, 223, 170, 1), | |
| ), |
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
| // 1 | |
| class _HomePage extends StatelessWidget { | |
| // 2 | |
| @override | |
| Widget build(BuildContext context) { | |
| // 3 | |
| return Scaffold( | |
| appBar: AppBar( | |
| title: Text( | |
| 'Hot Tip', |
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 CharacterListBloc { | |
| CharacterListBloc() { | |
| // The return type of the `listen` func is a `StreamSubscription`. You need | |
| // to store your subscriptions for being able to access and cancel | |
| // them if the widget (and consequently the BLoC) gets disposed. | |
| // We call "listen" twice in this BLoC, so we have two subscriptions. In | |
| // order to manage them together, we add both to a `CompositeSubscription`. | |
| _subscriptions | |
| // The '..' syntax is a Dart feature called cascade notation. |
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
| @override | |
| Widget build(BuildContext context) => | |
| Scaffold( | |
| appBar: AppBar( | |
| title: const Text('Characters'), | |
| ), | |
| // We could be listening the BLoC's Stream on the initState method, | |
| // storing the data on a variable whenever it arrives, and then calling | |
| // setState to force the widget to rebuild, but instead, we're using | |
| // this `StreamBuilder` helper class which does it all for us. |
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
| /// Fetches and displays a list of characters' summarized info. | |
| class CharacterListPage extends StatefulWidget { | |
| @override | |
| _CharacterListPageState createState() => _CharacterListPageState(); | |
| } | |
| class _CharacterListPageState extends State<CharacterListPage> { | |
| Object _activeCallbackIdentity; | |
| List<CharacterSummary> _characterSummaryList; |
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 MyApp extends StatelessWidget { | |
| @override | |
| Widget build(BuildContext context) => MaterialApp( | |
| title: 'Routing, navigation and deep linking sample', | |
| theme: ThemeData( | |
| primarySwatch: Colors.green, | |
| ), | |
| onGenerateRoute: (settings) => FluroRouter.appRouter | |
| .matchRoute(context, settings.name, routeSettings: settings) | |
| .route, |
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
| void main() { | |
| FluroRouter.appRouter | |
| // The '..' syntax is a Dart feature called cascade notation. | |
| // Further reading: https://dart.dev/guides/language/language-tour#cascade-notation- | |
| ..define( | |
| // The '/' route name is the one the MaterialApp defaults to as our initial one. | |
| '/', | |
| // Handler is a custom Fluro's class, in which you define the route's | |
| // widget builder as the Handler.handlerFunc. | |
| handler: Handler( |
NewerOlder