From fbf43c2aa8d076350eca29432143c2b6deeda736 Mon Sep 17 00:00:00 2001 From: Manoj <96906187+manoj-simform@users.noreply.github.com> Date: Fri, 31 May 2024 19:53:03 +0530 Subject: [PATCH] feat!: :boom: Remove builder widget (#400) (#453) --- CHANGELOG.md | 1 + README.md | 19 ++++ example/lib/detailscreen.dart | 160 +++++++++++++++++----------------- example/lib/main.dart | 2 +- lib/src/showcase_widget.dart | 6 +- 5 files changed, 103 insertions(+), 85 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 973cc029..69d9f586 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ - [BREAKING] Fixed [#434](https://github.com/SimformSolutionsPvtLtd/flutter_showcaseview/issues/434) removed deprecated text style after Flutter 3.22 follow [migration guide](https://docs.flutter.dev/release/breaking-changes/3-19-deprecations#texttheme) - Updated minimum support to dart sdk 2.18.0 - Fixed [#449](https://github.com/SimformSolutionsPvtLtd/flutter_showcaseview/issues/449) - Null check operator used on a null value +- [BREAKING] Improvement [#400](https://github.com/SimformSolutionsPvtLtd/flutter_showcaseview/issues/400) - remove Builder widget ## [2.1.1] - Fixed [#425](https://github.com/SimformSolutionsPvtLtd/flutter_showcaseview/issues/425) - Unhandled breaking change in v2.1.0 diff --git a/README.md b/README.md index b8dfca9b..0925c40a 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,25 @@ A Flutter package allows you to Showcase/Highlight your widgets step by step. ![The example app running in Android](https://raw.githubusercontent.com/SimformSolutionsPvtLtd/flutter_showcaseview/master/preview/showcaseview.gif) +## Migration guide for release 3.0.0 +Removed builder widget from `ShowCaseWidget` and replaced it with builder function + +Before: +```dart +ShowCaseWidget( + builder: Builder( + builder : (context) => Somewidget() + ), +), +``` + +After: +```dart +ShowCaseWidget( + builder : (context) => Somewidget(), +), +``` + ## Migration guide for release 2.0.0 Renamed properties/fields of widgets mentioned below in the table. diff --git a/example/lib/detailscreen.dart b/example/lib/detailscreen.dart index ade09678..e599ea49 100644 --- a/example/lib/detailscreen.dart +++ b/example/lib/detailscreen.dart @@ -25,97 +25,93 @@ class _DetailState extends State { @override Widget build(BuildContext context) { return ShowCaseWidget( - builder: Builder( - builder: (context) { - myContext = context; - return Scaffold( - appBar: AppBar( - backgroundColor: Colors.transparent, - elevation: 0, - leading: IconButton( - icon: const Icon( - Icons.arrow_back, - color: Colors.black, - ), - onPressed: () { - Navigator.pop(context); - }, + builder: (context) { + myContext = context; + return Scaffold( + appBar: AppBar( + backgroundColor: Colors.transparent, + elevation: 0, + leading: IconButton( + icon: const Icon( + Icons.arrow_back, + color: Colors.black, ), + onPressed: () { + Navigator.pop(context); + }, ), - body: Padding( - padding: const EdgeInsets.all(16), - child: ListView( - children: [ - Showcase( - key: _one, - title: 'Title', - description: 'Desc', - child: InkWell( - onTap: () {}, - child: const Text( - 'Flutter Notification', - style: TextStyle( - fontSize: 25, - fontWeight: FontWeight.w600, - ), + ), + body: Padding( + padding: const EdgeInsets.all(16), + child: ListView( + children: [ + Showcase( + key: _one, + title: 'Title', + description: 'Desc', + child: InkWell( + onTap: () {}, + child: const Text( + 'Flutter Notification', + style: TextStyle( + fontSize: 25, + fontWeight: FontWeight.w600, ), ), ), - const SizedBox( - height: 16, - ), - const Text( - 'Hi, you have new Notification from flutter group, open ' - 'slack and check it out', - style: TextStyle(fontSize: 18, fontWeight: FontWeight.w500), - ), - const SizedBox( - height: 16, - ), - RichText( - text: const TextSpan( - style: TextStyle( - fontWeight: FontWeight.w400, - color: Colors.black, + ), + const SizedBox( + height: 16, + ), + const Text( + 'Hi, you have new Notification from flutter group, open ' + 'slack and check it out', + style: TextStyle(fontSize: 18, fontWeight: FontWeight.w500), + ), + const SizedBox( + height: 16, + ), + RichText( + text: const TextSpan( + style: TextStyle( + fontWeight: FontWeight.w400, + color: Colors.black, + ), + children: [ + TextSpan(text: 'Hi team,\n\n'), + TextSpan( + text: 'As some of you know, we’re moving to Slack for ' + 'our internal team communications. Slack is a ' + 'messaging app where we can talk, share files, ' + 'and work together. It also connects with tools ' + 'we already use, like [add your examples here], ' + 'plus 900+ other apps.\n\n', ), - children: [ - TextSpan(text: 'Hi team,\n\n'), - TextSpan( - text: - 'As some of you know, we’re moving to Slack for ' - 'our internal team communications. Slack is a ' - 'messaging app where we can talk, share files, ' - 'and work together. It also connects with tools ' - 'we already use, like [add your examples here], ' - 'plus 900+ other apps.\n\n', - ), - TextSpan( - text: 'Why are we moving to Slack?\n\n', - style: TextStyle( - fontWeight: FontWeight.w600, - color: Colors.black, - ), - ), - TextSpan( - text: - 'We want to use the best communication tools to ' - 'make our lives easier and be more productive. ' - 'Having everything in one place will help us ' - 'work together better and faster, rather than ' - 'jumping around between emails, IMs, texts and ' - 'a bunch of other programs. Everything you share ' - 'in Slack is automatically indexed and archived, ' - 'creating a searchable archive of all our work.', + TextSpan( + text: 'Why are we moving to Slack?\n\n', + style: TextStyle( + fontWeight: FontWeight.w600, + color: Colors.black, ), - ], - ), + ), + TextSpan( + text: 'We want to use the best communication tools to ' + 'make our lives easier and be more productive. ' + 'Having everything in one place will help us ' + 'work together better and faster, rather than ' + 'jumping around between emails, IMs, texts and ' + 'a bunch of other programs. Everything you share ' + 'in Slack is automatically indexed and archived, ' + 'creating a searchable archive of all our work.', + ), + ], ), - ], - ), + ), + ], ), - ); - }, - ), + ), + ); + }, ); } } diff --git a/example/lib/main.dart b/example/lib/main.dart index 2385eec2..950c78c6 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -35,8 +35,8 @@ class MyApp extends StatelessWidget { } }, blurValue: 1, - builder: Builder(builder: (context) => const MailPage()), autoPlayDelay: const Duration(seconds: 3), + builder: (context) => const MailPage(), ), ), ); diff --git a/lib/src/showcase_widget.dart b/lib/src/showcase_widget.dart index 1c1e38cf..16168ba6 100644 --- a/lib/src/showcase_widget.dart +++ b/lib/src/showcase_widget.dart @@ -25,7 +25,7 @@ import 'package:flutter/material.dart'; import '../showcaseview.dart'; class ShowCaseWidget extends StatefulWidget { - final Builder builder; + final WidgetBuilder builder; /// Triggered when all the showcases are completed. final VoidCallback? onFinish; @@ -259,7 +259,9 @@ class ShowCaseWidgetState extends State { Widget build(BuildContext context) { return _InheritedShowCaseView( activeWidgetIds: ids?.elementAt(activeWidgetId!), - child: widget.builder, + child: Builder( + builder: widget.builder, + ), ); } }