Skip to content

Instantly share code, notes, and snippets.

@g-apparence
Last active January 29, 2021 07:14
Show Gist options
  • Save g-apparence/637a56c54458f20215de2d5f10d803aa to your computer and use it in GitHub Desktop.
Save g-apparence/637a56c54458f20215de2d5f10d803aa to your computer and use it in GitHub Desktop.
Pal setup instructions
import 'package:flutter/material.dart';
import 'package:pal/pal.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
final _navigatorKey = GlobalKey<NavigatorState>();
@override
Widget build(BuildContext context) {
return Pal(
editorModeEnabled: true, //switch between client mode and editor mode
appToken: "APPLICATION_TOKEN", // don't forget to give us your token
// --- your app start here --
child: MaterialApp(
key: ValueKey('hostedApp'),
navigatorKey: _navigatorKey, // add this in your app
navigatorObservers: [PalNavigatorObserver.instance()], // add this in your app
title: 'Pal Demo',
onGenerateRoute: route,
theme: ThemeData(
primarySwatch: Colors.blue,
visualDensity: VisualDensity.adaptivePlatformDensity,
),
),
// --- your app end here --
);
}
Route<dynamic> route(RouteSettings settings) {
switch (settings.name) {
case '/':
return MaterialPageRoute(
settings: settings,
builder: (context) => HomePage(),
maintainState: true,
);
case '/route1':
return MaterialPageRoute(
settings: settings,
builder: (context) => Route1Page(),
);
case '/route2':
return MaterialPageRoute(
settings: settings,
builder: (context) => Route2Page(),
);
default:
throw 'unexpected Route';
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment