You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
1.2 KiB
40 lines
1.2 KiB
import 'package:flutter/material.dart'; |
|
import 'package:flutter_example_packages/base/di/app_di.dart'; |
|
import 'package:flutter_example_packages/theme/colors.dart'; |
|
import 'package:scoped_model/scoped_model.dart'; |
|
|
|
class BlockLayout<T extends Model> extends StatelessWidget { |
|
const BlockLayout({ |
|
super.key, |
|
this.title, |
|
required this.builder, |
|
}); |
|
|
|
final String? title; |
|
final Widget Function(BuildContext context, Widget? child, T model) builder; |
|
|
|
@override |
|
Widget build(BuildContext context) { |
|
final theme = Theme.of(context); |
|
|
|
return ScopedModel<T>( |
|
model: getIt<T>(), |
|
child: ScopedModelDescendant<T>(builder: (context, child, model) { |
|
return Scaffold( |
|
appBar: title == null ? null : AppBar( |
|
backgroundColor: AppColors.primaryDark, |
|
title: Text( |
|
title!, |
|
textAlign: TextAlign.left, |
|
style: theme.textTheme.titleSmall?.copyWith(color: Colors.white), |
|
), |
|
), |
|
body: Padding( |
|
padding: EdgeInsets.all(title == null ? 0 : 20), |
|
child: builder.call(context, child, model), |
|
), |
|
); |
|
}), |
|
); |
|
} |
|
}
|
|
|