Line data Source code
1 : import 'package:flutter/widgets.dart'; 2 : import 'package:widgetbook/src/routing/story_route_path.dart'; 3 : 4 : class StoryRouteInformationParser 5 : extends RouteInformationParser<StoryRoutePath> { 6 : final Function(String path) onRoute; 7 : 8 0 : StoryRouteInformationParser({ 9 : required this.onRoute, 10 : }); 11 : 12 : @override 13 0 : Future<StoryRoutePath> parseRouteInformation( 14 : RouteInformation routeInformation, 15 : ) async { 16 0 : final uri = Uri.parse(routeInformation.location ?? ''); 17 0 : onRoute(uri.path); 18 0 : return StoryRoutePath(path: uri.path); 19 : } 20 : 21 0 : @override 22 : RouteInformation restoreRouteInformation(StoryRoutePath configuration) { 23 0 : return RouteInformation(location: configuration.path); 24 : } 25 : }