dart_std 0.0.7 dart_std: ^0.0.7 copied to clipboard
A library with full of interactive features that can be used as extension methods.
/*
* *
* * * GNU General Public License v3.0
* * *******************************************************************************************
* * * Created By Debojyoti Singha
* * * Copyright (c) 2023.
* * * This program is free software: you can redistribute it and/or modify
* * * it under the terms of the GNU General Public License as published by
* * * the Free Software Foundation, either version 3 of the License, or
* * * (at your option) any later version.
* * *
* * * This program is distributed in the hope that it will be useful,
* * *
* * * but WITHOUT ANY WARRANTY; without even the implied warranty of
* * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* * * GNU General Public License for more details.
* * *
* * * You should have received a copy of the GNU General Public License
* * * along with this program. If not, see <https://www.gnu.org/licenses/>.
* * * Contact Email: support@swingtechnologies.in
* * ******************************************************************************************
*
*/
import 'package:dart_std/dart_std.dart';
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.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({
super.key,
required this.title,
});
final String title;
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
final int _counter = 0;
final List<int> intArray = [0, 1, 2, 3];
final List<String> strArray = ['Deb', 'Singha'];
static const Triple<int, bool, String> _triple = Triple(1, false, 'Deb');
final map = {'Deb': 'Singha'};
void _incrementCounter() {
debugPrint(2.toOrdinal());
debugPrint(0.isNull().toString());
debugPrint(intArray.lastIndex.toString());
debugPrint(intArray.elementAtOrNull(5).toString());
debugPrint(intArray.firstIndex.toString());
debugPrint(intArray.indices.toString());
debugPrint(intArray.drop(1).toString());
debugPrint(intArray.dropWhile((element) => element.isEven).toString());
debugPrint(intArray.dropLast(2).toString());
debugPrint(_triple.third.toString());
debugPrint(10.toLikes());
debugPrint(map.filter((entry) => entry.key == 'Deb').values.toString());
debugPrint(20.divide(2.5).toString());
debugPrint(intArray.joinToString());
debugPrint(strArray.joinToString());
context.navigateTo(const SecondScreen());
}
@override
void initState() {
super.initState();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
const Text(
'You have pushed the button this many times:',
),
Text(
'$_counter',
style: Theme.of(context).textTheme.headlineMedium,
),
],
),
),
floatingActionButton: FloatingActionButton(
onPressed: _incrementCounter,
tooltip: 'Increment',
child: const Icon(Icons.add),
), // This trailing comma makes auto-formatting nicer for build methods.
);
}
}
class SecondScreen extends StatefulWidget {
const SecondScreen({super.key});
@override
State<SecondScreen> createState() => _SecondScreenState();
}
class _SecondScreenState extends State<SecondScreen> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Second Screen'),
),
body: const Center(
child: Text('Second Screen'),
),
);
}
}