Skip to content

Widget search #13

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions lib/bloc/list_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,13 @@ class ListBloc {
ListBloc() {
_listController.add(_listViewModel.getListItems());
}

void filter(String searchQuery) {
List<ListItem> _filteredList = _listViewModel
.getListItems()
.where((ListItem listItem) =>
listItem.title.toLowerCase().contains(searchQuery.toLowerCase()))
.toList();
_listController.sink.add(_filteredList);
}
}
1 change: 0 additions & 1 deletion lib/screens/animated_container.dart
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ class _AnimatedContainerWidgetState extends State<AnimatedContainerWidget> {
height: _iconHeight,
width: _iconWidth,
child: FlutterLogo(
colors: Colors.amber,
textColor: Colors.white,
),
),
Expand Down
2 changes: 0 additions & 2 deletions lib/screens/backdrop_filter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ class _BackdropFilterWidgetState extends State<BackdropFilterWidget> {
super.initState();
}


@override
Widget build(BuildContext context) {
return Scaffold(
Expand Down Expand Up @@ -56,7 +55,6 @@ class _BackdropFilterWidgetState extends State<BackdropFilterWidget> {
height: 200,
width: 200,
child: FlutterLogo(
colors: Colors.lightBlue,
textColor: Colors.white,
),
),
Expand Down
2 changes: 0 additions & 2 deletions lib/screens/clip_r_rect.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ class _ClipRRectWidgetState extends State<ClipRRectWidget> {
super.initState();
}


@override
Widget build(BuildContext context) {
return Scaffold(
Expand Down Expand Up @@ -71,7 +70,6 @@ class _ClipRRectWidgetState extends State<ClipRRectWidget> {
width: 100,
height: 100,
child: FlutterLogo(
colors: Colors.lightBlue,
textColor: Colors.white,
),
),
Expand Down
2 changes: 0 additions & 2 deletions lib/screens/fitted_box.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ class _FittedBoxWidgetState extends State<FittedBoxWidget> {
super.initState();
}


@override
Widget build(BuildContext context) {
return Scaffold(
Expand Down Expand Up @@ -63,7 +62,6 @@ class _FittedBoxWidgetState extends State<FittedBoxWidget> {
height: _heightValue,
width: 300,
child: FlutterLogo(
colors: Colors.lightBlue,
textColor: Colors.white,
),
),
Expand Down
1 change: 0 additions & 1 deletion lib/screens/hero.dart
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ class HeroWidget extends StatelessWidget {
width: 100,
height: 100,
child: FlutterLogo(
colors: Colors.lightBlue,
textColor: Colors.white,
),
),
Expand Down
1 change: 0 additions & 1 deletion lib/screens/hero2.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ class Hero2Widget extends StatelessWidget {
width: 100,
height: 100,
child: FlutterLogo(
colors: Colors.lightBlue,
textColor: Colors.white,
),
),
Expand Down
151 changes: 100 additions & 51 deletions lib/screens/home_page.dart
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -30,6 +32,7 @@ class _HomePageState extends State<HomePage> with WidgetsBindingObserver {
"https://play.google.com/store/apps/details?id=com.annsh.flutterwidgetguide";
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
FirebaseMessaging _fcm;
bool _isSearching;

@override
void didChangeAppLifecycleState(AppLifecycleState state) {
Expand Down Expand Up @@ -139,8 +142,7 @@ class _HomePageState extends State<HomePage> with WidgetsBindingObserver {
_takeNotificationAction(message, context, false);
},
);
// }
//});
_isSearching = false;
}

@override
Expand Down Expand Up @@ -267,7 +269,7 @@ class _HomePageState extends State<HomePage> with WidgetsBindingObserver {
controller: _hideButtonController,
//This is to contain Sliver Elements
slivers: <Widget>[
appBar(context),
appBar(context, listBloc),
SliverPadding(
padding: EdgeInsets.all(4.0),
),
Expand All @@ -281,66 +283,113 @@ class _HomePageState extends State<HomePage> 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: <Widget>[
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: <Widget>[
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>[
//
// ],
);

Widget bodyList(List<ListItem> listItems) => SliverList(
Expand Down
1 change: 0 additions & 1 deletion lib/screens/indexed_stack.dart
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ class _IndexedStackWidgetState extends State<IndexedStackWidget> {
child: GestureDetector(
child: FlutterLogo(
duration: Duration(milliseconds: 500),
colors: _imageColor,
curve: Curves.easeInOut,
),
onTap: () => setState(() => _imageColor == Colors.blue
Expand Down
1 change: 0 additions & 1 deletion lib/screens/opacity.dart
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ class _OpacityWidgetState extends State<OpacityWidget> {
width: 100,
height: 100,
child: FlutterLogo(
colors: Colors.lightBlue,
textColor: Colors.white,
),
),
Expand Down
1 change: 0 additions & 1 deletion lib/screens/positioned.dart
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ class _PositionedWidgetState extends State<PositionedWidget> {
width: 50,
height: 50,
child: FlutterLogo(
colors: Colors.lightBlue,
textColor: Colors.white,
),
),
Expand Down
1 change: 0 additions & 1 deletion lib/screens/selectable_text.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ class _SelectableTextWidgetState extends State<SelectableTextWidget> {
margin: EdgeInsets.only(left: 24.0, right: 24.0, top: 24.0),
child: FlutterLogo(
size: 100,
colors: bgColor,
),
),

Expand Down
31 changes: 15 additions & 16 deletions lib/screens/shadermask_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,17 @@ class ShaderMaskWidget extends StatefulWidget {
}

class _ShaderMaskWidgetState extends State<ShaderMaskWidget> {

Map<int, Color> 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<int, Color> 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
Expand Down Expand Up @@ -67,9 +65,10 @@ class _ShaderMaskWidgetState extends State<ShaderMaskWidget> {
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!!',
Expand All @@ -87,9 +86,9 @@ class _ShaderMaskWidgetState extends State<ShaderMaskWidget> {
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,
),
),
Expand Down
4 changes: 2 additions & 2 deletions lib/screens/tween_animation_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ class _TweenAnimationBuilderWidgetState
onPressed: () => Navigator.push(
context,
MaterialPageRoute(
builder: (context) => CodeScreen(code: Code.tweenAnimationBuilderWidgetCode),
builder: (context) =>
CodeScreen(code: Code.tweenAnimationBuilderWidgetCode),
),
),
)
Expand All @@ -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(
Expand Down
Loading