Flutter 7315个系统图标展示

Flutter 7315个系统图标展示_第1张图片
7315个系统图标.png
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:fluttertemplet/DartExpand/DDLog.dart';
import 'package:styled_widget/styled_widget.dart';

import 'DartExpand/ListView_extension.dart';


class IconsListPage extends StatefulWidget {

  @override
  _IconsListPageState createState() => _IconsListPageState();
}

class _IconsListPageState extends State {
  TextEditingController editingController = TextEditingController();

  var titles = List.from(kIconDataDic.keys);
  var list = List.from(kIconDataDic.keys);

  @override
  void initState() {
    super.initState();
  }

  @override
  void dispose() {
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("fluttefr 系统 Icons"),
      ),
      body: Container(
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            buildTextField(context)
                .padding(all: 10.0)
            ,
            Text("找到 ${list.length} 条数据")
                .padding(left: 10, right: 10)
            ,
            buildListView(context)
                .expanded()
            ,
          ],
        ),
      ),
    );
  }


  TextField buildTextField(BuildContext context) {
    return TextField(
        onChanged: _changeValue,
      //   onChanged: (value) {
      //   DDLog(value);
      // },
      controller: editingController,
      decoration: InputDecoration(
          icon: Icon(Icons.search),
        // labelText: "Search",
          hintText: "Search",
          // prefixIcon: Icon(Icons.search),
          // border: OutlineInputBorder(
          //     borderRadius: BorderRadius.all(Radius.circular(25.0))
          // ),
      ),
    );
  }


  CupertinoScrollbar buildListView(BuildContext context) {
    list.sort((a, b) => a.compareTo(b));
    return ListView.separated(
        itemCount: list.length,
        itemBuilder: (context, index) {
          final item = list[index];
          return ListTile(
            leading: Icon(kIconDataDic[item]),
            title: Text("$item"),
            // subtitle: Text(array[0]),
            onTap: (){
              DDLog(item);
              // Clipboard.setData(ClipboardData(text: "$item"));
              editingController.text = item.split('.').last;
              _changeValue(editingController.text);
            },
          );
        },
        separatorBuilder: (context, index) {
          return Divider(
            height: .5,
            indent: 15,
            endIndent: 15,
            color: Color(0xFFDDDDDD),
          );
        },
      ).addCupertinoScrollbar()
    ;
  }

  void _changeValue(String value) {
    // DDLog(value);
    setState(() {
      if (value.isEmpty) {
        list = titles;
      } else {
        list = titles.where((element) => element.contains(value)).toList();
        DDLog(list.length);
      }
    });
  }
}

Map kIconDataDic = {

};

///kIconDataDic 字典见文件
IconsListPage.dart

你可能感兴趣的:(Flutter 7315个系统图标展示)