import 'dart:io';

import 'package:flutter/material.dart';
import 'package:syncfusion_flutter_pdfviewer/pdfviewer.dart';

import '../route_transition_gate.dart';

/// SfPdfViewer asserts on `localToGlobal` if laid out while a route
/// transition's fresh `RenderTransform` has no size yet. Mount it only while
/// the route is at rest (see [RouteTransitionGate]).
class DeferredPdfViewer extends StatelessWidget {
  const DeferredPdfViewer({super.key, required this.path});
  final String path;

  @override
  Widget build(BuildContext context) => RouteTransitionGate(
    builder: (context) => SfPdfViewer.file(File(path)),
  );
}
