diff --git a/lib/bloc/list_bloc.dart b/lib/bloc/list_bloc.dart index eeef0bc..d90d813 100644 --- a/lib/bloc/list_bloc.dart +++ b/lib/bloc/list_bloc.dart @@ -12,4 +12,13 @@ class ListBloc { ListBloc() { _listController.add(_listViewModel.getListItems()); } + + void filter(String searchQuery) { + List _filteredList = _listViewModel + .getListItems() + .where((ListItem listItem) => + listItem.title.toLowerCase().contains(searchQuery.toLowerCase())) + .toList(); + _listController.sink.add(_filteredList); + } } diff --git a/lib/screens/animated_container.dart b/lib/screens/animated_container.dart index e7bb263..459d8b2 100644 --- a/lib/screens/animated_container.dart +++ b/lib/screens/animated_container.dart @@ -80,7 +80,6 @@ class _AnimatedContainerWidgetState extends State { height: _iconHeight, width: _iconWidth, child: FlutterLogo( - colors: Colors.amber, textColor: Colors.white, ), ), diff --git a/lib/screens/backdrop_filter.dart b/lib/screens/backdrop_filter.dart index 3304c34..c7e0cfc 100644 --- a/lib/screens/backdrop_filter.dart +++ b/lib/screens/backdrop_filter.dart @@ -22,7 +22,6 @@ class _BackdropFilterWidgetState extends State { super.initState(); } - @override Widget build(BuildContext context) { return Scaffold( @@ -56,7 +55,6 @@ class _BackdropFilterWidgetState extends State { height: 200, width: 200, child: FlutterLogo( - colors: Colors.lightBlue, textColor: Colors.white, ), ), diff --git a/lib/screens/clip_r_rect.dart b/lib/screens/clip_r_rect.dart index 3a4c2eb..f466145 100644 --- a/lib/screens/clip_r_rect.dart +++ b/lib/screens/clip_r_rect.dart @@ -20,7 +20,6 @@ class _ClipRRectWidgetState extends State { super.initState(); } - @override Widget build(BuildContext context) { return Scaffold( @@ -71,7 +70,6 @@ class _ClipRRectWidgetState extends State { width: 100, height: 100, child: FlutterLogo( - colors: Colors.lightBlue, textColor: Colors.white, ), ), diff --git a/lib/screens/fitted_box.dart b/lib/screens/fitted_box.dart index 115e4b9..0278988 100644 --- a/lib/screens/fitted_box.dart +++ b/lib/screens/fitted_box.dart @@ -22,7 +22,6 @@ class _FittedBoxWidgetState extends State { super.initState(); } - @override Widget build(BuildContext context) { return Scaffold( @@ -63,7 +62,6 @@ class _FittedBoxWidgetState extends State { height: _heightValue, width: 300, child: FlutterLogo( - colors: Colors.lightBlue, textColor: Colors.white, ), ), diff --git a/lib/screens/hero.dart b/lib/screens/hero.dart index 61aaf3c..3dd621f 100644 --- a/lib/screens/hero.dart +++ b/lib/screens/hero.dart @@ -73,7 +73,6 @@ class HeroWidget extends StatelessWidget { width: 100, height: 100, child: FlutterLogo( - colors: Colors.lightBlue, textColor: Colors.white, ), ), diff --git a/lib/screens/hero2.dart b/lib/screens/hero2.dart index c8f6e9e..a0f1c62 100644 --- a/lib/screens/hero2.dart +++ b/lib/screens/hero2.dart @@ -46,7 +46,6 @@ class Hero2Widget extends StatelessWidget { width: 100, height: 100, child: FlutterLogo( - colors: Colors.lightBlue, textColor: Colors.white, ), ), diff --git a/lib/screens/home_page.dart b/lib/screens/home_page.dart index 8dbffd0..a810581 100644 --- a/lib/screens/home_page.dart +++ b/lib/screens/home_page.dart @@ -1,3 +1,5 @@ +import 'dart:async'; + import 'package:firebase_messaging/firebase_messaging.dart'; import 'package:firebase_remote_config/firebase_remote_config.dart'; import 'package:flutter/material.dart'; @@ -30,6 +32,7 @@ class _HomePageState extends State with WidgetsBindingObserver { "https://play.google.com/store/apps/details?id=com.annsh.flutterwidgetguide"; final GlobalKey _scaffoldKey = GlobalKey(); FirebaseMessaging _fcm; + bool _isSearching; @override void didChangeAppLifecycleState(AppLifecycleState state) { @@ -139,8 +142,7 @@ class _HomePageState extends State with WidgetsBindingObserver { _takeNotificationAction(message, context, false); }, ); - // } - //}); + _isSearching = false; } @override @@ -267,7 +269,7 @@ class _HomePageState extends State with WidgetsBindingObserver { controller: _hideButtonController, //This is to contain Sliver Elements slivers: [ - appBar(context), + appBar(context, listBloc), SliverPadding( padding: EdgeInsets.all(4.0), ), @@ -281,66 +283,113 @@ class _HomePageState extends State with WidgetsBindingObserver { }); } - Widget appBar(BuildContext context) => SliverAppBar( + Widget appBar(BuildContext context, ListBloc listBloc) => SliverAppBar( backgroundColor: Theme.of(context).primaryColorDark, pinned: true, elevation: 3.0, forceElevated: false, - expandedHeight: 80.0, + expandedHeight: !_isSearching ? 80.0 : 80, flexibleSpace: FlexibleSpaceBar( titlePadding: EdgeInsets.only(left: 0.0, top: 0.0, right: 0.0, bottom: 14.0), centerTitle: true, - title: Row( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.center, - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Padding( - padding: const EdgeInsets.only(right: 12.0, left: 8.0), - child: GestureDetector( - child: FlutterLogo( - colors: Colors.cyan, - textColor: Colors.white, - ), - onTap: () => Navigator.push( - context, - MaterialPageRoute( - builder: (context) => - WebViewWidget(url: "https://flutter.dev"), + title: !_isSearching + ? Row( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Padding( + padding: const EdgeInsets.only(right: 12.0, left: 8.0), + child: GestureDetector( + child: FlutterLogo( + textColor: Colors.white, + ), + onTap: () => Navigator.push( + context, + MaterialPageRoute( + builder: (context) => + WebViewWidget(url: "https://flutter.dev"), + ), + ), + ), + ), + //To give a margin + SizedBox( + width: 0.0, + ), + Text( + Utils.appName, + style: TextStyle( + fontFamily: Utils.ubuntuRegularFont, fontSize: 16), + ), + SizedBox( + width: 0.0, + ), + GestureDetector( + child: Padding( + padding: EdgeInsets.only(left: 10.0, right: 8.0), + child: CircleAvatar( + radius: 14.0, + backgroundImage: AssetImage('assets/images/dp.png'), + ), + ), + onTap: () => showModalBottomSheet( + context: context, + builder: (context) => ProfileScreen(), + ), + ), + + InkWell( + onTap: () { + setState(() { + _isSearching = true; + }); + }, + child: Icon( + Icons.search, + size: 20, + color: Colors.blue, + ), + ), + ], + ) + : Padding( + padding: + const EdgeInsets.only(right: 8.0, left: 8.0, top: 52), + child: TextFormField( + keyboardType: TextInputType.text, + onChanged: (value) { + listBloc.filter(value.trim()); + }, + style: TextStyle( + fontSize: 14, + ), + decoration: InputDecoration( + suffixIcon: InkWell( + onTap: () { + setState(() { + _isSearching = false; + }); + }, + child: Icon( + Icons.clear, + size: 16, + color: Colors.blue, + ), + ), + hintText: 'Search Widget Name', + hintStyle: TextStyle( + fontSize: 12, + ), + border: OutlineInputBorder( + borderRadius: BorderRadius.circular(5.0), + borderSide: BorderSide(width: .5,color: Colors.blue,) + ), ), ), ), - ), - //To give a margin - SizedBox( - width: 0.0, - ), - Text( - Utils.appName, - style: TextStyle( - fontFamily: Utils.ubuntuRegularFont, fontSize: 16), - ), - SizedBox( - width: 0.0, - ), - GestureDetector( - child: Padding( - padding: EdgeInsets.only(left: 10.0, right: 8.0), - child: CircleAvatar( - radius: 14.0, - backgroundImage: AssetImage('assets/images/dp.png'), - ), - ), - onTap: () => showModalBottomSheet( - context: context, builder: (context) => ProfileScreen()), - ), - ], - ), ), -// actions: [ -// -// ], ); Widget bodyList(List listItems) => SliverList( diff --git a/lib/screens/indexed_stack.dart b/lib/screens/indexed_stack.dart index de7fd38..10af2fa 100644 --- a/lib/screens/indexed_stack.dart +++ b/lib/screens/indexed_stack.dart @@ -111,7 +111,6 @@ class _IndexedStackWidgetState extends State { child: GestureDetector( child: FlutterLogo( duration: Duration(milliseconds: 500), - colors: _imageColor, curve: Curves.easeInOut, ), onTap: () => setState(() => _imageColor == Colors.blue diff --git a/lib/screens/opacity.dart b/lib/screens/opacity.dart index 89372e0..c111b38 100644 --- a/lib/screens/opacity.dart +++ b/lib/screens/opacity.dart @@ -93,7 +93,6 @@ class _OpacityWidgetState extends State { width: 100, height: 100, child: FlutterLogo( - colors: Colors.lightBlue, textColor: Colors.white, ), ), diff --git a/lib/screens/positioned.dart b/lib/screens/positioned.dart index 8b92420..60102f5 100644 --- a/lib/screens/positioned.dart +++ b/lib/screens/positioned.dart @@ -62,7 +62,6 @@ class _PositionedWidgetState extends State { width: 50, height: 50, child: FlutterLogo( - colors: Colors.lightBlue, textColor: Colors.white, ), ), diff --git a/lib/screens/selectable_text.dart b/lib/screens/selectable_text.dart index 08d68fe..bb53867 100644 --- a/lib/screens/selectable_text.dart +++ b/lib/screens/selectable_text.dart @@ -54,7 +54,6 @@ class _SelectableTextWidgetState extends State { margin: EdgeInsets.only(left: 24.0, right: 24.0, top: 24.0), child: FlutterLogo( size: 100, - colors: bgColor, ), ), diff --git a/lib/screens/shadermask_widget.dart b/lib/screens/shadermask_widget.dart index dbcdf0d..99bcc9b 100644 --- a/lib/screens/shadermask_widget.dart +++ b/lib/screens/shadermask_widget.dart @@ -11,19 +11,17 @@ class ShaderMaskWidget extends StatefulWidget { } class _ShaderMaskWidgetState extends State { - - Map color = - { - 50:Color.fromRGBO(255,255,255, .1), - 100:Color.fromRGBO(255,255,255, .2), - 200:Color.fromRGBO(255,255,255, .3), - 300:Color.fromRGBO(255,255,255, .4), - 400:Color.fromRGBO(255,255,255, .5), - 500:Color.fromRGBO(255,255,255, .6), - 600:Color.fromRGBO(255,255,255, .7), - 700:Color.fromRGBO(255,255,255, .8), - 800:Color.fromRGBO(255,255,255, .9), - 900:Color.fromRGBO(255,255,255, 1), + Map color = { + 50: Color.fromRGBO(255, 255, 255, .1), + 100: Color.fromRGBO(255, 255, 255, .2), + 200: Color.fromRGBO(255, 255, 255, .3), + 300: Color.fromRGBO(255, 255, 255, .4), + 400: Color.fromRGBO(255, 255, 255, .5), + 500: Color.fromRGBO(255, 255, 255, .6), + 600: Color.fromRGBO(255, 255, 255, .7), + 700: Color.fromRGBO(255, 255, 255, .8), + 800: Color.fromRGBO(255, 255, 255, .9), + 900: Color.fromRGBO(255, 255, 255, 1), }; @override @@ -67,9 +65,10 @@ class _ShaderMaskWidgetState extends State { shaderCallback: (bounds) => RadialGradient( center: Alignment.topLeft, radius: 1.0, - colors: [Colors.yellow, Colors.deepOrange.shade900], - tileMode: TileMode.mirror, + // colors: [Colors.yellow, Colors.deepOrange.shade900], + // tileMode: TileMode.mirror, ).createShader(bounds), + ///Specified white here to get the ShaderMask effect child: const Text( 'Flutter is hot!!', @@ -87,9 +86,9 @@ class _ShaderMaskWidgetState extends State { colors: [Colors.yellow, Colors.deepOrange.shade900], tileMode: TileMode.mirror, ).createShader(bounds), + ///Specified white here to get the ShaderMask effect child: FlutterLogo( - colors: MaterialColor(0xffffffff, color), size: 150.0, ), ), diff --git a/lib/screens/tween_animation_builder.dart b/lib/screens/tween_animation_builder.dart index 26146bb..6015679 100644 --- a/lib/screens/tween_animation_builder.dart +++ b/lib/screens/tween_animation_builder.dart @@ -41,7 +41,8 @@ class _TweenAnimationBuilderWidgetState onPressed: () => Navigator.push( context, MaterialPageRoute( - builder: (context) => CodeScreen(code: Code.tweenAnimationBuilderWidgetCode), + builder: (context) => + CodeScreen(code: Code.tweenAnimationBuilderWidgetCode), ), ), ) @@ -60,7 +61,6 @@ class _TweenAnimationBuilderWidgetState /// flutter does not build the entire widget tree during the animation child: FlutterLogo( size: 200, - colors: Colors.yellow, ), builder: (BuildContext _, Color value, Widget child) { return ColorFiltered( diff --git a/pubspec.lock b/pubspec.lock index 68b826a..e90ec52 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -1,48 +1,48 @@ # Generated by pub # See https://dart.dev/tools/pub/glossary#lockfile packages: - archive: + async: dependency: transitive description: - name: archive + name: async url: "https://pub.dartlang.org" source: hosted - version: "2.0.11" - args: + version: "2.5.0-nullsafety.1" + boolean_selector: dependency: transitive description: - name: args + name: boolean_selector url: "https://pub.dartlang.org" source: hosted - version: "1.5.2" - async: + version: "2.1.0-nullsafety.1" + characters: dependency: transitive description: - name: async + name: characters url: "https://pub.dartlang.org" source: hosted - version: "2.4.0" - boolean_selector: + version: "1.1.0-nullsafety.3" + charcode: dependency: transitive description: - name: boolean_selector + name: charcode url: "https://pub.dartlang.org" source: hosted - version: "1.0.5" - charcode: + version: "1.2.0-nullsafety.1" + clock: dependency: transitive description: - name: charcode + name: clock url: "https://pub.dartlang.org" source: hosted - version: "1.1.2" + version: "1.1.0-nullsafety.1" collection: dependency: transitive description: name: collection url: "https://pub.dartlang.org" source: hosted - version: "1.14.11" + version: "1.15.0-nullsafety.3" convert: dependency: transitive description: @@ -50,13 +50,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.1.1" - crypto: - dependency: transitive - description: - name: crypto - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.3" cupertino_icons: dependency: "direct main" description: @@ -64,6 +57,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.1.3" + fake_async: + dependency: transitive + description: + name: fake_async + url: "https://pub.dartlang.org" + source: hosted + version: "1.2.0-nullsafety.1" firebase: dependency: transitive description: @@ -131,7 +131,7 @@ packages: name: flutter_svg url: "https://pub.dartlang.org" source: hosted - version: "0.14.4" + version: "0.19.1" flutter_test: dependency: "direct dev" description: flutter @@ -156,13 +156,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "3.1.3" - image: - dependency: transitive - description: - name: image - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.4" js: dependency: transitive description: @@ -176,14 +169,14 @@ packages: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.6" + version: "0.12.10-nullsafety.1" meta: dependency: transitive description: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.1.8" + version: "1.3.0-nullsafety.3" nested: dependency: transitive description: @@ -204,14 +197,14 @@ packages: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.6.4" + version: "1.8.0-nullsafety.1" path_drawing: dependency: transitive description: name: path_drawing url: "https://pub.dartlang.org" source: hosted - version: "0.4.1" + version: "0.4.1+1" path_parsing: dependency: transitive description: @@ -232,7 +225,7 @@ packages: name: petitparser url: "https://pub.dartlang.org" source: hosted - version: "2.4.0" + version: "3.1.0" platform: dependency: transitive description: @@ -300,42 +293,42 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.5.5" + version: "1.8.0-nullsafety.2" stack_trace: dependency: transitive description: name: stack_trace url: "https://pub.dartlang.org" source: hosted - version: "1.9.3" + version: "1.10.0-nullsafety.1" stream_channel: dependency: transitive description: name: stream_channel url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.1.0-nullsafety.1" string_scanner: dependency: transitive description: name: string_scanner url: "https://pub.dartlang.org" source: hosted - version: "1.0.5" + version: "1.1.0-nullsafety.1" term_glyph: dependency: transitive description: name: term_glyph url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.2.0-nullsafety.1" test_api: dependency: transitive description: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.11" + version: "0.2.19-nullsafety.2" transparent_image: dependency: "direct main" description: @@ -349,7 +342,7 @@ packages: name: typed_data url: "https://pub.dartlang.org" source: hosted - version: "1.1.6" + version: "1.3.0-nullsafety.3" url_launcher: dependency: "direct main" description: @@ -384,7 +377,7 @@ packages: name: vector_math url: "https://pub.dartlang.org" source: hosted - version: "2.0.8" + version: "2.1.0-nullsafety.3" webview_media: dependency: transitive description: @@ -398,7 +391,7 @@ packages: name: xml url: "https://pub.dartlang.org" source: hosted - version: "3.5.0" + version: "4.5.1" youtube_player_flutter: dependency: "direct main" description: @@ -407,5 +400,5 @@ packages: source: hosted version: "6.1.1" sdks: - dart: ">=2.5.0 <3.0.0" - flutter: ">=1.12.13+hotfix.5 <2.0.0" + dart: ">=2.10.0-110 <2.11.0" + flutter: ">=1.18.0-6.0.pre <2.0.0" diff --git a/pubspec.yaml b/pubspec.yaml index 3fb13bc..d5392df 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -16,7 +16,7 @@ dependencies: # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. cupertino_icons: ^0.1.2 - flutter_svg: ^0.14.0 + flutter_svg: ^0.19.1 url_launcher: ^5.1.2 http: ^0.12.0+1 youtube_player_flutter: ^6.1.1