rand dart fix
This commit is contained in:
@@ -114,15 +114,13 @@ class MyApp extends StatelessWidget {
|
||||
""";
|
||||
|
||||
String buildCustomColors(List<CustomColor> colors) {
|
||||
if (colors != null) {
|
||||
final sb = StringBuffer();
|
||||
for (var color in colors) {
|
||||
String _name = ReCase(color.name).camelCase;
|
||||
int _value = color.color;
|
||||
sb.writeln(' static Color get $_name => const Color($_value);');
|
||||
}
|
||||
return sb.toString();
|
||||
final sb = StringBuffer();
|
||||
for (var color in colors) {
|
||||
String _name = ReCase(color.name).camelCase;
|
||||
int _value = color.color;
|
||||
sb.writeln(' static Color get $_name => const Color($_value);');
|
||||
}
|
||||
return sb.toString();
|
||||
return '';
|
||||
}
|
||||
|
||||
@@ -134,52 +132,42 @@ import 'package:flutter/material.dart';
|
||||
|
||||
bool isDark(BuildContext context) => Theme.of(context).brightness == Brightness.dark;
|
||||
|
||||
ThemeMode get themeMode => ${(project?.themeMode ?? ThemeMode.system).toString()};
|
||||
ThemeMode get themeMode => ${(project.themeMode ?? ThemeMode.system).toString()};
|
||||
|
||||
""");
|
||||
|
||||
sb.writeln(_writeProjectTheme(project?.lightTheme, 'LightTheme', true));
|
||||
sb.writeln(_writeProjectTheme(project?.darkTheme, 'DarkTheme', false));
|
||||
sb.writeln(_writeProjectTheme(project.lightTheme, 'LightTheme', true));
|
||||
sb.writeln(_writeProjectTheme(project.darkTheme, 'DarkTheme', false));
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
String _writeProjectTheme(ProjectTheme theme, String name, bool isLight) {
|
||||
if (theme == null) {
|
||||
return """
|
||||
class $name {
|
||||
$name._();
|
||||
|
||||
static ThemeData get data => ThemeData.${isLight ? 'light' : 'dark'}();
|
||||
|
||||
}
|
||||
""";
|
||||
}
|
||||
ThemeData _base = isLight ? ThemeData.light() : ThemeData.dark();
|
||||
return """
|
||||
class $name {
|
||||
$name._();
|
||||
|
||||
static ThemeData get data => ThemeData(
|
||||
brightness: ${theme?.lightBrightness ?? isLight ? 'Brightness.light' : 'Brightness.dark'},
|
||||
brightness: ${theme.lightBrightness ?? isLight ? 'Brightness.light' : 'Brightness.dark'},
|
||||
visualDensity: VisualDensity.adaptivePlatformDensity,
|
||||
textTheme: ThemeData.${isLight ? 'light' : 'dark'}().textTheme
|
||||
).copyWith(
|
||||
primaryColor: const Color(${_getColor(theme?.primaryColor, _base.primaryColor)}),
|
||||
accentColor: const Color(${_getColor(theme?.accentColor, _base.accentColor)}),
|
||||
primaryColor: const Color(${_getColor(theme.primaryColor, _base.primaryColor)}),
|
||||
accentColor: const Color(${_getColor(theme.accentColor, _base.colorScheme.secondary)}),
|
||||
floatingActionButtonTheme:
|
||||
ThemeData.${isLight ? 'light' : 'dark'}().floatingActionButtonTheme.copyWith(
|
||||
backgroundColor: const Color(${_getColor(theme?.floatingActionButtonBackgroundColor, _base.floatingActionButtonTheme.backgroundColor)}),
|
||||
foregroundColor: const Color(${_getColor(theme?.floatingActionButtonForegroundColor, _base.floatingActionButtonTheme.foregroundColor)}),
|
||||
backgroundColor: const Color(${_getColor(theme.floatingActionButtonBackgroundColor, _base.floatingActionButtonTheme.backgroundColor)}),
|
||||
foregroundColor: const Color(${_getColor(theme.floatingActionButtonForegroundColor, _base.floatingActionButtonTheme.foregroundColor)}),
|
||||
),
|
||||
scaffoldBackgroundColor: const Color(${_getColor(theme?.scaffoldBackgroundColor, _base.scaffoldBackgroundColor)}),
|
||||
scaffoldBackgroundColor: const Color(${_getColor(theme.scaffoldBackgroundColor, _base.scaffoldBackgroundColor)}),
|
||||
appBarTheme: ThemeData.${isLight ? 'light' : 'dark'}().appBarTheme,
|
||||
);
|
||||
|
||||
${buildCustomColors(theme?.customColors)}
|
||||
${buildCustomColors(theme.customColors)}
|
||||
}
|
||||
""";
|
||||
}
|
||||
|
||||
int _getColor(int value, Color fallback) {
|
||||
return value ?? fallback?.value ?? Colors.blue.value;
|
||||
return value ?? fallback.value ?? Colors.blue.value;
|
||||
}
|
||||
|
||||
@@ -101,10 +101,8 @@ Future _writeFilesDir(
|
||||
if (!_dir.existsSync()) {
|
||||
_dir.createSync(recursive: true);
|
||||
}
|
||||
if (file?.children != null) {
|
||||
await _writeFilesDir(file.children, path, base);
|
||||
}
|
||||
}
|
||||
await _writeFilesDir(file.children, path, base);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -166,9 +166,6 @@ class _$FlutterProjectCopyWithImpl<$Res>
|
||||
|
||||
@override
|
||||
$ProjectThemeCopyWith<$Res> get lightTheme {
|
||||
if (_value.lightTheme == null) {
|
||||
return null;
|
||||
}
|
||||
return $ProjectThemeCopyWith<$Res>(_value.lightTheme, (value) {
|
||||
return _then(_value.copyWith(lightTheme: value));
|
||||
});
|
||||
@@ -176,9 +173,6 @@ class _$FlutterProjectCopyWithImpl<$Res>
|
||||
|
||||
@override
|
||||
$ProjectThemeCopyWith<$Res> get darkTheme {
|
||||
if (_value.darkTheme == null) {
|
||||
return null;
|
||||
}
|
||||
return $ProjectThemeCopyWith<$Res>(_value.darkTheme, (value) {
|
||||
return _then(_value.copyWith(darkTheme: value));
|
||||
});
|
||||
@@ -298,16 +292,7 @@ class _$_FlutterProject
|
||||
this.themeMode,
|
||||
this.canvasZoom = 0,
|
||||
this.canvasOffsetDx = 0,
|
||||
this.canvasOffsetDy = 0})
|
||||
: assert(name != null),
|
||||
assert(org != null),
|
||||
assert(description != null),
|
||||
assert(useSwift != null),
|
||||
assert(useKotlin != null),
|
||||
assert(targets != null),
|
||||
assert(canvasZoom != null),
|
||||
assert(canvasOffsetDx != null),
|
||||
assert(canvasOffsetDy != null);
|
||||
this.canvasOffsetDy = 0});
|
||||
|
||||
factory _$_FlutterProject.fromJson(Map<String, dynamic> json) =>
|
||||
_$_$_FlutterProjectFromJson(json);
|
||||
|
||||
@@ -750,9 +750,6 @@ class _$_CustomGradient
|
||||
double endY,
|
||||
TileMode tileMode),
|
||||
}) {
|
||||
assert($default != null);
|
||||
assert(radial != null);
|
||||
assert(linear != null);
|
||||
return $default(name, colors);
|
||||
}
|
||||
|
||||
@@ -781,11 +778,8 @@ class _$_CustomGradient
|
||||
TileMode tileMode),
|
||||
@required Result orElse(),
|
||||
}) {
|
||||
assert(orElse != null);
|
||||
if ($default != null) {
|
||||
return $default(name, colors);
|
||||
}
|
||||
return orElse();
|
||||
return $default(name, colors);
|
||||
return orElse();
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -795,9 +789,6 @@ class _$_CustomGradient
|
||||
@required Result radial(CustomRadialGradient value),
|
||||
@required Result linear(CustomLinearGradient value),
|
||||
}) {
|
||||
assert($default != null);
|
||||
assert(radial != null);
|
||||
assert(linear != null);
|
||||
return $default(this);
|
||||
}
|
||||
|
||||
@@ -809,11 +800,8 @@ class _$_CustomGradient
|
||||
Result linear(CustomLinearGradient value),
|
||||
@required Result orElse(),
|
||||
}) {
|
||||
assert(orElse != null);
|
||||
if ($default != null) {
|
||||
return $default(this);
|
||||
}
|
||||
return orElse();
|
||||
return $default(this);
|
||||
return orElse();
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -1006,9 +994,6 @@ class _$CustomRadialGradient
|
||||
double endY,
|
||||
TileMode tileMode),
|
||||
}) {
|
||||
assert($default != null);
|
||||
assert(radial != null);
|
||||
assert(linear != null);
|
||||
return radial(name, stops, colors, radius, alignX, alignY, focalX, focalY);
|
||||
}
|
||||
|
||||
@@ -1037,12 +1022,9 @@ class _$CustomRadialGradient
|
||||
TileMode tileMode),
|
||||
@required Result orElse(),
|
||||
}) {
|
||||
assert(orElse != null);
|
||||
if (radial != null) {
|
||||
return radial(
|
||||
name, stops, colors, radius, alignX, alignY, focalX, focalY);
|
||||
}
|
||||
return orElse();
|
||||
return radial(
|
||||
name, stops, colors, radius, alignX, alignY, focalX, focalY);
|
||||
return orElse();
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -1052,9 +1034,6 @@ class _$CustomRadialGradient
|
||||
@required Result radial(CustomRadialGradient value),
|
||||
@required Result linear(CustomLinearGradient value),
|
||||
}) {
|
||||
assert($default != null);
|
||||
assert(radial != null);
|
||||
assert(linear != null);
|
||||
return radial(this);
|
||||
}
|
||||
|
||||
@@ -1066,11 +1045,8 @@ class _$CustomRadialGradient
|
||||
Result linear(CustomLinearGradient value),
|
||||
@required Result orElse(),
|
||||
}) {
|
||||
assert(orElse != null);
|
||||
if (radial != null) {
|
||||
return radial(this);
|
||||
}
|
||||
return orElse();
|
||||
return radial(this);
|
||||
return orElse();
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -1288,9 +1264,6 @@ class _$CustomLinearGradient
|
||||
double endY,
|
||||
TileMode tileMode),
|
||||
}) {
|
||||
assert($default != null);
|
||||
assert(radial != null);
|
||||
assert(linear != null);
|
||||
return linear(
|
||||
name, stops, colors, radius, startX, startY, endX, endY, tileMode);
|
||||
}
|
||||
@@ -1320,12 +1293,9 @@ class _$CustomLinearGradient
|
||||
TileMode tileMode),
|
||||
@required Result orElse(),
|
||||
}) {
|
||||
assert(orElse != null);
|
||||
if (linear != null) {
|
||||
return linear(
|
||||
name, stops, colors, radius, startX, startY, endX, endY, tileMode);
|
||||
}
|
||||
return orElse();
|
||||
return linear(
|
||||
name, stops, colors, radius, startX, startY, endX, endY, tileMode);
|
||||
return orElse();
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -1335,9 +1305,6 @@ class _$CustomLinearGradient
|
||||
@required Result radial(CustomRadialGradient value),
|
||||
@required Result linear(CustomLinearGradient value),
|
||||
}) {
|
||||
assert($default != null);
|
||||
assert(radial != null);
|
||||
assert(linear != null);
|
||||
return linear(this);
|
||||
}
|
||||
|
||||
@@ -1349,11 +1316,8 @@ class _$CustomLinearGradient
|
||||
Result linear(CustomLinearGradient value),
|
||||
@required Result orElse(),
|
||||
}) {
|
||||
assert(orElse != null);
|
||||
if (linear != null) {
|
||||
return linear(this);
|
||||
}
|
||||
return orElse();
|
||||
return linear(this);
|
||||
return orElse();
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@@ -196,10 +196,7 @@ class _$ProjectScreen with DiagnosticableTreeMixin implements ProjectScreen {
|
||||
this.dx,
|
||||
this.dy,
|
||||
this.width,
|
||||
this.height})
|
||||
: assert(className != null),
|
||||
assert(isStateful != null),
|
||||
assert(route != null);
|
||||
this.height});
|
||||
|
||||
factory _$ProjectScreen.fromJson(Map<String, dynamic> json) =>
|
||||
_$_$ProjectScreenFromJson(json);
|
||||
|
||||
@@ -106,12 +106,8 @@ class ProjectFile extends ProjectFileBase {
|
||||
|
||||
Future<FileData> getFileData() async {
|
||||
List<int> _data;
|
||||
if (content.value != null) {
|
||||
_data = content.value;
|
||||
} else if (readAsBytes != null) {
|
||||
_data = await readAsBytes;
|
||||
}
|
||||
return FileData(
|
||||
_data = content.value;
|
||||
return FileData(
|
||||
_data,
|
||||
_data.length,
|
||||
filename,
|
||||
|
||||
Reference in New Issue
Block a user