Initial commit. I can successfully create random tensor.
This commit is contained in:
6
lib/src/sample_feature/sample_item.dart
Normal file
6
lib/src/sample_feature/sample_item.dart
Normal file
@ -0,0 +1,6 @@
|
||||
/// A placeholder class that represents an entity or model.
|
||||
class SampleItem {
|
||||
const SampleItem(this.id);
|
||||
|
||||
final int id;
|
||||
}
|
20
lib/src/sample_feature/sample_item_details_view.dart
Normal file
20
lib/src/sample_feature/sample_item_details_view.dart
Normal file
@ -0,0 +1,20 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// Displays detailed information about a SampleItem.
|
||||
class SampleItemDetailsView extends StatelessWidget {
|
||||
const SampleItemDetailsView({super.key});
|
||||
|
||||
static const routeName = '/sample_item';
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Item Details'),
|
||||
),
|
||||
body: const Center(
|
||||
child: Text('More Information Here'),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
71
lib/src/sample_feature/sample_item_list_view.dart
Normal file
71
lib/src/sample_feature/sample_item_list_view.dart
Normal file
@ -0,0 +1,71 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../settings/settings_view.dart';
|
||||
import 'sample_item.dart';
|
||||
import 'sample_item_details_view.dart';
|
||||
|
||||
/// Displays a list of SampleItems.
|
||||
class SampleItemListView extends StatelessWidget {
|
||||
const SampleItemListView({
|
||||
super.key,
|
||||
this.items = const [SampleItem(1), SampleItem(2), SampleItem(3)],
|
||||
});
|
||||
|
||||
static const routeName = '/';
|
||||
|
||||
final List<SampleItem> items;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('Sample Items'),
|
||||
actions: [
|
||||
IconButton(
|
||||
icon: const Icon(Icons.settings),
|
||||
onPressed: () {
|
||||
// Navigate to the settings page. If the user leaves and returns
|
||||
// to the app after it has been killed while running in the
|
||||
// background, the navigation stack is restored.
|
||||
Navigator.restorablePushNamed(context, SettingsView.routeName);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
// To work with lists that may contain a large number of items, it’s best
|
||||
// to use the ListView.builder constructor.
|
||||
//
|
||||
// In contrast to the default ListView constructor, which requires
|
||||
// building all Widgets up front, the ListView.builder constructor lazily
|
||||
// builds Widgets as they’re scrolled into view.
|
||||
body: ListView.builder(
|
||||
// Providing a restorationId allows the ListView to restore the
|
||||
// scroll position when a user leaves and returns to the app after it
|
||||
// has been killed while running in the background.
|
||||
restorationId: 'sampleItemListView',
|
||||
itemCount: items.length,
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
final item = items[index];
|
||||
|
||||
return ListTile(
|
||||
title: Text('SampleItem ${item.id}'),
|
||||
leading: const CircleAvatar(
|
||||
// Display the Flutter Logo image asset.
|
||||
foregroundImage: AssetImage('assets/images/flutter_logo.png'),
|
||||
),
|
||||
onTap: () {
|
||||
// Navigate to the details page. If the user leaves and returns to
|
||||
// the app after it has been killed while running in the
|
||||
// background, the navigation stack is restored.
|
||||
Navigator.restorablePushNamed(
|
||||
context,
|
||||
SampleItemDetailsView.routeName,
|
||||
);
|
||||
}
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user