createAppwriteMainWithOnBoarding static method

Future<void> createAppwriteMainWithOnBoarding(
  1. String projectName
)

Implementation

static Future<void> createAppwriteMainWithOnBoarding(
    String projectName) async {
  final File mainFile = File('lib/main.dart');
  mainFile.writeAsStringSync('''

import 'package:flutter/material.dart';
import 'package:appwrite/appwrite.dart';
import 'package:$projectName/features/auth/service/auth_status.dart';
import 'package:$projectName/features/auth/ui/auth_screen.dart';
import 'package:provider/provider.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:$projectName/features/onBoarding/ui/on_boarding_screen.dart';
import 'package:$projectName/shared/nav_bar.dart';

void main() async {
WidgetsFlutterBinding.ensureInitialized();
Client client = Client();
client = Client()
    .setEndpoint("<YOUR_PROJECT_ENDPOINT>")
    .setProject("<YOUR_PROJECT_ID>");
Account account = Account(client);
SharedPreferences prefs = await SharedPreferences.getInstance();
bool hasSeenOnboarding =
    prefs.getBool('hasSeenOnboarding') ?? false;
runApp(ChangeNotifierProvider(
  create: (context) => AuthService(),
  child: MyApp(account: account, hasSeenOnboarding: hasSeenOnboarding,),
));
}

class MyApp extends StatelessWidget {
final Account account;
final bool hasSeenOnboarding;
const MyApp({
  required this.account,
  required this.hasSeenOnboarding,
  super.key,
});

@override
Widget build(BuildContext context) {
  final value = context.watch<AuthService>().status;
  return MaterialApp(
    debugShowCheckedModeBanner: false,
    theme: ThemeData(
      useMaterial3: true,
    ),
    home: !hasSeenOnboarding
        ? const OnBoardingScreen()
        : value == AuthStatus.uninitialized
            ? const Scaffold(
                body: Center(child: CircularProgressIndicator()),
              )
            : value == AuthStatus.authenticated
                ? const NavigationScreen()
                : const AuthScreen(),
  );
}
}



''');
}