diff --git a/example/lib/src/examples/example_selection_navigator.dart b/example/lib/src/examples/example_selection_navigator.dart index 28fe05b..776214f 100644 --- a/example/lib/src/examples/example_selection_navigator.dart +++ b/example/lib/src/examples/example_selection_navigator.dart @@ -1,6 +1,8 @@ import 'package:fdr/fdr.dart'; import 'package:fdr_example/src/examples/dynamic_pop_navigator.dart'; -import 'package:fdr_example/src/examples/hot_reloadable_navigator.dart'; +import 'package:fdr_example/src/examples/hot_reloadable_mapped_navigator.dart'; +import 'package:fdr_example/src/examples/hot_reloadable_stateful_navigator.dart'; +import 'package:fdr_example/src/examples/hot_reloadable_stateless_navigator.dart'; import 'package:fdr_example/src/examples/list_detail_navigator.dart'; import 'package:fdr_example/src/examples/overlay_portal_navigator.dart'; import 'package:flutter/cupertino.dart'; @@ -29,7 +31,9 @@ class ExampleSelectionNavigator examples: { 'List Detail': () => ListDetailNavigator(), 'Dynamic back behavior': () => DynamicPopNavigator(), - 'Stateful Navigator w/ hot reload': () => HotReloadableNavigator(), + 'Stateful Navigator': () => HotReloadableStatefulNavigator(), + 'Stateless Navigator': () => HotReloadableStatelessNavigator(), + 'Mapped Navigator': () => HotReloadableMappedNavigator(), 'Overlay Portal': () => OverlayPortalNavigator(), }, onExampleSelect: (exampleFactory) => this.state = exampleFactory(), diff --git a/example/lib/src/examples/hot_reloadable_mapped_navigator.dart b/example/lib/src/examples/hot_reloadable_mapped_navigator.dart new file mode 100644 index 0000000..0ce2034 --- /dev/null +++ b/example/lib/src/examples/hot_reloadable_mapped_navigator.dart @@ -0,0 +1,39 @@ +import 'package:fdr/fdr.dart'; +import 'package:flutter/material.dart'; + +class HotReloadableMappedNavigator extends StatelessNavigator { + @override + List build() { + return [ + MappedNavigatorDemo(), + ]; + } +} + +class MappedNavigatorDemo extends MappedNavigatableSource { + MappedNavigatorDemo() : super(initialState: 0); + + @override + List build() { + return [ + Scaffold( + appBar: AppBar( + title: const Text('Stateless Navigator'), + ), + body: Center( + child: Column( + children: [ + Text('Count: $state'), + FilledButton( + onPressed: () { + state++; + }, + child: const Text('Increment'), + ) + ], + ), + ), + ).page(onPop: null), + ]; + } +} diff --git a/example/lib/src/examples/hot_reloadable_navigator.dart b/example/lib/src/examples/hot_reloadable_stateful_navigator.dart similarity index 96% rename from example/lib/src/examples/hot_reloadable_navigator.dart rename to example/lib/src/examples/hot_reloadable_stateful_navigator.dart index 90f4424..2a9c3ef 100644 --- a/example/lib/src/examples/hot_reloadable_navigator.dart +++ b/example/lib/src/examples/hot_reloadable_stateful_navigator.dart @@ -4,7 +4,7 @@ import 'package:fdr/fdr.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -class HotReloadableNavigator extends StatelessNavigator { +class HotReloadableStatefulNavigator extends StatelessNavigator { @override List build() { return [ diff --git a/example/lib/src/examples/hot_reloadable_stateless_navigator.dart b/example/lib/src/examples/hot_reloadable_stateless_navigator.dart new file mode 100644 index 0000000..08ef1c7 --- /dev/null +++ b/example/lib/src/examples/hot_reloadable_stateless_navigator.dart @@ -0,0 +1,34 @@ +import 'package:fdr/fdr.dart'; +import 'package:flutter/material.dart'; + +class HotReloadableStatelessNavigator extends StatelessNavigator { + @override + List build() { + return [ + StatelessNavigatorDemo(greeting: 'hello, world!'), + ]; + } +} + +class StatelessNavigatorDemo extends StatelessNavigator { + @visibleForTesting + StatelessNavigatorDemo({ + required this.greeting, + }); + + final String greeting; + + @override + List build() { + return [ + Scaffold( + appBar: AppBar( + title: const Text('Stateless Navigator'), + ), + body: Center( + child: Text(greeting), + ), + ).page(onPop: null), + ]; + } +}