Skip to content

Instantly share code, notes, and snippets.

Avatar
👋
vijaycreations

Vijay R vijayinyoutube

👋
vijaycreations
View GitHub Profile
View list.dart
class SliverListBldr extends StatelessWidget {
const SliverListBldr({
Key? key,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return SliverList(
delegate: SliverChildBuilderDelegate(
(BuildContext context, int index) {
View search.dart
class SliverSearch extends StatelessWidget {
const SliverSearch({
Key? key,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return SliverAppBar(
backgroundColor: Theme.of(context).scaffoldBackgroundColor,
elevation: 0,
View appbar.dart
class SliverAppBarBldr extends StatelessWidget {
const SliverAppBarBldr({
Key? key,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return SliverAppBar(
backgroundColor: Theme.of(context).scaffoldBackgroundColor,
elevation: 0,
View screen.dart
return const Scaffold(
body: CustomScrollView(
slivers: [
SliverAppBarBldr(), // <- corresponds to the top most image
SliverSearch(), // <- corresponds to search bar widget
SliverListBldr(), // <- corresponds to the body lists containers
],
),
);
View write_data.dart
Future<void> addStudents() async {
//creates a new doc with unique doc ID
return collectionRef
.add({
'Name': "TestName",
})
.then((value) => debugPrint("User Added"))
.catchError((error) => debugPrint("Failed to add user: $error"));
}
View read_date.dart
class FireStoreDataBase {
final CollectionReference collectionRef =
FirebaseFirestore.instance.collection("Students");
Future getData() async {
try {
//to get data from a single/particular document alone.
var temp = await collectionRef.doc("<your document ID here>").get();
return temp;
} catch (e) {
View setBadge.dart
setBadgeNum(int count, BuildContext context) async {
try {
await FlutterDynamicIcon.setApplicationIconBadgeNumber(count);
} on PlatformException {
print('Exception: Platform not supported');
} catch (e) {
print(e);
}
// To get currently badge number that was set.
int badgeNumber = await FlutterDynamicIcon.getApplicationIconBadgeNumber();
View btn.dart
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: buildAppBar(appBarTitle: title),
body: Center(
child: ElevatedButton(
style: getBtnStyle(context),
child: const Text('Set badge no'),
onPressed: () => setBadgeNum(5, context),
),
View event.dart
changeAppIcon() async {
try {
if (await FlutterDynamicIcon.supportsAlternateIcons) {
await FlutterDynamicIcon.setAlternateIconName(iconName[iconIndex]);
debugPrint("App icon change successful");
return;
}
} catch (e) {
debugPrint("Exception: ${e.toString()}");
}
View ui.dart
import 'package:flutter/material.dart';
class MyHomePage extends StatefulWidget {
const MyHomePage({Key? key, required this.title}) : super(key: key);
final String title;
@override
State<MyHomePage> createState() => _MyHomePageState();
}