import '/components/permission_list_widget.dart';
import '/flutterlib/flutter_theme.dart';
import '/flutterlib/flutter_util.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:provider/provider.dart';
import 'permission_list_container2_model.dart';
export 'permission_list_container2_model.dart';

class PermissionListContainer2Widget extends StatefulWidget {
  const PermissionListContainer2Widget({
    Key? key,
    String? roleID,
    this.getPermissionsList,
  })  : this.roleID = roleID ?? '',
        super(key: key);

  final String roleID;
  final List<int>? getPermissionsList;

  @override
  _PermissionListContainer2WidgetState createState() =>
      _PermissionListContainer2WidgetState();
}

class _PermissionListContainer2WidgetState
    extends State<PermissionListContainer2Widget> {
  late PermissionListContainer2Model _model;

  @override
  void setState(VoidCallback callback) {
    super.setState(callback);
    _model.onUpdate();
  }

  @override
  void initState() {
    super.initState();
    _model = createModel(context, () => PermissionListContainer2Model());
  }

  @override
  void dispose() {
    _model.maybeDispose();

    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    context.watch<FFAppState>();

    return Container(
      decoration: BoxDecoration(),
      child: Align(
        alignment: AlignmentDirectional(0.0, 0.0),
        child: wrapWithModel(
          model: _model.permissionListModel,
          updateCallback: () => setState(() {}),
          updateOnChange: true,
          child: PermissionListWidget(
            roleID: widget.roleID,
            getPermissionsList: widget.getPermissionsList,
          ),
        ),
      ),
    );
  }
}
