createConstants static method

Future<void> createConstants(
  1. String projectName
)

Implementation

static Future<void> createConstants(String projectName) async {
  final constantsFolder = Directory('lib/constants');
  constantsFolder.createSync();

  final File dimensionsFile = File('lib/constants/dimensions.dart');
  if (!dimensionsFile.existsSync()) {
    dimensionsFile.createSync();
    dimensionsFile.writeAsStringSync('''
import 'package:flutter/widgets.dart';

final GlobalKey<NavigatorState> navigatorKey = GlobalKey<NavigatorState>();

double getScreenWidth(BuildContext context) {
return MediaQuery.of(context).size.width;
}

double getScreenheight(BuildContext context) {
return MediaQuery.of(context).size.height;
}

''');
  }
}