82 lines
1.8 KiB
Dart
82 lines
1.8 KiB
Dart
![]() |
import 'package:flutter/material.dart';
|
||
|
import 'package:provider/provider.dart';
|
||
|
|
||
|
void main(){
|
||
|
runApp(const MyApp());
|
||
|
}
|
||
|
|
||
|
class MyApp extends StatelessWidget{
|
||
|
const MyApp({super.key});
|
||
|
|
||
|
@override
|
||
|
Widget build(BuildContext context){
|
||
|
return ChangeNotifierProvider(
|
||
|
create: (context) => MyAppState(),
|
||
|
child: MaterialApp(
|
||
|
title: 'First App',
|
||
|
theme: ThemeData(
|
||
|
useMaterial3: true,
|
||
|
colorScheme: ColorScheme.fromSeed(seedColor: Colors.green)
|
||
|
),
|
||
|
home: const MyHomePage(),
|
||
|
),
|
||
|
);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
class MyAppState extends ChangeNotifier{
|
||
|
|
||
|
}
|
||
|
|
||
|
class MyHomePage extends StatefulWidget{
|
||
|
const MyHomePage({super.key});
|
||
|
|
||
|
@override
|
||
|
State<MyHomePage> createState() => _MyHomePageState();
|
||
|
}
|
||
|
|
||
|
class _MyHomePageState extends State<MyHomePage>{
|
||
|
|
||
|
var counter = 0;
|
||
|
|
||
|
|
||
|
@override
|
||
|
Widget build(BuildContext context){
|
||
|
var sCount = counter.toString();
|
||
|
|
||
|
return Scaffold(
|
||
|
body: Row(
|
||
|
children: [
|
||
|
SafeArea(
|
||
|
child: NavigationRail(
|
||
|
destinations: const [
|
||
|
NavigationRailDestination(
|
||
|
icon: Icon(Icons.home),
|
||
|
label: Text('Home'),
|
||
|
),
|
||
|
NavigationRailDestination(
|
||
|
icon: Icon(Icons.favorite),
|
||
|
label: Text('Favorites'),
|
||
|
),
|
||
|
],
|
||
|
selectedIndex: 0
|
||
|
),
|
||
|
),
|
||
|
Center(
|
||
|
child: Column(
|
||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||
|
children: [
|
||
|
Text('count: $sCount'),
|
||
|
ElevatedButton(
|
||
|
onPressed: () => counter++,
|
||
|
child: const Text('Increment')
|
||
|
),
|
||
|
],
|
||
|
),
|
||
|
),
|
||
|
|
||
|
],
|
||
|
)
|
||
|
);
|
||
|
}
|
||
|
}
|