Skip to content

Commit

Permalink
refactor: stateful to stateless widget
Browse files Browse the repository at this point in the history
  • Loading branch information
AladdineDev committed May 16, 2024
1 parent 216b85b commit a7d86bd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 16 deletions.
9 changes: 2 additions & 7 deletions lib/src/features/general/presentation/general_section.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,11 @@ import 'package:portfolio/src/features/general/presentation/widgets/end_drawer.d
import 'package:portfolio/src/features/general/presentation/widgets/safe_area.dart';
import 'package:portfolio/src/common/widgets/responsive.dart';

class GeneralSection extends ConsumerStatefulWidget {
class GeneralSection extends ConsumerWidget {
const GeneralSection({super.key});

@override
ConsumerState<GeneralSection> createState() => _MainSectionState();
}

class _MainSectionState extends ConsumerState<GeneralSection> {
@override
Widget build(BuildContext context) {
Widget build(BuildContext context, WidgetRef ref) {
return Scaffold(
backgroundColor: Theme.of(context).colorScheme.secondary,
endDrawer: const MySafeArea(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,11 @@ import 'package:portfolio/src/features/general/provider/scroll_controller.dart';
import 'package:portfolio/src/features/general/provider/section_key_provider.dart';
import 'package:portfolio/src/common/widgets/responsive.dart';

class GeneralTablet extends ConsumerStatefulWidget {
class GeneralTablet extends ConsumerWidget {
const GeneralTablet({super.key});

@override
ConsumerState<GeneralTablet> createState() => _MainTabletState();
}

class _MainTabletState extends ConsumerState<GeneralTablet> {
@override
Widget build(BuildContext context) {
Widget build(BuildContext context, WidgetRef ref) {
final scrollController = ref.watch(scrollControllerProvider);

return Column(
Expand All @@ -37,7 +32,7 @@ class _MainTabletState extends ConsumerState<GeneralTablet> {
SliverList.list(
children: [
Padding(
padding: _buildResponsivePadding(),
padding: _buildResponsivePadding(context: context),
child: Align(
alignment: Alignment.topLeft,
child: AnimatedFadeSlide(
Expand Down Expand Up @@ -86,7 +81,7 @@ class _MainTabletState extends ConsumerState<GeneralTablet> {
);
}

EdgeInsetsGeometry _buildResponsivePadding() {
EdgeInsetsGeometry _buildResponsivePadding({required BuildContext context}) {
if (Responsive.isTablet(context)) {
return const EdgeInsets.fromLTRB(48, 60, 48, 88);
} else if (Responsive.isMobile(context)) {
Expand Down

0 comments on commit a7d86bd

Please sign in to comment.