notification_listview 1.1.0 copy "notification_listview: ^1.1.0" to clipboard
notification_listview: ^1.1.0 copied to clipboard

This package is for Hyundai AutoEver internship assignments.

example/main.dart

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:notification_listview/notification_listview.dart';
import 'package:notification_listview/notification_tile.dart';
import 'package:notification_listview/notification_type.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: const MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({Key? key, required this.title}) : super(key: key);

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    return const ListViewPage();
  }
}

//////////////////////////////////////////////////////////////////////////////

class Temp {
  final NotiTileType notiTileType;
  final String title;
  final String content;

  const Temp(this.notiTileType, this.title, this.content);

  @override
  String toString() {
    return 'Temp{title: $title, type: $notiTileType}\n';
  }
}

class ListViewPage extends StatefulWidget {
  const ListViewPage({Key? key}) : super(key: key);

  @override
  State<ListViewPage> createState() => _ListViewPageState();
}

class _ListViewPageState extends State<ListViewPage> {
  final List<Temp> list = const [
    Temp(NotiTileType.alert, "title", "content"),
    Temp(NotiTileType.normal, "title", "content"),
    Temp(NotiTileType.chatting, "title", "content"),
    Temp(NotiTileType.alert, "title", "content"),
    Temp(NotiTileType.normal, "title", "content"),
    Temp(NotiTileType.chatting, "title", "content"),
    Temp(NotiTileType.alert, "title", "content"),
    Temp(NotiTileType.normal, "title", "content"),
    Temp(NotiTileType.chatting, "title", "content"),
    Temp(NotiTileType.alert, "title", "content"),
    Temp(NotiTileType.normal, "title", "content"),
  ];
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: const CupertinoNavigationBar(
        middle: Text("Notification ListView"),
      ),
      body: Container(
        color: Colors.black12,
        child: NotificationListView<Temp>(
          elements: list,
          groupBy: (element) => element.notiTileType,
          hasHeader: true,
          onTapSearch: () => print("tap search button"),
          isSearching: false,
          itemCount: list.length,
          indexItemBuilder: (context, e, i) => NotiListViewTile(
            isNew: true,
            title: e.title,
            content: e.content,
            notiTileType: e.notiTileType,
            onTapDelete: () => print("tap delete button"),
          ),
        ),
      ),
    );
  }
}
3
likes
140
points
14
downloads

Publisher

unverified uploader

Weekly Downloads

This package is for Hyundai AutoEver internship assignments.

Homepage
Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on notification_listview