main.dart 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. import 'package:flutter/material.dart';
  2. import 'pages/advanced/index.dart';
  3. import 'pages/basic/index.dart';
  4. void main() => runApp(MyApp());
  5. /// This widget is the root of your application.
  6. class MyApp extends StatelessWidget {
  7. final _DATA = [...Basic, ...Advanced];
  8. @override
  9. Widget build(BuildContext context) {
  10. return MaterialApp(
  11. debugShowCheckedModeBanner: false,
  12. theme: ThemeData(
  13. primarySwatch: Colors.blue,
  14. ),
  15. home: Scaffold(
  16. appBar: AppBar(
  17. title: const Text('玻璃心'),
  18. ),
  19. body: ListView.builder(
  20. itemCount: _DATA.length,
  21. itemBuilder: (context, index) {
  22. return _DATA[index]['widget'] == null
  23. ? Ink(
  24. color: Colors.grey,
  25. child: ListTile(
  26. title: Text(_DATA[index]['name'] as String,
  27. style: TextStyle(fontSize: 24, color: Colors.white)),
  28. ),
  29. )
  30. : ListTile(
  31. onTap: () {
  32. Navigator.push(
  33. context,
  34. MaterialPageRoute(
  35. builder: (context) => Scaffold(
  36. appBar: AppBar(
  37. title:
  38. Text(_DATA[index]['name'] as String),
  39. ),
  40. body: _DATA[index]['widget'] as Widget?,
  41. )));
  42. },
  43. title: Text(
  44. _DATA[index]['name'] as String,
  45. style: TextStyle(fontSize: 24, color: Colors.black),
  46. ),
  47. );
  48. },
  49. ),
  50. ),
  51. );
  52. }
  53. }