designflow 0.0.1 designflow: ^0.0.1 copied to clipboard
Combine no-code and local code to create a Flutter app with DesignFlow.
import 'package:designflow/designflow.dart';
import 'package:example/designflow_ui_widgets.g.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:go_router/go_router.dart';
import 'package:designflow_google_maps_addon/designflow_google_maps_addon.dart';
import 'package:designflow_material_addon/designflow_material_addon.dart';
final router = GoRouter(
initialLocation: '/places',
routes: [
GoRoute(
path: '/booking',
builder: (_, __) => const Scaffold(body: BookingConnectorWidget()),
),
GoRoute(
path: '/places',
builder: (_, __) => const Scaffold(body: BookingFindPlaceDialogWidget()),
),
],
);
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({super.key});
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
final GlobalKey appKey = GlobalKey();
@override
void initState() {
super.initState();
load();
}
void load() {
Future.delayed(const Duration(seconds: 2)).then((value) {
print(appKey.currentContext?.read<AppCubit>().state);
});
}
@override
Widget build(BuildContext context) {
return DesignFlowApp(
token:
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJyZWYiOiJhNWYwZDA3ZS04ZWY2LTQ3MzctYTJjNC1iMTdmOGQ5ODQyNDEiLCJhbm9uX2tleSI6ImI5M2M4MDFhLTBmYjItNDQzYi1iYTdlLWQ4MjdmNDczZmFjMCIsImlhdCI6MTcwNzQ3NDc1OCwiZXhwIjoxNzM5MDMyMzU4LCJpc3MiOiJodHRwczovL2J1aWxkd2l0aHRoZXRhLmNvbSJ9.BYo5pb6ox3nRcKZiWwC3cratB2EkzqG50NcJC4_jrdA',
components: designFlowComponentEntries,
mapComponentsIDToName: const {},
appKey: appKey,
dependenciesInitializers: [
() => DesignFlowWidgetsMaterial.initializeDependencies(),
() => DesignFlowWidgetsGoogleMaps.initializeDependencies(),
],
router: router,
);
}
}