crawlink

Creator: coderz1093

Last updated:

0 purchases

crawlink Image
crawlink Images

Languages

Categories

Add to Cart

Description:

crawlink

crawlink #
A simple routing library for flutter apps based on Navigator 2.0
Getting Started #


Install #
pubspec.yaml
crawlink: <latest-version>
copied to clipboard
Push a route #
Syntax:
Crawlink.of(context).push(
String url, {
Map<String, String> params = const {},
Map<String, dynamic> data = const {},
});
copied to clipboard

Crawlink.of(context).push('/' );

// or,

Crawlink.of(context).push('/users/1', data: {'user':<user>});

// or

Crawlink.of(context).push('/users/:id', params: {'id': "1"}, data: {'user':<user>});
copied to clipboard
Pop a route #
Crawlink.of(context).pop()
copied to clipboard
Define a route #
CrawlinkRouter(
url: '/',
onPages: (path) => <Page>[
MaterialPage(child: HomePage()),
],
),
copied to clipboard
Full Example Usage #
void main() {
setPathUrlStrategy();
runApp(MyApp());
}

class MyApp extends StatefulWidget {
MyApp({Key? key}) : super(key: key) {
print('MyApp:init');
}

@override
_MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
late Crawlink _crawlink;

@override
void initState() {
super.initState();
_crawlink = _initCrawlink();
}

@override
Widget build(BuildContext context) {
print('MyApp : build');
return _crawlink;
}

_initCrawlink() {
return Crawlink(
context: context,
builder: Builder(
builder: (context) {
return MaterialApp.router(
routeInformationParser: context.routeInformationParser!,
routerDelegate: context.routerDelegate!,
backButtonDispatcher: context.backButtonDispatcher!,
routeInformationProvider: context.routeInformationProvider!,
);
},
),
routers: [
CrawlinkRouter(
url: '/',
onPages: (path) => <Page>[
MaterialPage(child: HomePage()),
],
),
CrawlinkRouter(
url: '/users',
onPages: (path) => <Page>[
MaterialPage(child: HomePage()),
MaterialPage(child: UsersPage()),
],
),
CrawlinkRouter(
url: '/users/:id',
onPages: (path) => <Page>[
MaterialPage(child: HomePage()),
MaterialPage(child: UsersPage()),
MaterialPage(
child: UserPage(
path: path,
)),
],
onPush: (path) async => path,
onPop: (path) => CrawlinkRoutePath('/users'),
onResolve: (path, data) async => data,
),

],
);
}
}

copied to clipboard
CrawlinkRouter #
class CrawlinkRouter {

final String url;

final List<Page> Function(CrawlinkRoutePath path) onPages;

final Future<CrawlinkRoutePath> Function(CrawlinkRoutePath path)? onPush;

final CrawlinkRoutePath Function(CrawlinkRoutePath path)? onPop;

final Future<Map<String, dynamic>> Function(CrawlinkRoutePath path, Map<String, dynamic> data)? onResolve;

}
copied to clipboard

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.