Vaibhav Surve 99902e743c Flutter application
- Created generated_plugin_registrant.cc and generated_plugin_registrant.h to manage plugin registration.
- Added generated_plugins.cmake for plugin configuration in CMake.
- Implemented CMakeLists.txt for the Windows runner, defining build settings and dependencies.
- Created Runner.rc for application resources including versioning and icons.
- Developed flutter_window.cpp and flutter_window.h to manage the Flutter window lifecycle.
- Implemented main.cpp as the entry point for the Windows application.
- Added resource.h for resource definitions.
- Included app icon in resources.
- Created runner.exe.manifest for application settings.
- Developed utils.cpp and utils.h for console management and command line argument handling.
- Implemented win32_window.cpp and win32_window.h for high DPI-aware window management.
2025-04-17 12:30:38 +05:30

97 lines
3.1 KiB
Dart

import 'package:marco/helpers/theme/app_theme.dart';
import 'package:marco/helpers/widgets/my_flex_item.dart';
import 'package:marco/helpers/widgets/my_list_extension.dart';
import 'package:marco/helpers/widgets/my_responsive.dart';
import 'package:marco/helpers/widgets/my_screen_media.dart';
import 'package:marco/helpers/widgets/my_screen_media_type.dart';
import 'package:marco/helpers/widgets/my_spacing.dart';
import 'package:flutter/material.dart';
class MyFlex extends StatelessWidget {
final List<MyFlexItem> children;
final WrapAlignment wrapAlignment;
final WrapCrossAlignment wrapCrossAlignment;
final WrapAlignment runAlignment;
final bool contentPadding;
// final Map<ScreenMediaType, int>? flex;
final double? spacing, runSpacing;
const MyFlex(
{super.key,
required this.children,
this.wrapAlignment = WrapAlignment.start, // this.flex,
this.wrapCrossAlignment = WrapCrossAlignment.start,
this.runAlignment = WrapAlignment.start,
this.contentPadding = true,
this.spacing,
this.runSpacing});
getPadding(index, length) {
if (contentPadding) {
return MySpacing.x((spacing ?? flexSpacing) / 2);
} else {
return MySpacing.fromLTRB(index == 0 ? 0 : (spacing ?? flexSpacing) / 2,
0, index == length - 1 ? 0 : (spacing ?? flexSpacing) / 2, 0);
}
}
@override
Widget build(BuildContext context) {
return MyResponsive(
builder:
(BuildContext context, BoxConstraints constraints, screenMediaType) {
double width = constraints.maxWidth;
List<Widget> list = [];
for (List<MyFlexItem> lCol in getGrouped(screenMediaType)) {
list.addAll(lCol.mapIndexed((index, col) => Container(
width: getWidthFromFlex(
width,
col.flex[screenMediaType] ?? MyScreenMedia.flexColumns.toDouble(),
lCol.length,
spacing ?? flexSpacing),
padding: getPadding(index, lCol.length),
child: col,
)));
}
return Wrap(
crossAxisAlignment: wrapCrossAlignment,
alignment: wrapAlignment,
runAlignment: runAlignment,
runSpacing: (runSpacing ?? flexSpacing),
spacing: (spacing ?? 0),
children: list,
);
},
);
}
List<List<MyFlexItem>> getGrouped(MyScreenMediaType type) {
List<List<MyFlexItem>> list = [];
double flexCount = 0;
List<MyFlexItem> iList = [];
for (MyFlexItem col in children) {
if (col.display[type]!.isBlock) {
double flex = col.flex[type]!;
if (flexCount + flex <= 12) {
iList.add(col);
flexCount += flex;
} else {
list.add(iList);
iList = [];
iList.add(col);
flexCount = flex;
}
}
}
if (iList.isNotEmpty) {
list.add(iList);
}
return list;
}
double getWidthFromFlex(double width, double flex, int items, double spacing) {
return (width * flex / MyScreenMedia.flexColumns).floorToDouble();
}
}