flutter_deck icon indicating copy to clipboard operation
flutter_deck copied to clipboard

feat: Support direct slide widget creation

Open matthew-carroll opened this issue 5 months ago • 2 comments

The current structural approach of flutter_deck is to subclass FlutterDeckSlideWidget to create a slide. This requirement seems to result in a lot more code than should be necessary to describe a desired slide show.

For example, I'd like to start defining my presentation with something like this:

@override
Widget build(BuildContext context) {
  return FlutterDeckApp(
    slides: [
      FlutterDeckSlide.title(title: 'The Art of Flutter Testing'),
    ],
  );
}

But the above won't compile. The slide is a FlutterDeckSlide, but the slides list wants FlutterDeckSlideWidgets.

Therefore, I have to write the following code for the exact same effect:

@override
Widget build(BuildContext context) {
  return FlutterDeckApp(
    slides: [
      const MyTitleSlide(),
    ],
  );
}

class MyTitleSlide extends FlutterDeckSlideWidget {
  const MyTitleSlide()
    : super(
        configuration: const FlutterDeckSlideConfiguration(route: '/'),
      );

  @override
  FlutterDeckSlide build(BuildContext context) {
    return FlutterDeckSlide.title(title: 'The Art of Flutter Testing');
  }
}

I'm sure there are some details behind the scenes that lead to this, but in terms of UX, I really think we should be able to directly use existing slide types within the slides list without subclassing. I know there's code generation tooling, but in this case, that seems like a solution to a problem that doesn't need to exist.

matthew-carroll avatar Sep 17 '24 02:09 matthew-carroll