repo_id
stringlengths
21
168
file_path
stringlengths
36
210
content
stringlengths
1
9.98M
__index_level_0__
int64
0
0
mirrored_repositories/airplane/lib/ui
mirrored_repositories/airplane/lib/ui/pages/setting_page.dart
import 'package:airplane/cubit/auth_cubit.dart'; import 'package:airplane/cubit/page_cubit.dart'; import 'package:airplane/shared/theme.dart'; import 'package:airplane/ui/widgets/custom_button.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; class SettingPage extends StatelessWidget{ const SettingPage({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return BlocConsumer<AuthCubit, AuthState>( listener: (context, state){ if(state is AuthFailed){ ScaffoldMessenger.of(context).showSnackBar( SnackBar( backgroundColor: kRedColor, content: Text(state.error), ) ); } else if (state is AuthInitial){ context.read<PageCubit>().setPage(0); Navigator.pushNamedAndRemoveUntil(context, '/sign-in', (route) => false); } }, builder: (context, state){ if(state is AuthLoading){ return Center( child: CircularProgressIndicator(), ); } return Center( child: CustomButton( title: 'Sign Out', width: 220, onPressed: (){ context.read<AuthCubit>().signOut(); }, ) ); }, ); } }
0
mirrored_repositories/airplane/lib/ui
mirrored_repositories/airplane/lib/ui/pages/transaction_page.dart
import 'package:airplane/cubit/transaction_cubit.dart'; import 'package:airplane/shared/theme.dart'; import 'package:airplane/ui/widgets/transaction_card.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; class TransactionPage extends StatefulWidget{ const TransactionPage({Key? key}) : super(key: key); @override State<TransactionPage> createState() => _TransactionPageState(); } class _TransactionPageState extends State<TransactionPage> { @override void initState() { context.read<TransactionCubit>().fetchTransaction(); super.initState(); } @override Widget build(BuildContext context) { return BlocBuilder<TransactionCubit, TransactionState>( builder: (context, state) { if(state is TransactionLoading){ return Center( child: CircularProgressIndicator(), ); }else if(state is TransactionSuccess){ if(state.transactions.length == 0){ return Center( child: Text( 'No Transaction!' ), ); } else { return ListView.builder( itemCount: state.transactions.length, padding: EdgeInsets.symmetric(horizontal: defaultMargin), itemBuilder: (context, index){ return TransactionCard(state.transactions[index], ); }); } } return Center( child: Text( 'Get Some Help?' ), ); }, ); } }
0
mirrored_repositories/airplane/lib/ui
mirrored_repositories/airplane/lib/ui/pages/splash_page.dart
import 'dart:async'; import 'package:airplane/cubit/auth_cubit.dart'; import 'package:firebase_auth/firebase_auth.dart'; import 'package:flutter/material.dart'; import '../../shared/theme.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; class SplashPage extends StatefulWidget { const SplashPage({Key? key}) : super(key: key); @override State<SplashPage> createState() => _SplashPageState(); } class _SplashPageState extends State<SplashPage> { @override void initState() { Timer(Duration(seconds: 3), () { User? user = FirebaseAuth.instance.currentUser; if(user == null){ Navigator.pushNamedAndRemoveUntil(context, '/get-started', (route) => false); } else { context.read<AuthCubit>().getCurrentUser(user.uid); Navigator.pushNamedAndRemoveUntil(context, '/main', (route) => false); } }); super.initState(); } @override Widget build(BuildContext context) { dynamic parentWidth = MediaQuery.of(context).size.width; dynamic parentHeight = MediaQuery.of(context).size.height; return Scaffold( backgroundColor: kPrimaryColor, body: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Container( width: parentWidth/4, height: parentWidth/4, margin: EdgeInsets.only(bottom: 50), decoration: BoxDecoration( image: DecorationImage( image: AssetImage( 'assets/icon_plane.png' ), ) ), ), Text( 'AIRPLANE', style: whiteTextStyle.copyWith( fontSize: 32, fontWeight: medium, letterSpacing: 10 ), ) ]), ), ); } }
0
mirrored_repositories/airplane/lib/ui
mirrored_repositories/airplane/lib/ui/pages/main_page.dart
import 'package:airplane/cubit/page_cubit.dart'; import 'package:airplane/ui/pages/homepage.dart'; import 'package:airplane/ui/pages/setting_page.dart'; import 'package:airplane/ui/pages/transaction_page.dart'; import 'package:airplane/ui/pages/wallet_page.dart'; import 'package:airplane/ui/widgets/custom_button_navigation_item.dart'; import 'package:flutter/material.dart'; import '../../shared/theme.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; class MainPage extends StatelessWidget{ const MainPage({Key? key}) : super(key: key); @override Widget build(BuildContext context) { Widget buildContent(int currentIndex){ switch(currentIndex){ case 0: return HomePage(); case 1: return TransactionPage(); case 2: return WalletPage(); case 3: return SettingPage(); default: return HomePage(); } } Widget customButtonNavigation(){ return Align( alignment: Alignment.bottomCenter, child: Container( margin: EdgeInsets.only( bottom: 30, left: defaultMargin, right: defaultMargin, ), width: double.infinity, height: 60, decoration: BoxDecoration( color: kWhiteColor, borderRadius: BorderRadius.circular(18), ), child: Row( mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ CustomButtonNavigationItem( index: 0, imageUrl: 'assets/icon_home.png', ), CustomButtonNavigationItem( index: 1, imageUrl: 'assets/icon_booking.png', ), CustomButtonNavigationItem( index: 2, imageUrl: 'assets/icon_card.png', ), CustomButtonNavigationItem( index: 3, imageUrl: 'assets/icon_settings.png', ) ], ), ), ); } return BlocBuilder<PageCubit, int>( builder: (context, currentIndex) { return Scaffold( backgroundColor: kBackgroundColor, body: Stack( children: [ buildContent(currentIndex), customButtonNavigation(), ], ), ); }, ); } }
0
mirrored_repositories/airplane/lib
mirrored_repositories/airplane/lib/services/destination_service.dart
import 'package:airplane/models/destination_model.dart'; import 'package:cloud_firestore/cloud_firestore.dart'; class DestinationService { CollectionReference _destinationRef = FirebaseFirestore.instance.collection('destinations'); Future<List<DestinationModel>> fetchDestination() async { try { QuerySnapshot result = await _destinationRef.get(); List<DestinationModel> destinations = result.docs.map((e){ return DestinationModel.fromJson( e.id, e.data() as Map<String, dynamic>); }).toList(); return destinations; } catch (e){ throw e; } } }
0
mirrored_repositories/airplane/lib
mirrored_repositories/airplane/lib/services/user_service.dart
import 'package:airplane/models/user_model.dart'; import 'package:cloud_firestore/cloud_firestore.dart'; class UserService { CollectionReference _userReference = FirebaseFirestore.instance.collection('users'); Future<void> setUser(UserModel user) async { try{ _userReference.doc(user.id).set({ 'email': user.email, 'name': user.name, 'hobby': user.hobby, 'balance': user.balance, }); } catch (e){ throw e; } } Future<UserModel> getUserById(String id) async { try{ DocumentSnapshot snapshot = await _userReference.doc(id).get(); return UserModel( id: id, email: snapshot['email'], name: snapshot['name'], hobby: snapshot['hobby'], balance: snapshot['balance'], ); } catch (e){ throw e; } } }
0
mirrored_repositories/airplane/lib
mirrored_repositories/airplane/lib/services/auth_service.dart
import 'package:airplane/services/user_service.dart'; import 'package:firebase_auth/firebase_auth.dart'; import '../models/user_model.dart'; class AuthService { FirebaseAuth _auth = FirebaseAuth.instance; Future<UserModel> signIn({ required String email, required String password }) async { try{ UserCredential userCredential = await _auth.signInWithEmailAndPassword( email: email, password: password ); UserModel user = await UserService().getUserById(userCredential.user!.uid); return user; } catch (e){ throw e; } } Future<UserModel> signUp({ required String email, required String password, required String name, String hobby = '' }) async { try{ UserCredential userCredential = await _auth.createUserWithEmailAndPassword(email: email, password: password); UserModel user = UserModel( id: userCredential.user!.uid, email: email, name: name, hobby: hobby, balance: 280000000); await UserService().setUser(user); return user; } catch (e){ throw e; } } Future<void> signOut() async { try{ await _auth.signOut(); } catch (e){ throw e; } } }
0
mirrored_repositories/airplane/lib
mirrored_repositories/airplane/lib/services/transaction_service.dart
import 'package:airplane/models/transaction_model.dart'; import 'package:cloud_firestore/cloud_firestore.dart'; class TransactionService { CollectionReference _transactionRef = FirebaseFirestore.instance.collection('transactions'); Future<void> createTransaction(TransactionModel transactionModel) async { try{ _transactionRef.add({ 'destination' : transactionModel.destination.toJson(), 'amountOfTraveler' : transactionModel.amountOfTraveler, 'selectedSeat' : transactionModel.selectedSeats, 'insurance' : transactionModel.insurance, 'refundable': transactionModel.refundable, 'vat': transactionModel.vat, 'price': transactionModel.price, 'grandTotal': transactionModel.grandTotal, }); } catch (e){ throw e; } } Future<List<TransactionModel>> fetchTransaction() async { try { QuerySnapshot result = await _transactionRef.get(); List<TransactionModel> transactions = result.docs.map((e){ return TransactionModel.fromJson( e.id, e.data() as Map<String, dynamic>); }).toList(); return transactions; } catch (e){ throw e; } } }
0
mirrored_repositories/airplane
mirrored_repositories/airplane/test/widget_test.dart
// This is a basic Flutter widget test. // // To perform an interaction with a widget in your test, use the WidgetTester // utility in the flutter_test package. For example, you can send tap and scroll // gestures. You can also use WidgetTester to find child widgets in the widget // tree, read text, and verify that the values of widget properties are correct. import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:airplane/main.dart'; void main() { testWidgets('Counter increments smoke test', (WidgetTester tester) async { // Build our app and trigger a frame. await tester.pumpWidget(const MyApp()); // Verify that our counter starts at 0. expect(find.text('0'), findsOneWidget); expect(find.text('1'), findsNothing); // Tap the '+' icon and trigger a frame. await tester.tap(find.byIcon(Icons.add)); await tester.pump(); // Verify that our counter has incremented. expect(find.text('0'), findsNothing); expect(find.text('1'), findsOneWidget); }); }
0
mirrored_repositories/Flutter-Sample-For-Beginner
mirrored_repositories/Flutter-Sample-For-Beginner/lib/CelebrityDetailScreen.dart
import 'package:flutter/material.dart'; import 'package:flutter_app/CelebrityItem.dart'; import 'package:flutter_app/model/CelebrityInfo.dart'; // ignore: must_be_immutable class CelebrityDetailScreen extends StatelessWidget { CelebrityInfo info; final VoidCallback onPressed; CelebrityDetailScreen({Key key, this.info, this.onPressed}) : super(key: key); @override Widget build(BuildContext context) { return new Scaffold( backgroundColor: Colors.teal, appBar: new AppBar( title: new Text("Second Screen"), ), body: new Align( alignment: Alignment.topCenter, child: new Column( mainAxisAlignment: MainAxisAlignment.center, mainAxisSize: MainAxisSize.max, children: <Widget>[ new CelebrityWidget(info: info, isVisible: false), new Container( decoration: new BoxDecoration(color: Colors.lightGreenAccent), margin: const EdgeInsets.only(top: 15.0, bottom: 5.0), child: new RaisedButton( padding: const EdgeInsets.all(15.0), onPressed: onPressed, child: new Text('Show Scroll page'), )), ]), )); } } //onPressed: () { //// Navigate back to first screen when tapped! //Navigator.pop(context); //}
0
mirrored_repositories/Flutter-Sample-For-Beginner
mirrored_repositories/Flutter-Sample-For-Beginner/lib/ScrollingImageDetailer.dart
import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; class ScrollingImageDetailer extends StatelessWidget { ScrollingImageDetailer({Key key}) : super(key: key); @override Widget build(BuildContext context) { // final key = new GlobalKey<ScaffoldState>(); Column createContactColumn(IconData icon, String label, VoidCallback onPressed) { Color color = Theme .of(context) .primaryColor; return Column( mainAxisSize: MainAxisSize.min, mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ IconButton(icon: Icon(icon, color: color), onPressed: onPressed), Container( margin: const EdgeInsets.all(10.0), child: Text(label, style: TextStyle( fontSize: 12.0, fontWeight: FontWeight.w400, color: color))) ]); } return new MaterialApp( title: "My FIrst Flutter", theme: new ThemeData(primarySwatch: Colors.pink), home: new Scaffold( backgroundColor: Colors.pink[100], appBar: new AppBar(title: new Text("Hello Google!")), body: new Container( padding: const EdgeInsets.all(32.0), child: new LayoutBuilder( builder: (BuildContext context, BoxConstraints viewportConstraints) { return SingleChildScrollView(child: new ConstrainedBox( constraints: new BoxConstraints( minHeight: viewportConstraints.maxHeight, ), child: new Column(children: <Widget>[ Row(children: <Widget>[ Expanded( child: new Column( crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ Image.asset( 'images/lord_shiva_animated_hd_wallpapers.jpg', height: 240.0, fit: BoxFit.cover, ), Container( child: new Text( 'Oeschinen Lake Campground', style: TextStyle( fontWeight: FontWeight.bold, )), padding: const EdgeInsets.only( bottom: 8.0)), Text( 'Kandersteg, Switzerland', style: TextStyle( color: Colors.grey[850], ), ) ], )), Icon( Icons.star, color: Colors.red[500], ), Text('41') ]), Container( margin: const EdgeInsets.all(10.0), padding: const EdgeInsets.all(10.0), child: new Builder(builder: (context) { return Row( mainAxisAlignment: MainAxisAlignment .spaceBetween, children: <Widget>[ createContactColumn(Icons.call, 'CALL', () { showSnackBar(context, 'CALL'); }), createContactColumn( Icons.near_me, 'ROUTE', () { showSnackBar(context, 'ROUTE'); }), createContactColumn(Icons.share, 'SHARE', () { showSnackBar(context, 'SHARE'); }) ]); }), ), Container( padding: const EdgeInsets.all(10.0), child: Text( 'Lake Oeschinen lies at the foot of the Blüemlisalp in the Bernese Alps. Situated 1,578 meters above sea level, it is one of the larger Alpine Lakes. A gondola ride from Kandersteg, followed by a half-hour walk through pastures and pine forest, leads you to the lake, which warms to 20 degrees Celsius in the summer. Activities enjoyed here include rowing, and riding the summer toboggan run. Lake Oeschinen lies at the foot of the Blüemlisalp in the Bernese Alps. Situated 1,578 meters above sea level, it is one of the larger Alpine Lakes. A gondola ride from Kandersteg, followed by a half-hour walk through pastures and pine forest, leads you to the lake, which warms to 20 degrees Celsius in the summer. Activities enjoyed here include rowing, and riding the summer toboggan run. Lake Oeschinen lies at the foot of the Blüemlisalp in the Bernese Alps. Situated 1,578 meters above sea level, it is one of the larger Alpine Lakes. A gondola ride from Kandersteg, followed by a half-hour walk through pastures and pine forest, leads you to the lake, which warms to 20 degrees Celsius in the summer. Activities enjoyed here include rowing, and riding the summer toboggan run. Lake Oeschinen lies at the foot of the Blüemlisalp in the Bernese Alps. Situated 1,578 meters above sea level, it is one of the larger Alpine Lakes. A gondola ride from Kandersteg, followed by a half-hour walk through pastures and pine forest, leads you to the lake, which warms to 20 degrees Celsius in the summer. Activities enjoyed here include rowing, and riding the summer toboggan run. Lake Oeschinen lies at the foot of the Blüemlisalp in the Bernese Alps. Situated 1,578 meters above sea level, it is one of the larger Alpine Lakes. A gondola ride from Kandersteg, followed by a half-hour walk through pastures and pine forest, leads you to the lake, which warms to 20 degrees Celsius in the summer. Activities enjoyed here include rowing, and riding the summer toboggan run. Lake Oeschinen lies at the foot of the Blüemlisalp in the Bernese Alps. Situated 1,578 meters above sea level, it is one of the larger Alpine Lakes. A gondola ride from Kandersteg, followed by a half-hour walk through pastures and pine forest, leads you to the lake, which warms to 20 degrees Celsius in the summer. Activities enjoyed here include rowing, and riding the summer toboggan run. Lake Oeschinen lies at the foot of the Blüemlisalp in the Bernese Alps. Situated 1,578 meters above sea level, it is one of the larger Alpine Lakes. A gondola ride from Kandersteg, followed by a half-hour walk through pastures and pine forest, leads you to the lake, which warms to 20 degrees Celsius in the summer. Activities enjoyed here include rowing, and riding the summer toboggan run. Lake Oeschinen lies at the foot of the Blüemlisalp in the Bernese Alps. Situated 1,578 meters above sea level, it is one of the larger Alpine Lakes. A gondola ride from Kandersteg, followed by a half-hour walk through pastures and pine forest, leads you to the lake, which warms to 20 degrees Celsius in the summer. Activities enjoyed here include rowing, and riding the summer toboggan run.' + 'Lake Oeschinen lies at the foot of the Blüemlisalp in the Bernese Alps. Situated 1,578 meters above sea level, it is one of the larger Alpine Lakes. A gondola ride from Kandersteg, followed by a half-hour walk through pastures and pine forest, leads you to the lake, which warms to 20 degrees Celsius in the summer. Activities enjoyed here include rowing, and riding the summer toboggan run.', textAlign: TextAlign.justify, softWrap: true), ) ]))); }, )), )); } /// This method used to show the SnackBar void showSnackBar(BuildContext context, String buttonName) { Scaffold.of(context).showSnackBar( new SnackBar(content: new Text('$buttonName button clicked!'))); } }
0
mirrored_repositories/Flutter-Sample-For-Beginner
mirrored_repositories/Flutter-Sample-For-Beginner/lib/main.dart
import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; import 'package:flutter_app/CelebrityItem.dart'; import 'package:flutter_app/model/CelebrityInfo.dart'; void main() { debugPaintSizeEnabled = false; // set True to check Layout bound design debugging runApp(new MyApp()); // runApp(new DesignedApp()); } class DesignedApp extends StatelessWidget { @override Widget build(BuildContext context) { // final key = new GlobalKey<ScaffoldState>(); Column createContactColumn(IconData icon, String label, VoidCallback onPressed) { Color color = Theme .of(context) .primaryColor; return Column( mainAxisSize: MainAxisSize.min, mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ IconButton(icon: Icon(icon, color: color), onPressed: onPressed), Container( margin: const EdgeInsets.all(10.0), child: Text(label, style: TextStyle( fontSize: 12.0, fontWeight: FontWeight.w400, color: color))) ]); } return new MaterialApp( title: "My First Flutter", theme: new ThemeData(primarySwatch: Colors.pink), home: new Scaffold( backgroundColor: Colors.pink[100], appBar: new AppBar(title: new Text("Hello Flutter!")), body: new Container( padding: const EdgeInsets.all(32.0), child: new LayoutBuilder( builder: (BuildContext context, BoxConstraints viewportConstraints) { return SingleChildScrollView(child: new ConstrainedBox( constraints: new BoxConstraints( minHeight: viewportConstraints.maxHeight, ), child: new Column(children: <Widget>[ Row(children: <Widget>[ Expanded( child: new Column( crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ Image.asset( 'images/lord_shiva_animated_hd_wallpapers.jpg', height: 240.0, fit: BoxFit.cover, ), Container( child: new Text( 'Oeschinen Lake Campground', style: TextStyle( fontWeight: FontWeight.bold, )), padding: const EdgeInsets.only( bottom: 8.0)), Text( 'Kandersteg, Switzerland', style: TextStyle( color: Colors.grey[850], ), ) ], )), Icon( Icons.star, color: Colors.red[500], ), Text('41') ]), Container( margin: const EdgeInsets.all(10.0), padding: const EdgeInsets.all(10.0), child: new Builder(builder: (context) { return Row( mainAxisAlignment: MainAxisAlignment .spaceBetween, children: <Widget>[ createContactColumn(Icons.call, 'CALL', () { showSnackBar(context, 'CALL'); }), createContactColumn( Icons.near_me, 'ROUTE', () { showSnackBar(context, 'ROUTE'); }), createContactColumn(Icons.share, 'SHARE', () { showSnackBar(context, 'SHARE'); }) ]); }), ), Container( padding: const EdgeInsets.all(10.0), child: Text( 'Lake Oeschinen lies at the foot of the Blüemlisalp in the Bernese Alps. Situated 1,578 meters above sea level, it is one of the larger Alpine Lakes. A gondola ride from Kandersteg, followed by a half-hour walk through pastures and pine forest, leads you to the lake, which warms to 20 degrees Celsius in the summer. Activities enjoyed here include rowing, and riding the summer toboggan run. Lake Oeschinen lies at the foot of the Blüemlisalp in the Bernese Alps. Situated 1,578 meters above sea level, it is one of the larger Alpine Lakes. A gondola ride from Kandersteg, followed by a half-hour walk through pastures and pine forest, leads you to the lake, which warms to 20 degrees Celsius in the summer. Activities enjoyed here include rowing, and riding the summer toboggan run. Lake Oeschinen lies at the foot of the Blüemlisalp in the Bernese Alps. Situated 1,578 meters above sea level, it is one of the larger Alpine Lakes. A gondola ride from Kandersteg, followed by a half-hour walk through pastures and pine forest, leads you to the lake, which warms to 20 degrees Celsius in the summer. Activities enjoyed here include rowing, and riding the summer toboggan run. Lake Oeschinen lies at the foot of the Blüemlisalp in the Bernese Alps. Situated 1,578 meters above sea level, it is one of the larger Alpine Lakes. A gondola ride from Kandersteg, followed by a half-hour walk through pastures and pine forest, leads you to the lake, which warms to 20 degrees Celsius in the summer. Activities enjoyed here include rowing, and riding the summer toboggan run. Lake Oeschinen lies at the foot of the Blüemlisalp in the Bernese Alps. Situated 1,578 meters above sea level, it is one of the larger Alpine Lakes. A gondola ride from Kandersteg, followed by a half-hour walk through pastures and pine forest, leads you to the lake, which warms to 20 degrees Celsius in the summer. Activities enjoyed here include rowing, and riding the summer toboggan run. Lake Oeschinen lies at the foot of the Blüemlisalp in the Bernese Alps. Situated 1,578 meters above sea level, it is one of the larger Alpine Lakes. A gondola ride from Kandersteg, followed by a half-hour walk through pastures and pine forest, leads you to the lake, which warms to 20 degrees Celsius in the summer. Activities enjoyed here include rowing, and riding the summer toboggan run. Lake Oeschinen lies at the foot of the Blüemlisalp in the Bernese Alps. Situated 1,578 meters above sea level, it is one of the larger Alpine Lakes. A gondola ride from Kandersteg, followed by a half-hour walk through pastures and pine forest, leads you to the lake, which warms to 20 degrees Celsius in the summer. Activities enjoyed here include rowing, and riding the summer toboggan run. Lake Oeschinen lies at the foot of the Blüemlisalp in the Bernese Alps. Situated 1,578 meters above sea level, it is one of the larger Alpine Lakes. A gondola ride from Kandersteg, followed by a half-hour walk through pastures and pine forest, leads you to the lake, which warms to 20 degrees Celsius in the summer. Activities enjoyed here include rowing, and riding the summer toboggan run.' + 'Lake Oeschinen lies at the foot of the Blüemlisalp in the Bernese Alps. Situated 1,578 meters above sea level, it is one of the larger Alpine Lakes. A gondola ride from Kandersteg, followed by a half-hour walk through pastures and pine forest, leads you to the lake, which warms to 20 degrees Celsius in the summer. Activities enjoyed here include rowing, and riding the summer toboggan run.', textAlign: TextAlign.justify, softWrap: true), ) ]))); }, )), )); } } /// This method used to show the SnackBar void showSnackBar(BuildContext context, String buttonName) { Scaffold.of(context).showSnackBar( new SnackBar(content: new Text('$buttonName button clicked!'))); } class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { new FutureBuilder( future: CelebrityInfo.fetchCelebritiesDetails(), builder: (context, celebs) { debugPrint('test FutureBuilder $celebs'); return new Container(); }); return new MaterialApp( title: "My First Flutter", theme: new ThemeData(primarySwatch: Colors.brown), home: new Scaffold( backgroundColor: Colors.white30, appBar: new AppBar(title: new Text("Hello Flutter!")), body: new FutureBuilder<List<CelebrityInfo>>( future: CelebrityInfo.fetchCelebritiesDetails(), builder: (context, celebs) { return new ListView.builder( itemCount: celebs.data.length, itemBuilder: (context, index) => new CelebrityWidget( info: celebs.data[index], isVisible: true)); }))); } }
0
mirrored_repositories/Flutter-Sample-For-Beginner
mirrored_repositories/Flutter-Sample-For-Beginner/lib/CelebrityItem.dart
import 'package:flutter/material.dart'; import 'package:flutter_app/model/CelebrityInfo.dart'; import 'package:flutter_app/CelebrityDetailScreen.dart'; import 'package:flutter_app/ScrollingImageDetailer.dart'; // ignore: must_be_immutable class CelebrityWidget extends StatelessWidget { CelebrityInfo info; bool isVisible; CelebrityWidget({Key key, this.info, this.isVisible}) : super(key: key); @override Widget build(BuildContext context) { debugPrint('@@@@@@' + info.name); return new Card( color: Theme.of(context).primaryColorLight, elevation: 5.0, child: new Column( mainAxisAlignment: MainAxisAlignment.center, mainAxisSize: MainAxisSize.max, children: <Widget>[ new Padding( padding: const EdgeInsets.all(10.0), child: new Column(children: <Widget>[ new Text(info.name, style: new TextStyle(color: Colors.green, fontSize: 25.0)), new Text(info.company, style: new TextStyle(color: Colors.deepOrange)), new Text(info.country, style: new TextStyle(color: Colors.blue)), new Image.network(info.url), new Container( decoration: new BoxDecoration(color: Colors.lightGreenAccent), margin: const EdgeInsets.only(top: 15.0, bottom: 5.0), child: new Text(getCurrentDateTimeNow(info.dateTime), style: new TextStyle( fontWeight: FontWeight.w900, // The most thick color: Colors.redAccent), textAlign: TextAlign.justify)), new Padding( padding: const EdgeInsets.all(5.0), child: new Container( decoration: new BoxDecoration( color: Colors.black12, shape: BoxShape.circle), child: isVisible ? new IconButton( iconSize: 48.0, highlightColor: Colors.green, icon: new Icon(Icons.navigate_next), color: Colors.deepOrange, splashColor: Colors.brown, tooltip: 'Refresh', onPressed: () { // showSnackBar(context); Navigator.push( context, new MaterialPageRoute( builder: (context) => new CelebrityDetailScreen( info: info, onPressed: () { Navigator.push( context, new MaterialPageRoute( builder: (context) => new ScrollingImageDetailer())); // Navigator.pop(context); }))); }) : new Container()///Empty container if isVisible flag false ), ) ])) ])); } // onPressed: () { // Navigator.pop(context); // } /// It gives current Date and Time String getCurrentDateTimeNow(int millisecondsSinceEpoch) { // var now = new DateTime.now(); var now = new DateTime.fromMillisecondsSinceEpoch(millisecondsSinceEpoch); debugPrint('CurrentDateTimeNow: $now'); String value = now.day.toString() + "/" + now.month.toString() + "/" + now.year.toString(); return value; } /// This method used to show the SnackBar void showSnackBar(BuildContext context) { Scaffold.of(context).showSnackBar( new SnackBar(content: new Text('Refresh button clicked!'))); } }
0
mirrored_repositories/Flutter-Sample-For-Beginner/lib
mirrored_repositories/Flutter-Sample-For-Beginner/lib/model/CelebrityInfo.dart
import 'package:flutter/material.dart'; import 'dart:convert'; import 'dart:async' show Future; import 'package:flutter/services.dart' show rootBundle; class CelebrityInfo { String name; String company; String country; String url; int dateTime; CelebrityInfo( {this.name, this.company, this.country, this.url, this.dateTime}); factory CelebrityInfo.fromJson(Map<String, dynamic> jsonResponse) { return new CelebrityInfo( name: jsonResponse['name'] as String, company: jsonResponse['company'] as String, country: jsonResponse['country'] as String, url: jsonResponse['url'] as String, dateTime: jsonResponse['dateTime'] as int); } static Future<List<CelebrityInfo>> fetchCelebritiesDetails() async { String resp = await loadAsset(); // final jsonResponse = jsonDecode(resp); debugPrint('CelebrityInfo.fromJsonResponse resp: $resp'); Map<String, dynamic> decoded = json.decode(resp); // debugPrint('decoded value is $decoded'); List<CelebrityInfo> celebs = new List<CelebrityInfo>(); for (var celeb in decoded['celebrities']) { CelebrityInfo info = new CelebrityInfo( name: celeb['name'] as String, company: celeb['company'] as String, country: celeb['country'] as String, url: celeb['url'] as String, dateTime: celeb['dateTime'] as int); celebs.add(info); } return celebs; } static Future<String> loadAsset() async { return await rootBundle .loadString("lib/sample_response/celebrity_mock_response.json"); } factory CelebrityInfo.fromJsonResponse(BuildContext context) { new FutureBuilder( future: DefaultAssetBundle.of(context) .loadString('lib/sample_response/celebrity_mock_response.json'), builder: (context, celebrityInfo) { var data = json.encode(celebrityInfo.data.toString()); var dataLength = data.length; debugPrint('CelebrityInfo.fromJsonResponse data: $data'); debugPrint('CelebrityInfo.fromJsonResponse data_length: $dataLength'); debugPrint( 'CelebrityInfo.fromJsonResponse loadAsset(): $loadAsset()'); return new Container(); }); return null; // return new CelebrityInfo( // name: jsonResponse['name'] as String, // company: jsonResponse['company'] as String, // country: jsonResponse['country'] as String, // url: jsonResponse['url'] as String, // dateTime: jsonResponse['dateTime'] as int); } }
0
mirrored_repositories/Flutter-Sample-For-Beginner
mirrored_repositories/Flutter-Sample-For-Beginner/test/widget_test.dart
// This is a basic Flutter widget test. // To perform an interaction with a widget in your test, use the WidgetTester utility that Flutter // provides. For example, you can send tap and scroll gestures. You can also use WidgetTester to // find child widgets in the widget tree, read text, and verify that the values of widget properties // are correct. import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_app/main.dart'; void main() { testWidgets('Counter increments smoke test', (WidgetTester tester) async { // Build our app and trigger a frame. await tester.pumpWidget(new MyApp()); // Verify that our counter starts at 0. expect(find.text('0'), findsOneWidget); expect(find.text('1'), findsNothing); // Tap the '+' icon and trigger a frame. await tester.tap(find.byIcon(Icons.add)); await tester.pump(); // Verify that our counter has incremented. expect(find.text('0'), findsNothing); expect(find.text('1'), findsOneWidget); }); }
0
mirrored_repositories/usemap-flutter
mirrored_repositories/usemap-flutter/lib/main.dart
import 'package:flutter/material.dart'; void main() { runApp(const MyApp()); } class MyApp extends StatelessWidget { const MyApp({Key? key}) : super(key: key); // This widget is the root of your application. @override Widget build(BuildContext context) { return MaterialApp( title: 'MapUp', theme: ThemeData( // This is the theme of your application. // // Try running your application with "flutter run". You'll see the // application has a blue toolbar. Then, without quitting the app, try // changing the primarySwatch below to Colors.green and then invoke // "hot reload" (press "r" in the console where you ran "flutter run", // or simply save your changes to "hot reload" in a Flutter IDE). // Notice that the counter didn't reset back to zero; the application // is not restarted. primarySwatch: Colors.blue, ), home: const MyHomePage(title: 'MapUp'), ); } } class MyHomePage extends StatefulWidget { const MyHomePage({Key? key, required this.title}) : super(key: key); // This widget is the home page of your application. It is stateful, meaning // that it has a State object (defined below) that contains fields that affect // how it looks. // This class is the configuration for the state. It holds the values (in this // case the title) provided by the parent (in this case the App widget) and // used by the build method of the State. Fields in a Widget subclass are // always marked "final". final String title; @override State<MyHomePage> createState() => _MyHomePageState(); } class _MyHomePageState extends State<MyHomePage> { int _counter = 0; void _incrementCounter() { setState(() { // This call to setState tells the Flutter framework that something has // changed in this State, which causes it to rerun the build method below // so that the display can reflect the updated values. If we changed // _counter without calling setState(), then the build method would not be // called again, and so nothing would appear to happen. _counter++; }); } @override Widget build(BuildContext context) { // This method is rerun every time setState is called, for instance as done // by the _incrementCounter method above. // // The Flutter framework has been optimized to make rerunning build methods // fast, so that you can just rebuild anything that needs updating rather // than having to individually change instances of widgets. return Scaffold( appBar: AppBar( // Here we take the value from the MyHomePage object that was created by // the App.build method, and use it to set our appbar title. title: Text(widget.title), ), body: Center( // Center is a layout widget. It takes a single child and positions it // in the middle of the parent. child: Column( // Column is also a layout widget. It takes a list of children and // arranges them vertically. By default, it sizes itself to fit its // children horizontally, and tries to be as tall as its parent. // // Invoke "debug painting" (press "p" in the console, choose the // "Toggle Debug Paint" action from the Flutter Inspector in Android // Studio, or the "Toggle Debug Paint" command in Visual Studio Code) // to see the wireframe for each widget. // // Column has various properties to control how it sizes itself and // how it positions its children. Here we use mainAxisAlignment to // center the children vertically; the main axis here is the vertical // axis because Columns are vertical (the cross axis would be // horizontal). mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ const Text( 'You have pushed the button this many times:', ), Text( '$_counter', style: Theme.of(context).textTheme.headline4, ), ], ), ), floatingActionButton: FloatingActionButton( onPressed: _incrementCounter, tooltip: 'Increment', child: const Icon(Icons.add), ), // This trailing comma makes auto-formatting nicer for build methods. ); } }
0
mirrored_repositories/usemap-flutter
mirrored_repositories/usemap-flutter/test/widget_test.dart
// This is a basic Flutter widget test. // // To perform an interaction with a widget in your test, use the WidgetTester // utility in the flutter_test package. For example, you can send tap and scroll // gestures. You can also use WidgetTester to find child widgets in the widget // tree, read text, and verify that the values of widget properties are correct. import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:mapup/main.dart'; void main() { testWidgets('Counter increments smoke test', (WidgetTester tester) async { // Build our app and trigger a frame. await tester.pumpWidget(const MyApp()); // Verify that our counter starts at 0. expect(find.text('0'), findsOneWidget); expect(find.text('1'), findsNothing); // Tap the '+' icon and trigger a frame. await tester.tap(find.byIcon(Icons.add)); await tester.pump(); // Verify that our counter has incremented. expect(find.text('0'), findsNothing); expect(find.text('1'), findsOneWidget); }); }
0
mirrored_repositories/flutter_auto_route_example
mirrored_repositories/flutter_auto_route_example/lib/second_page.dart
import 'package:auto_route/auto_route.dart'; import 'package:flutter/material.dart'; @RoutePage(name: "SecondPage") class SecondPage extends StatefulWidget { const SecondPage({super.key}); @override SecondPageState createState() => SecondPageState(); } class SecondPageState extends State<SecondPage> { @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: const Text("Second Page"), ), body: const Center( child: Text( "Welcome To Second Page", style: TextStyle( fontWeight: FontWeight.bold, color: Colors.orange, fontSize: 24), )), ); } }
0
mirrored_repositories/flutter_auto_route_example
mirrored_repositories/flutter_auto_route_example/lib/third_page.dart
import 'package:auto_route/auto_route.dart'; import 'package:flutter/material.dart'; @RoutePage(name: "ThirdPage") class ThirdPage extends StatefulWidget { final String text; const ThirdPage({super.key, required this.text}); @override ThirdPageState createState() => ThirdPageState(); } class ThirdPageState extends State<ThirdPage> { @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: const Text("Third Page"), ), body: Center( child: Text( widget.text, style: const TextStyle( fontWeight: FontWeight.bold, color: Colors.orange, fontSize: 24), )), ); } }
0
mirrored_repositories/flutter_auto_route_example
mirrored_repositories/flutter_auto_route_example/lib/main.dart
import 'package:auto_route/auto_route.dart'; import 'package:auto_routing_eg/routes/routes.dart'; import 'package:auto_routing_eg/routes/routes.gr.dart'; // import 'package:auto_routing_eg/routes/routes.gr.dart' as ro; import 'package:flutter/material.dart'; void main(List<String> args) { WidgetsFlutterBinding.ensureInitialized(); runApp( MaterialApp.router( routerConfig: AppRouter().config(), ), ); } @RoutePage(name: "MyApp") class MyApp extends StatefulWidget { const MyApp({super.key}); @override MyAppState createState() => MyAppState(); } class MyAppState extends State<MyApp> { @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: const Text("Main Page"), ), body: Center( child: Column( mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ ElevatedButton( onPressed: () { AutoRouter.of(context).replace(const SecondPage()); }, child: const Text("Second Page")), ElevatedButton( onPressed: () { AutoRouter.of(context).push(ThirdPage(text: "Hello da Raj")); }, child: const Text("Third Page")), ], ), ), ); } }
0
mirrored_repositories/flutter_auto_route_example/lib
mirrored_repositories/flutter_auto_route_example/lib/routes/routes.dart
import 'package:auto_route/auto_route.dart'; import 'routes.gr.dart'; @AutoRouterConfig(replaceInRouteName: 'Screen,Route') class AppRouter extends $AppRouter { @override RouteType get defaultRouteType => const RouteType.material(); @override List<AutoRoute> get routes => [ MaterialRoute(page: const PageInfo('MyApp'), initial: true), MaterialRoute( page: const PageInfo('SecondPage'), fullscreenDialog: true, ), CustomRoute( page: const PageInfo('ThirdPage'), transitionsBuilder: TransitionsBuilders.slideLeftWithFade), /// routes go here ]; }
0
mirrored_repositories/flutter_auto_route_example/lib
mirrored_repositories/flutter_auto_route_example/lib/routes/routes.gr.dart
// GENERATED CODE - DO NOT MODIFY BY HAND // ************************************************************************** // AutoRouterGenerator // ************************************************************************** // ignore_for_file: type=lint // coverage:ignore-file // ignore_for_file: no_leading_underscores_for_library_prefixes import 'package:auto_route/auto_route.dart' as _i4; import 'package:auto_routing_eg/main.dart' as _i1; import 'package:auto_routing_eg/second_page.dart' as _i2; import 'package:auto_routing_eg/third_page.dart' as _i3; import 'package:flutter/material.dart' as _i5; abstract class $AppRouter extends _i4.RootStackRouter { $AppRouter({super.navigatorKey}); @override final Map<String, _i4.PageFactory> pagesMap = { MyApp.name: (routeData) { return _i4.AutoRoutePage<dynamic>( routeData: routeData, child: const _i1.MyApp(), ); }, SecondPage.name: (routeData) { return _i4.AutoRoutePage<dynamic>( routeData: routeData, child: const _i2.SecondPage(), ); }, ThirdPage.name: (routeData) { final args = routeData.argsAs<ThirdPageArgs>(); return _i4.AutoRoutePage<dynamic>( routeData: routeData, child: _i3.ThirdPage( key: args.key, text: args.text, ), ); }, }; } /// generated route for /// [_i1.MyApp] class MyApp extends _i4.PageRouteInfo<void> { const MyApp({List<_i4.PageRouteInfo>? children}) : super( MyApp.name, initialChildren: children, ); static const String name = 'MyApp'; static const _i4.PageInfo<void> page = _i4.PageInfo<void>(name); } /// generated route for /// [_i2.SecondPage] class SecondPage extends _i4.PageRouteInfo<void> { const SecondPage({List<_i4.PageRouteInfo>? children}) : super( SecondPage.name, initialChildren: children, ); static const String name = 'SecondPage'; static const _i4.PageInfo<void> page = _i4.PageInfo<void>(name); } /// generated route for /// [_i3.ThirdPage] class ThirdPage extends _i4.PageRouteInfo<ThirdPageArgs> { ThirdPage({ _i5.Key? key, required String text, List<_i4.PageRouteInfo>? children, }) : super( ThirdPage.name, args: ThirdPageArgs( key: key, text: text, ), initialChildren: children, ); static const String name = 'ThirdPage'; static const _i4.PageInfo<ThirdPageArgs> page = _i4.PageInfo<ThirdPageArgs>(name); } class ThirdPageArgs { const ThirdPageArgs({ this.key, required this.text, }); final _i5.Key? key; final String text; @override String toString() { return 'ThirdPageArgs{key: $key, text: $text}'; } }
0
mirrored_repositories/MetaFlutter
mirrored_repositories/MetaFlutter/lib/main.dart
import 'package:flutter/material.dart'; import 'package:flutter_app_builder/pages/splash_screen.dart'; void main() => runApp(MyApp()); class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( title: 'MetaFlutter', theme: ThemeData( primarySwatch: Colors.blue, accentColor: Colors.blueAccent, scaffoldBackgroundColor: Colors.white, ), home: SplashScreen(), debugShowCheckedModeBanner: false, ); } }
0
mirrored_repositories/MetaFlutter/lib
mirrored_repositories/MetaFlutter/lib/widget_builder_utilities/property.dart
import 'package:flutter/material.dart'; import 'package:flutter_app_builder/pages/add_property_widget_dialog.dart'; import 'package:flutter_app_builder/widget_builder_utilities/property_helpers/font_style_helper.dart'; import 'package:flutter_app_builder/widget_builder_utilities/property_helpers/scroll_physics_helper.dart'; import 'model_widget.dart'; import 'property_helpers/icons_helper.dart'; import 'property_helpers/colors_helper.dart'; import 'property_helpers/alignment_helper.dart'; import 'package:flutter_app_builder/components/selecting_text_editing_controller.dart'; /// Types of properties of a widget enum PropertyType { icon, double, integer, string, mainAxisAlignment, crossAxisAlignment, widget, color, alignment, boxFit, boolean, scrollPhysics, axis, fontStyle } /// The property widget displays an input widget for a certain type of property /// For the [PropertyType.widget], it displays a button which allows the user to create a separate widget class Property extends StatefulWidget { final PropertyType type; final ValueChanged onValueChanged; final currentValue; final WidgetType widgetType; Property(this.type, this.onValueChanged, {this.currentValue, this.widgetType}); @override _PropertyState createState() => _PropertyState(); } class _PropertyState extends State<Property> { @override Widget build(BuildContext context) { switch (widget.type) { case PropertyType.icon: return CustomDropdownButton( items: icons.map((data) { return DropdownMenuItem( child: Text(data.name), value: data.iconData, ); }).toList(), onChanged: (value) { widget.onValueChanged(value); }, value: widget.currentValue, ); break; case PropertyType.fontStyle: return CustomDropdownButton( items: font.map((data) { return DropdownMenuItem( child: Text(data.name), value: data.fontStyle, ); }).toList(), onChanged: (value) { widget.onValueChanged(value); }, value: widget.currentValue, ); case PropertyType.double: return TextField( decoration: InputDecoration( border: OutlineInputBorder(), labelText: "Enter a decimal number", ), controller: SelectingTextEditingController( text: widget.currentValue.toString()), onChanged: widget.onValueChanged, keyboardType: TextInputType.numberWithOptions(signed: true, decimal: true), ); break; case PropertyType.integer: return TextField( decoration: InputDecoration( border: OutlineInputBorder(), labelText: "Enter an integer"), onChanged: widget.onValueChanged, controller: SelectingTextEditingController( text: widget.currentValue.toString()), keyboardType: TextInputType.numberWithOptions(signed: true, decimal: false), ); break; case PropertyType.string: return TextField( decoration: InputDecoration( border: OutlineInputBorder(), labelText: "Enter a string"), controller: SelectingTextEditingController( text: widget.currentValue.toString()), onChanged: widget.onValueChanged, ); break; case PropertyType.mainAxisAlignment: return CustomDropdownButton( items: MainAxisAlignment.values.map( (value) { return DropdownMenuItem( child: Text(value.toString().split(".")[1]), value: value, ); }, ).toList(), onChanged: widget.onValueChanged, value: widget.currentValue, ); break; case PropertyType.crossAxisAlignment: return CustomDropdownButton( items: CrossAxisAlignment.values.map( (value) { return DropdownMenuItem( child: Text(value.toString().split(".")[1]), value: value, ); }, ).toList(), onChanged: widget.onValueChanged, value: widget.currentValue, ); break; case PropertyType.widget: return FlatButton( onPressed: () async { ModelWidget newWidget = await Navigator.of(context) .push(new MaterialPageRoute<ModelWidget>( builder: (BuildContext context) { return new AddPropertyWidgetDialog( widget: getNewModelFromType(widget.widgetType), ); }, fullscreenDialog: true)); widget.onValueChanged(newWidget); }, child: Text("Edit property"), ); break; case PropertyType.color: return CustomDropdownButton( items: colors.map( (value) { return DropdownMenuItem( child: Text(value.name), value: value.color, ); }, ).toList(), onChanged: widget.onValueChanged, value: widget.currentValue, ); break; case PropertyType.alignment: return CustomDropdownButton( items: alignments.map( (value) { return DropdownMenuItem( child: Text(value.name), value: value.alignment, ); }, ).toList(), onChanged: widget.onValueChanged, value: widget.currentValue, ); break; case PropertyType.boxFit: return CustomDropdownButton( items: BoxFit.values.map( (value) { return DropdownMenuItem( child: Text(value.toString()), value: value, ); }, ).toList(), onChanged: widget.onValueChanged, value: widget.currentValue, ); break; case PropertyType.boolean: return CustomDropdownButton( items: [true, false].map( (value) { return DropdownMenuItem( child: Text(value.toString()), value: value, ); }, ).toList(), onChanged: widget.onValueChanged, value: widget.currentValue, ); break; case PropertyType.scrollPhysics: return CustomDropdownButton( items: scrollPhysicsTypes.map( (ScrollPhysicsInfo value) { return DropdownMenuItem( child: Text(value.name), value: value.physics, ); }, ).toList(), onChanged: widget.onValueChanged, value: widget.currentValue, ); break; case PropertyType.axis: return CustomDropdownButton( items: [Axis.horizontal, Axis.vertical].map( (value) { return DropdownMenuItem( child: Text(value.toString()), value: value, ); }, ).toList(), onChanged: widget.onValueChanged, value: widget.currentValue, ); break; default: return null; } } } /// Creates a custom [DropdownButton] with borders to display in [Property] inputs class CustomDropdownButton extends StatelessWidget { final List<DropdownMenuItem> items; final Function onChanged; final value; const CustomDropdownButton({Key key, this.items, this.onChanged, this.value}) : super(key: key); @override Widget build(BuildContext context) { return DropdownButtonHideUnderline( child: Container( decoration: BoxDecoration( border: Border.all( color: Colors.black45, ), borderRadius: BorderRadius.circular(4.0)), child: Padding( padding: const EdgeInsets.symmetric(horizontal: 2.0), child: DropdownButton( items: items, onChanged: onChanged, value: value, isExpanded: true, hint: Text("Select Value"), ), ), ), ); } }
0
mirrored_repositories/MetaFlutter/lib
mirrored_repositories/MetaFlutter/lib/widget_builder_utilities/model_widget.dart
import 'package:flutter/material.dart'; import 'package:flutter_app_builder/widget_builder_utilities/widgets/align_model.dart'; import 'package:flutter_app_builder/widget_builder_utilities/widgets/aspect_ratio_model.dart'; import 'package:flutter_app_builder/widget_builder_utilities/widgets/center_model.dart'; import 'package:flutter_app_builder/widget_builder_utilities/widgets/column_model.dart'; import 'package:flutter_app_builder/widget_builder_utilities/widgets/container_model.dart'; import 'package:flutter_app_builder/widget_builder_utilities/widgets/expanded_model.dart'; import 'package:flutter_app_builder/widget_builder_utilities/widgets/fitted_box_model.dart'; import 'package:flutter_app_builder/widget_builder_utilities/widgets/flat_button_model.dart'; import 'package:flutter_app_builder/widget_builder_utilities/widgets/flutter_logo_model.dart'; import 'package:flutter_app_builder/widget_builder_utilities/widgets/grid_view_model.dart'; import 'package:flutter_app_builder/widget_builder_utilities/widgets/icon_model.dart'; import 'package:flutter_app_builder/widget_builder_utilities/widgets/list_view_model.dart'; import 'package:flutter_app_builder/widget_builder_utilities/widgets/padding_model.dart'; import 'package:flutter_app_builder/widget_builder_utilities/widgets/page_view_model.dart'; import 'package:flutter_app_builder/widget_builder_utilities/widgets/raised_button_model.dart'; import 'package:flutter_app_builder/widget_builder_utilities/widgets/row_model.dart'; import 'package:flutter_app_builder/widget_builder_utilities/widgets/safe_area_model.dart'; import 'package:flutter_app_builder/widget_builder_utilities/widgets/stack_model.dart'; import 'package:flutter_app_builder/widget_builder_utilities/widgets/text_model.dart'; import 'package:flutter_app_builder/widget_builder_utilities/widgets/text_field_model.dart'; import 'package:flutter_app_builder/widget_builder_utilities/widgets/transform_rotate_model.dart'; import 'package:flutter_app_builder/widget_builder_utilities/widgets/transform_scale_model.dart'; import 'package:flutter_app_builder/widget_builder_utilities/widgets/transform_translate_model.dart'; import 'package:flutter_app_builder/widget_builder_utilities/widgets/card_view_model.dart'; /// Denotes the type of widget enum WidgetType { Text, Center, Column, Icon, Container, Expanded, Align, Padding, FittedBox, TextField, Row, SafeArea, FlatButton, RaisedButton, FlutterLogo, Stack, ListView, GridView, AspectRatio, TransformRotate, TransformTranslate, TransformScale, PageView, CardView } /// Denotes if the widget can have zero, one or multiple children enum NodeType { SingleChild, MultipleChildren, End, } /// Creates a new model for each [WidgetType] ModelWidget getNewModelFromType(WidgetType type) { switch (type) { case WidgetType.Text: return TextModel(); break; case WidgetType.Center: return CenterModel(); break; case WidgetType.Column: return ColumnModel(); break; case WidgetType.Icon: return IconModel(); break; case WidgetType.Container: return ContainerModel(); break; case WidgetType.Expanded: return ExpandedModel(); break; case WidgetType.Align: return AlignModel(); break; case WidgetType.Padding: return PaddingModel(); break; case WidgetType.FittedBox: return FittedBoxModel(); break; case WidgetType.TextField: return TextFieldModel(); break; case WidgetType.Row: return RowModel(); break; case WidgetType.SafeArea: return SafeAreaModel(); break; case WidgetType.FlatButton: return FlatButtonModel(); break; case WidgetType.RaisedButton: return RaisedButtonModel(); break; case WidgetType.FlutterLogo: return FlutterLogoModel(); break; case WidgetType.Stack: return StackModel(); break; case WidgetType.ListView: return ListViewModel(); break; case WidgetType.GridView: return GridViewModel(); break; case WidgetType.AspectRatio: return AspectRatioModel(); break; case WidgetType.TransformRotate: return TransformRotateModel(); break; case WidgetType.TransformScale: return TransformScaleModel(); break; case WidgetType.TransformTranslate: return TransformTranslateModel(); break; case WidgetType.PageView: return PageViewModel(); break; case WidgetType.CardView: return CardViewModel(); break; default: return null; break; } } /// Model Widget class abstract class ModelWidget { /// Type of widget ([Text], [Center], [Column], etc) WidgetType widgetType; /// Children of the widget Map<int, ModelWidget> children = {}; /// The parent of the current widget ModelWidget parent; /// How the widget fits into the tree /// [NodeType.End] is used for widgets that cannot have children /// [NodeType.SingleChild] and [NodeType.MultipleChildren] are self-explanatory NodeType nodeType; /// Stores the names of all parameters and input types Map paramNameAndTypes = {}; /// The parameter values of the widget /// Key is the parameter name and value is the value Map params = {}; /// Denotes if the widget has any properties bool hasProperties; /// Denotes if the widget has any children bool hasChildren; /// This method takes the parameters and returns the actual widget to display Widget toWidget(); /// Add child if widget takes children and space is available and return true, else return false bool addChild(ModelWidget widget) { if (nodeType == NodeType.SingleChild) { children[0] = widget; return true; } else if (nodeType == NodeType.MultipleChildren) { children[children.length] = widget; return true; } return false; } /// Get current values of all parameters of the widget model Map getParamValuesMap(); /// Converts current widget to code and returns as string String toCode(); }
0
mirrored_repositories/MetaFlutter/lib/widget_builder_utilities
mirrored_repositories/MetaFlutter/lib/widget_builder_utilities/property_helpers/font_style_helper.dart
import 'package:flutter/material.dart'; var font = [ FontInfo("Normal", FontStyle.normal), FontInfo("Italic", FontStyle.italic) ]; class FontInfo { String name; FontStyle fontStyle; FontInfo(this.name, this.fontStyle); }
0
mirrored_repositories/MetaFlutter/lib/widget_builder_utilities
mirrored_repositories/MetaFlutter/lib/widget_builder_utilities/property_helpers/alignment_helper.dart
import 'package:flutter/material.dart'; /// Provides alignments for selection of property var alignments = [ AlignmentInfo("topLeft", Alignment.topLeft), AlignmentInfo("topCenter", Alignment.topCenter), AlignmentInfo("topRight", Alignment.topRight), AlignmentInfo("centerLeft", Alignment.centerLeft), AlignmentInfo("center", Alignment.center), AlignmentInfo("centerRight", Alignment.centerRight), AlignmentInfo("bottomLeft", Alignment.bottomLeft), AlignmentInfo("bottomCenter", Alignment.bottomCenter), AlignmentInfo("bottomRight", Alignment.bottomRight), ]; class AlignmentInfo { String name; Alignment alignment; AlignmentInfo(this.name, this.alignment); }
0
mirrored_repositories/MetaFlutter/lib/widget_builder_utilities
mirrored_repositories/MetaFlutter/lib/widget_builder_utilities/property_helpers/colors_helper.dart
import 'package:flutter/material.dart'; /// Provides colors for selection of property var colors = [ ColorInfo("black", Colors.black, Colors.black.toString()), ColorInfo("red", Colors.red, Colors.red[500].toString()), ColorInfo("green", Colors.green, Colors.green[500].toString()), ColorInfo("blue", Colors.blue, Colors.blue[500].toString()), ColorInfo("yellow", Colors.yellow, Colors.yellow[500].toString()), ColorInfo("purple", Colors.purple, Colors.purple[500].toString()), ColorInfo("amber", Colors.amber, Colors.amber[500].toString()), ColorInfo("cyan", Colors.cyan, Colors.cyan[500].toString()), ColorInfo("grey", Colors.grey, Colors.grey[500].toString()), ColorInfo("teal", Colors.teal, Colors.teal[500].toString()), ColorInfo("pink", Colors.pink, Colors.pink[500].toString()), ColorInfo("orange", Colors.orange, Colors.orange[500].toString()), ColorInfo("white", Colors.white, Colors.white.toString()), ColorInfo("transparent", Colors.transparent, Colors.transparent.toString()), ]; class ColorInfo { String name; Color color; String hex; ColorInfo(this.name, this.color, this.hex); } String getName(Color color) { ColorInfo info = colors.firstWhere((element) { return element.color == color; }); return "Colors.${info.name}"; }
0
mirrored_repositories/MetaFlutter/lib/widget_builder_utilities
mirrored_repositories/MetaFlutter/lib/widget_builder_utilities/property_helpers/scroll_physics_helper.dart
import 'package:flutter/material.dart'; /// Provides ScrollPhysics for selection of property List<ScrollPhysicsInfo> scrollPhysicsTypes = [ ScrollPhysicsInfo( "AlwaysScrollableScrollPhysics", AlwaysScrollableScrollPhysics()), ScrollPhysicsInfo( "NeverScrollableScrollPhysics", NeverScrollableScrollPhysics()), ScrollPhysicsInfo("BouncingScrollPhysics", BouncingScrollPhysics()), ScrollPhysicsInfo("ClampingScrollPhysics", ClampingScrollPhysics()), ScrollPhysicsInfo("FixedExtentScrollPhysics", FixedExtentScrollPhysics()), ]; class ScrollPhysicsInfo { String name; ScrollPhysics physics; ScrollPhysicsInfo(this.name, this.physics); }
0
mirrored_repositories/MetaFlutter/lib/widget_builder_utilities
mirrored_repositories/MetaFlutter/lib/widget_builder_utilities/property_helpers/icons_helper.dart
import 'package:flutter/material.dart'; /// Provides icons for selection of property var icons = [ IconInfo("threesixty", Icons.threesixty), IconInfo("four_k", Icons.four_k), IconInfo("access_alarm", Icons.access_alarm), IconInfo("access_time", Icons.access_time), IconInfo("accessibility_new", Icons.accessibility_new), IconInfo("accessible_forward", Icons.accessible_forward), IconInfo("account_balance_wallet", Icons.account_balance_wallet), IconInfo("account_circle", Icons.account_circle), IconInfo("add", Icons.add), IconInfo("add_alarm", Icons.add_alarm), IconInfo("add_box", Icons.add_box), IconInfo("add_circle", Icons.add_circle), IconInfo("add_comment", Icons.add_comment), IconInfo("add_photo_alternate", Icons.add_photo_alternate), IconInfo("add_to_home_screen", Icons.add_to_home_screen), IconInfo("add_to_queue", Icons.add_to_queue), IconInfo("airline_seat_flat", Icons.airline_seat_flat), IconInfo( "airline_seat_individual_suite", Icons.airline_seat_individual_suite), IconInfo("airline_seat_legroom_normal", Icons.airline_seat_legroom_normal), IconInfo("airline_seat_recline_extra", Icons.airline_seat_recline_extra), IconInfo("airplanemode_active", Icons.airplanemode_active), IconInfo("airplay", Icons.airplay), IconInfo("alarm", Icons.alarm), IconInfo("alarm_off", Icons.alarm_off), IconInfo("album", Icons.album), IconInfo("all_out", Icons.all_out), IconInfo("android", Icons.android), IconInfo("apps", Icons.apps), IconInfo("arrow_back", Icons.arrow_back), IconInfo("arrow_downward", Icons.arrow_downward), IconInfo("arrow_drop_down_circle", Icons.arrow_drop_down_circle), IconInfo("arrow_forward", Icons.arrow_forward), IconInfo("arrow_left", Icons.arrow_left), IconInfo("arrow_upward", Icons.arrow_upward), IconInfo("aspect_ratio", Icons.aspect_ratio), IconInfo("assignment", Icons.assignment), IconInfo("assignment_late", Icons.assignment_late), IconInfo("assignment_returned", Icons.assignment_returned), IconInfo("assistant", Icons.assistant), IconInfo("atm", Icons.atm), IconInfo("attach_money", Icons.attach_money), IconInfo("audiotrack", Icons.audiotrack), IconInfo("av_timer", Icons.av_timer), IconInfo("backup", Icons.backup), IconInfo("battery_charging_full", Icons.battery_charging_full), IconInfo("battery_std", Icons.battery_std), IconInfo("beach_access", Icons.beach_access), IconInfo("block", Icons.block), IconInfo("bluetooth_audio", Icons.bluetooth_audio), IconInfo("bluetooth_disabled", Icons.bluetooth_disabled), IconInfo("blur_circular", Icons.blur_circular), IconInfo("blur_off", Icons.blur_off), IconInfo("book", Icons.book), IconInfo("bookmark_border", Icons.bookmark_border), IconInfo("border_bottom", Icons.border_bottom), IconInfo("border_color", Icons.border_color), IconInfo("border_inner", Icons.border_inner), IconInfo("border_outer", Icons.border_outer), IconInfo("border_style", Icons.border_style), IconInfo("border_vertical", Icons.border_vertical), IconInfo("brightness_1", Icons.brightness_1), IconInfo("brightness_3", Icons.brightness_3), IconInfo("brightness_5", Icons.brightness_5), IconInfo("brightness_7", Icons.brightness_7), IconInfo("brightness_high", Icons.brightness_high), IconInfo("brightness_medium", Icons.brightness_medium), IconInfo("brush", Icons.brush), IconInfo("bug_report", Icons.bug_report), IconInfo("burst_mode", Icons.burst_mode), IconInfo("business_center", Icons.business_center), IconInfo("cake", Icons.cake), IconInfo("calendar_view_day", Icons.calendar_view_day), IconInfo("call_end", Icons.call_end), IconInfo("call_merge", Icons.call_merge), IconInfo("call_missed_outgoing", Icons.call_missed_outgoing), IconInfo("call_split", Icons.call_split), IconInfo("camera", Icons.camera), IconInfo("camera_enhance", Icons.camera_enhance), IconInfo("camera_rear", Icons.camera_rear), IconInfo("cancel", Icons.cancel), IconInfo("card_membership", Icons.card_membership), IconInfo("casino", Icons.casino), IconInfo("cast_connected", Icons.cast_connected), IconInfo("center_focus_strong", Icons.center_focus_strong), IconInfo("change_history", Icons.change_history), IconInfo("chat_bubble", Icons.chat_bubble), IconInfo("check", Icons.check), IconInfo("check_box_outline_blank", Icons.check_box_outline_blank), IconInfo("check_circle_outline", Icons.check_circle_outline), IconInfo("chevron_right", Icons.chevron_right), IconInfo("child_friendly", Icons.child_friendly), IconInfo("class_", Icons.class_), IconInfo("clear_all", Icons.clear_all), IconInfo("closed_caption", Icons.closed_caption), IconInfo("cloud_circle", Icons.cloud_circle), IconInfo("cloud_download", Icons.cloud_download), IconInfo("cloud_queue", Icons.cloud_queue), IconInfo("code", Icons.code), IconInfo("collections_bookmark", Icons.collections_bookmark), IconInfo("colorize", Icons.colorize), IconInfo("compare", Icons.compare), IconInfo("computer", Icons.computer), IconInfo("contact_mail", Icons.contact_mail), IconInfo("contacts", Icons.contacts), IconInfo("content_cut", Icons.content_cut), IconInfo("control_point", Icons.control_point), IconInfo("copyright", Icons.copyright), IconInfo("create_new_folder", Icons.create_new_folder), IconInfo("crop", Icons.crop), IconInfo("crop_3_2", Icons.crop_3_2), IconInfo("crop_7_5", Icons.crop_7_5), IconInfo("crop_free", Icons.crop_free), IconInfo("crop_original", Icons.crop_original), IconInfo("crop_rotate", Icons.crop_rotate), IconInfo("dashboard", Icons.dashboard), IconInfo("date_range", Icons.date_range), IconInfo("delete", Icons.delete), IconInfo("delete_outline", Icons.delete_outline), IconInfo("departure_board", Icons.departure_board), IconInfo("desktop_mac", Icons.desktop_mac), IconInfo("details", Icons.details), IconInfo("developer_mode", Icons.developer_mode), IconInfo("device_unknown", Icons.device_unknown), IconInfo("devices_other", Icons.devices_other), IconInfo("dialpad", Icons.dialpad), IconInfo("directions_bike", Icons.directions_bike), IconInfo("directions_bus", Icons.directions_bus), IconInfo("directions_railway", Icons.directions_railway), IconInfo("directions_subway", Icons.directions_subway), IconInfo("directions_walk", Icons.directions_walk), IconInfo("dns", Icons.dns), IconInfo("do_not_disturb_alt", Icons.do_not_disturb_alt), IconInfo("do_not_disturb_on", Icons.do_not_disturb_on), IconInfo("domain", Icons.domain), IconInfo("done_all", Icons.done_all), IconInfo("donut_large", Icons.donut_large), IconInfo("drafts", Icons.drafts), IconInfo("drive_eta", Icons.drive_eta), IconInfo("edit", Icons.edit), IconInfo("edit_location", Icons.edit_location), IconInfo("email", Icons.email), IconInfo("equalizer", Icons.equalizer), IconInfo("error_outline", Icons.error_outline), IconInfo("ev_station", Icons.ev_station), IconInfo("event_available", Icons.event_available), IconInfo("event_note", Icons.event_note), IconInfo("exit_to_app", Icons.exit_to_app), IconInfo("expand_more", Icons.expand_more), IconInfo("explore", Icons.explore), IconInfo("exposure_neg_1", Icons.exposure_neg_1), IconInfo("exposure_plus_1", Icons.exposure_plus_1), IconInfo("exposure_zero", Icons.exposure_zero), IconInfo("face", Icons.face), IconInfo("fast_rewind", Icons.fast_rewind), IconInfo("favorite", Icons.favorite), IconInfo("featured_play_list", Icons.featured_play_list), IconInfo("feedback", Icons.feedback), IconInfo("fiber_manual_record", Icons.fiber_manual_record), IconInfo("fiber_pin", Icons.fiber_pin), IconInfo("file_download", Icons.file_download), IconInfo("filter", Icons.filter), IconInfo("filter_2", Icons.filter_2), IconInfo("filter_4", Icons.filter_4), IconInfo("filter_6", Icons.filter_6), IconInfo("filter_8", Icons.filter_8), IconInfo("filter_9_plus", Icons.filter_9_plus), IconInfo("filter_center_focus", Icons.filter_center_focus), IconInfo("filter_frames", Icons.filter_frames), IconInfo("filter_list", Icons.filter_list), IconInfo("filter_tilt_shift", Icons.filter_tilt_shift), IconInfo("find_in_page", Icons.find_in_page), IconInfo("fingerprint", Icons.fingerprint), IconInfo("fitness_center", Icons.fitness_center), IconInfo("flare", Icons.flare), IconInfo("flash_off", Icons.flash_off), IconInfo("flight", Icons.flight), IconInfo("flight_takeoff", Icons.flight_takeoff), IconInfo("flip_to_back", Icons.flip_to_back), IconInfo("folder", Icons.folder), IconInfo("folder_shared", Icons.folder_shared), IconInfo("font_download", Icons.font_download), IconInfo("format_align_justify", Icons.format_align_justify), IconInfo("format_align_right", Icons.format_align_right), IconInfo("format_clear", Icons.format_clear), IconInfo("format_color_reset", Icons.format_color_reset), IconInfo("format_indent_decrease", Icons.format_indent_decrease), IconInfo("format_italic", Icons.format_italic), IconInfo("format_list_bulleted", Icons.format_list_bulleted), IconInfo("format_list_numbered_rtl", Icons.format_list_numbered_rtl), IconInfo("format_quote", Icons.format_quote), IconInfo("format_size", Icons.format_size), IconInfo("format_textdirection_l_to_r", Icons.format_textdirection_l_to_r), IconInfo("format_underlined", Icons.format_underlined), IconInfo("forward", Icons.forward), IconInfo("forward_30", Icons.forward_30), IconInfo("free_breakfast", Icons.free_breakfast), IconInfo("fullscreen_exit", Icons.fullscreen_exit), IconInfo("g_translate", Icons.g_translate), IconInfo("games", Icons.games), IconInfo("gesture", Icons.gesture), IconInfo("gif", Icons.gif), IconInfo("gps_fixed", Icons.gps_fixed), IconInfo("gps_off", Icons.gps_off), IconInfo("gradient", Icons.gradient), IconInfo("graphic_eq", Icons.graphic_eq), IconInfo("grid_on", Icons.grid_on), IconInfo("group_add", Icons.group_add), IconInfo("hd", Icons.hd), IconInfo("hdr_on", Icons.hdr_on), IconInfo("hdr_weak", Icons.hdr_weak), IconInfo("headset_mic", Icons.headset_mic), IconInfo("healing", Icons.healing), IconInfo("help", Icons.help), IconInfo("high_quality", Icons.high_quality), IconInfo("highlight_off", Icons.highlight_off), IconInfo("home", Icons.home), IconInfo("hotel", Icons.hotel), IconInfo("hourglass_full", Icons.hourglass_full), IconInfo("https", Icons.https), IconInfo("image_aspect_ratio", Icons.image_aspect_ratio), IconInfo("import_export", Icons.import_export), IconInfo("inbox", Icons.inbox), IconInfo("info", Icons.info), IconInfo("input", Icons.input), IconInfo("insert_comment", Icons.insert_comment), IconInfo("insert_emoticon", Icons.insert_emoticon), IconInfo("insert_link", Icons.insert_link), IconInfo("invert_colors", Icons.invert_colors), IconInfo("iso", Icons.iso), IconInfo("keyboard_arrow_down", Icons.keyboard_arrow_down), IconInfo("keyboard_arrow_right", Icons.keyboard_arrow_right), IconInfo("keyboard_backspace", Icons.keyboard_backspace), IconInfo("keyboard_hide", Icons.keyboard_hide), IconInfo("keyboard_tab", Icons.keyboard_tab), IconInfo("kitchen", Icons.kitchen), IconInfo("label_important", Icons.label_important), IconInfo("landscape", Icons.landscape), IconInfo("laptop", Icons.laptop), IconInfo("laptop_mac", Icons.laptop_mac), IconInfo("last_page", Icons.last_page), IconInfo("layers", Icons.layers), IconInfo("leak_add", Icons.leak_add), IconInfo("lens", Icons.lens), IconInfo("library_books", Icons.library_books), IconInfo("lightbulb_outline", Icons.lightbulb_outline), IconInfo("line_weight", Icons.line_weight), IconInfo("link", Icons.link), IconInfo("linked_camera", Icons.linked_camera), IconInfo("live_help", Icons.live_help), IconInfo("local_activity", Icons.local_activity), IconInfo("local_atm", Icons.local_atm), IconInfo("local_cafe", Icons.local_cafe), IconInfo("local_convenience_store", Icons.local_convenience_store), IconInfo("local_drink", Icons.local_drink), IconInfo("local_gas_station", Icons.local_gas_station), IconInfo("local_hospital", Icons.local_hospital), IconInfo("local_laundry_service", Icons.local_laundry_service), IconInfo("local_mall", Icons.local_mall), IconInfo("local_offer", Icons.local_offer), IconInfo("local_pharmacy", Icons.local_pharmacy), IconInfo("local_pizza", Icons.local_pizza), IconInfo("local_post_office", Icons.local_post_office), IconInfo("local_see", Icons.local_see), IconInfo("local_taxi", Icons.local_taxi), IconInfo("location_disabled", Icons.location_disabled), IconInfo("location_on", Icons.location_on), IconInfo("lock", Icons.lock), IconInfo("lock_outline", Icons.lock_outline), IconInfo("looks_3", Icons.looks_3), IconInfo("looks_5", Icons.looks_5), IconInfo("looks_one", Icons.looks_one), IconInfo("loop", Icons.loop), IconInfo("low_priority", Icons.low_priority), IconInfo("mail", Icons.mail), IconInfo("map", Icons.map), IconInfo("markunread_mailbox", Icons.markunread_mailbox), IconInfo("memory", Icons.memory), IconInfo("merge_type", Icons.merge_type), IconInfo("mic", Icons.mic), IconInfo("mic_off", Icons.mic_off), IconInfo("missed_video_call", Icons.missed_video_call), IconInfo("mobile_screen_share", Icons.mobile_screen_share), IconInfo("mode_edit", Icons.mode_edit), IconInfo("money_off", Icons.money_off), IconInfo("mood", Icons.mood), IconInfo("more", Icons.more), IconInfo("more_vert", Icons.more_vert), IconInfo("mouse", Icons.mouse), IconInfo("movie", Icons.movie), IconInfo("movie_filter", Icons.movie_filter), IconInfo("music_note", Icons.music_note), IconInfo("my_location", Icons.my_location), IconInfo("nature_people", Icons.nature_people), IconInfo("navigate_next", Icons.navigate_next), IconInfo("near_me", Icons.near_me), IconInfo("network_check", Icons.network_check), IconInfo("network_wifi", Icons.network_wifi), IconInfo("next_week", Icons.next_week), IconInfo("no_encryption", Icons.no_encryption), IconInfo("not_interested", Icons.not_interested), IconInfo("note", Icons.note), IconInfo("notification_important", Icons.notification_important), IconInfo("notifications_active", Icons.notifications_active), IconInfo("notifications_off", Icons.notifications_off), IconInfo("offline_bolt", Icons.offline_bolt), IconInfo("ondemand_video", Icons.ondemand_video), IconInfo("open_in_browser", Icons.open_in_browser), IconInfo("open_with", Icons.open_with), IconInfo("pages", Icons.pages), IconInfo("palette", Icons.palette), IconInfo("panorama", Icons.panorama), IconInfo("panorama_horizontal", Icons.panorama_horizontal), IconInfo("panorama_wide_angle", Icons.panorama_wide_angle), IconInfo("pause", Icons.pause), IconInfo("pause_circle_outline", Icons.pause_circle_outline), IconInfo("people", Icons.people), IconInfo("perm_camera_mic", Icons.perm_camera_mic), IconInfo("perm_data_setting", Icons.perm_data_setting), IconInfo("perm_identity", Icons.perm_identity), IconInfo("perm_phone_msg", Icons.perm_phone_msg), IconInfo("person", Icons.person), IconInfo("person_outline", Icons.person_outline), IconInfo("person_pin_circle", Icons.person_pin_circle), IconInfo("pets", Icons.pets), IconInfo("phone_android", Icons.phone_android), IconInfo("phone_forwarded", Icons.phone_forwarded), IconInfo("phone_iphone", Icons.phone_iphone), IconInfo("phone_missed", Icons.phone_missed), IconInfo("phonelink", Icons.phonelink), IconInfo("phonelink_lock", Icons.phonelink_lock), IconInfo("phonelink_ring", Icons.phonelink_ring), IconInfo("photo", Icons.photo), IconInfo("photo_camera", Icons.photo_camera), IconInfo("photo_library", Icons.photo_library), IconInfo("photo_size_select_large", Icons.photo_size_select_large), IconInfo("picture_as_pdf", Icons.picture_as_pdf), IconInfo("picture_in_picture_alt", Icons.picture_in_picture_alt), IconInfo("pie_chart_outlined", Icons.pie_chart_outlined), IconInfo("place", Icons.place), IconInfo("play_circle_filled", Icons.play_circle_filled), IconInfo("play_for_work", Icons.play_for_work), IconInfo("playlist_add_check", Icons.playlist_add_check), IconInfo("plus_one", Icons.plus_one), IconInfo("polymer", Icons.polymer), IconInfo("portable_wifi_off", Icons.portable_wifi_off), IconInfo("power", Icons.power), IconInfo("power_settings_new", Icons.power_settings_new), IconInfo("present_to_all", Icons.present_to_all), IconInfo("priority_high", Icons.priority_high), IconInfo("publish", Icons.publish), IconInfo("question_answer", Icons.question_answer), IconInfo("queue_music", Icons.queue_music), IconInfo("radio", Icons.radio), IconInfo("radio_button_unchecked", Icons.radio_button_unchecked), IconInfo("receipt", Icons.receipt), IconInfo("record_voice_over", Icons.record_voice_over), IconInfo("redo", Icons.redo), IconInfo("remove", Icons.remove), IconInfo("remove_circle_outline", Icons.remove_circle_outline), IconInfo("remove_red_eye", Icons.remove_red_eye), IconInfo("reorder", Icons.reorder), IconInfo("repeat_one", Icons.repeat_one), IconInfo("replay_10", Icons.replay_10), IconInfo("replay_5", Icons.replay_5), IconInfo("reply_all", Icons.reply_all), IconInfo("report_off", Icons.report_off), IconInfo("restaurant", Icons.restaurant), IconInfo("restore", Icons.restore), IconInfo("restore_page", Icons.restore_page), IconInfo("room", Icons.room), IconInfo("rotate_90_degrees_ccw", Icons.rotate_90_degrees_ccw), IconInfo("rotate_right", Icons.rotate_right), IconInfo("router", Icons.router), IconInfo("rss_feed", Icons.rss_feed), IconInfo("satellite", Icons.satellite), IconInfo("save_alt", Icons.save_alt), IconInfo("scatter_plot", Icons.scatter_plot), IconInfo("school", Icons.school), IconInfo("screen_lock_landscape", Icons.screen_lock_landscape), IconInfo("screen_lock_rotation", Icons.screen_lock_rotation), IconInfo("screen_share", Icons.screen_share), IconInfo("sd_storage", Icons.sd_storage), IconInfo("security", Icons.security), IconInfo("send", Icons.send), IconInfo("sentiment_neutral", Icons.sentiment_neutral), IconInfo("sentiment_very_dissatisfied", Icons.sentiment_very_dissatisfied), IconInfo("settings", Icons.settings), IconInfo("settings_backup_restore", Icons.settings_backup_restore), IconInfo("settings_brightness", Icons.settings_brightness), IconInfo("settings_ethernet", Icons.settings_ethernet), IconInfo("settings_input_component", Icons.settings_input_component), IconInfo("settings_input_hdmi", Icons.settings_input_hdmi), IconInfo("settings_overscan", Icons.settings_overscan), IconInfo("settings_power", Icons.settings_power), IconInfo("settings_system_daydream", Icons.settings_system_daydream), IconInfo("share", Icons.share), IconInfo("shop_two", Icons.shop_two), IconInfo("shopping_cart", Icons.shopping_cart), IconInfo("show_chart", Icons.show_chart), IconInfo("shutter_speed", Icons.shutter_speed), IconInfo("signal_cellular_connected_no_internet_4_bar", Icons.signal_cellular_connected_no_internet_4_bar), IconInfo("signal_cellular_null", Icons.signal_cellular_null), IconInfo("signal_wifi_4_bar", Icons.signal_wifi_4_bar), IconInfo("signal_wifi_off", Icons.signal_wifi_off), IconInfo("sim_card_alert", Icons.sim_card_alert), IconInfo("skip_previous", Icons.skip_previous), IconInfo("slow_motion_video", Icons.slow_motion_video), IconInfo("smoke_free", Icons.smoke_free), IconInfo("sms", Icons.sms), IconInfo("snooze", Icons.snooze), IconInfo("sort_by_alpha", Icons.sort_by_alpha), IconInfo("space_bar", Icons.space_bar), IconInfo("speaker_group", Icons.speaker_group), IconInfo("speaker_notes_off", Icons.speaker_notes_off), IconInfo("spellcheck", Icons.spellcheck), IconInfo("star_border", Icons.star_border), IconInfo("stars", Icons.stars), IconInfo("stay_current_portrait", Icons.stay_current_portrait), IconInfo("stay_primary_portrait", Icons.stay_primary_portrait), IconInfo("stop_screen_share", Icons.stop_screen_share), IconInfo("store", Icons.store), IconInfo("straighten", Icons.straighten), IconInfo("strikethrough_s", Icons.strikethrough_s), IconInfo("subdirectory_arrow_left", Icons.subdirectory_arrow_left), IconInfo("subject", Icons.subject), IconInfo("subtitles", Icons.subtitles), IconInfo("supervised_user_circle", Icons.supervised_user_circle), IconInfo("surround_sound", Icons.surround_sound), IconInfo("swap_horiz", Icons.swap_horiz), IconInfo("swap_vert", Icons.swap_vert), IconInfo("switch_camera", Icons.switch_camera), IconInfo("sync", Icons.sync), IconInfo("sync_problem", Icons.sync_problem), IconInfo("system_update_alt", Icons.system_update_alt), IconInfo("tab_unselected", Icons.tab_unselected), IconInfo("tablet", Icons.tablet), IconInfo("tablet_mac", Icons.tablet_mac), IconInfo("tap_and_play", Icons.tap_and_play), IconInfo("text_fields", Icons.text_fields), IconInfo("text_rotate_up", Icons.text_rotate_up), IconInfo("text_rotation_angledown", Icons.text_rotation_angledown), IconInfo("text_rotation_down", Icons.text_rotation_down), IconInfo("textsms", Icons.textsms), IconInfo("theaters", Icons.theaters), IconInfo("thumb_up", Icons.thumb_up), IconInfo("time_to_leave", Icons.time_to_leave), IconInfo("timeline", Icons.timeline), IconInfo("timer_10", Icons.timer_10), IconInfo("timer_off", Icons.timer_off), IconInfo("toc", Icons.toc), IconInfo("toll", Icons.toll), IconInfo("touch_app", Icons.touch_app), IconInfo("track_changes", Icons.track_changes), IconInfo("train", Icons.train), IconInfo("transfer_within_a_station", Icons.transfer_within_a_station), IconInfo("transit_enterexit", Icons.transit_enterexit), IconInfo("trending_down", Icons.trending_down), IconInfo("trending_up", Icons.trending_up), IconInfo("tune", Icons.tune), IconInfo("turned_in_not", Icons.turned_in_not), IconInfo("unarchive", Icons.unarchive), IconInfo("unfold_less", Icons.unfold_less), IconInfo("update", Icons.update), IconInfo("verified_user", Icons.verified_user), IconInfo("vertical_align_center", Icons.vertical_align_center), IconInfo("vibration", Icons.vibration), IconInfo("video_label", Icons.video_label), IconInfo("videocam", Icons.videocam), IconInfo("videogame_asset", Icons.videogame_asset), IconInfo("view_array", Icons.view_array), IconInfo("view_column", Icons.view_column), IconInfo("view_compact", Icons.view_compact), IconInfo("view_headline", Icons.view_headline), IconInfo("view_module", Icons.view_module), IconInfo("view_stream", Icons.view_stream), IconInfo("vignette", Icons.vignette), IconInfo("visibility_off", Icons.visibility_off), IconInfo("voicemail", Icons.voicemail), IconInfo("volume_mute", Icons.volume_mute), IconInfo("volume_up", Icons.volume_up), IconInfo("vpn_lock", Icons.vpn_lock), IconInfo("warning", Icons.warning), IconInfo("watch_later", Icons.watch_later), IconInfo("wb_cloudy", Icons.wb_cloudy), IconInfo("wb_iridescent", Icons.wb_iridescent), IconInfo("wc", Icons.wc), IconInfo("web_asset", Icons.web_asset), IconInfo("whatshot", Icons.whatshot), IconInfo("wifi", Icons.wifi), IconInfo("wifi_tethering", Icons.wifi_tethering), IconInfo("wrap_text", Icons.wrap_text), IconInfo("zoom_in", Icons.zoom_in), IconInfo("zoom_out_map", Icons.zoom_out_map), ]; class IconInfo { String name; IconData iconData; IconInfo(this.name, this.iconData); }
0
mirrored_repositories/MetaFlutter/lib/widget_builder_utilities
mirrored_repositories/MetaFlutter/lib/widget_builder_utilities/widgets/card_view_model.dart
import 'package:flutter/material.dart'; import 'package:flutter_app_builder/utils/code_utils.dart'; import '../model_widget.dart'; import '../property.dart'; class CardViewModel extends ModelWidget { CardViewModel() { this.widgetType = WidgetType.CardView; this.nodeType = NodeType.SingleChild; this.hasProperties = true; this.hasChildren = true; this.paramNameAndTypes = { "elevation": PropertyType.double, "color": PropertyType.color, }; this.params = { "elevation": 2.0, "color": Colors.white, }; } @override Map getParamValuesMap() { return {"elevation": params["elevation"], "color": params["color"]}; } @override Widget toWidget() { return Card( child: children[0]?.toWidget() ?? Container(), elevation: params["elevation"] ?? 2.0, color: params["color"] ?? Colors.white, ); } @override String toCode() { return "Card(\n" "${paramToCode(paramName: "elevation", type: PropertyType.double, currentValue: params["elevation"])}" "${paramToCode(paramName: "color", type: PropertyType.color, currentValue: params["color"])}" " child: ${children[0]?.toCode() ?? 'Container()'}," "\n )"; } }
0
mirrored_repositories/MetaFlutter/lib/widget_builder_utilities
mirrored_repositories/MetaFlutter/lib/widget_builder_utilities/widgets/fitted_box_model.dart
import 'package:flutter/material.dart'; import 'package:flutter_app_builder/utils/code_utils.dart'; import '../model_widget.dart'; import '../property.dart'; /// Provides a model for recreating the [FittedBox] widget class FittedBoxModel extends ModelWidget { FittedBoxModel() { this.widgetType = WidgetType.FittedBox; this.nodeType = NodeType.SingleChild; this.hasProperties = true; this.hasChildren = true; this.paramNameAndTypes = { "fit": PropertyType.boxFit, "alignment": PropertyType.alignment }; this.params = {}; } @override Widget toWidget() { return FittedBox( child: children[0]?.toWidget() ?? Container(), alignment: params["alignment"] ?? Alignment.center, fit: params["fit"] ?? BoxFit.contain, ); } @override Map getParamValuesMap() { return { "alignment": params["alignment"], "fit": params["fit"], }; } @override String toCode() { return "FittedBox(\n" "${paramToCode(paramName: "alignment", type: PropertyType.alignment, currentValue: params["alignment"])}" "${paramToCode(type: PropertyType.boxFit, paramName: "fit", currentValue: params["fit"])}" " child: ${children[0]?.toCode() ?? 'Container()'}," "\n )"; } }
0
mirrored_repositories/MetaFlutter/lib/widget_builder_utilities
mirrored_repositories/MetaFlutter/lib/widget_builder_utilities/widgets/raised_button_model.dart
import 'package:flutter/material.dart'; import 'package:flutter_app_builder/utils/code_utils.dart'; import '../model_widget.dart'; import '../property.dart'; /// Provides a model for recreating the [RaisedButton] widget class RaisedButtonModel extends ModelWidget { RaisedButtonModel() { this.widgetType = WidgetType.RaisedButton; this.nodeType = NodeType.SingleChild; this.hasProperties = true; this.hasChildren = true; this.paramNameAndTypes = { "color": PropertyType.color, }; } @override Widget toWidget() { return RaisedButton( child: children[0]?.toWidget() ?? Container(), onPressed: () {}, color: params["color"], ); } @override Map getParamValuesMap() { return { "color": params["color"], }; } @override String toCode() { return "RaisedButton(\n" " onPressed: () {}," "${paramToCode(paramName: "color", type: PropertyType.color, currentValue: params["color"])}" " child: ${children[0]?.toCode() ?? 'Container()'}," "\n )"; } }
0
mirrored_repositories/MetaFlutter/lib/widget_builder_utilities
mirrored_repositories/MetaFlutter/lib/widget_builder_utilities/widgets/icon_model.dart
import 'package:flutter/material.dart'; import 'package:flutter_app_builder/utils/code_utils.dart'; import '../model_widget.dart'; import '../property.dart'; /// Provides a model for recreating the [Icon] widget class IconModel extends ModelWidget { IconModel() { this.widgetType = WidgetType.Icon; this.nodeType = NodeType.End; this.hasProperties = true; this.hasChildren = false; this.paramNameAndTypes = { "icon": PropertyType.icon, "size": PropertyType.double, }; this.params = { "size": "20.0", }; } @override Widget toWidget() { return Icon( params["icon"] ?? Icons.help_outline, size: double.tryParse(params["size"]) ?? 20.0, ); } @override Map getParamValuesMap() { return { "icon": params["icon"], "size": params["size"], }; } @override String toCode() { return "Icon(\n" "${paramToCode(paramName: "icon", isNamed: false, currentValue: params["icon"], defaultValue: "Icons.help_outline", type: PropertyType.icon)}" "${paramToCode(paramName: "size", type: PropertyType.double, currentValue: params["size"])}" "\n )"; } }
0
mirrored_repositories/MetaFlutter/lib/widget_builder_utilities
mirrored_repositories/MetaFlutter/lib/widget_builder_utilities/widgets/column_model.dart
import 'package:flutter/material.dart'; import 'package:flutter_app_builder/utils/code_utils.dart'; import '../model_widget.dart'; import '../property.dart'; /// Provides a model for recreating the [Column] widget class ColumnModel extends ModelWidget { ColumnModel() { this.widgetType = WidgetType.Column; this.nodeType = NodeType.MultipleChildren; this.hasProperties = true; this.hasChildren = true; this.paramNameAndTypes = { "mainAxisAlignment": PropertyType.mainAxisAlignment, "crossAxisAlignment": PropertyType.crossAxisAlignment }; this.params = { "mainAxisAlignment": MainAxisAlignment.start, "crossAxisAlignment": CrossAxisAlignment.start, }; } @override Widget toWidget() { return Column( mainAxisAlignment: params["mainAxisAlignment"] == null ? MainAxisAlignment.start : params["mainAxisAlignment"], crossAxisAlignment: params["crossAxisAlignment"] == null ? CrossAxisAlignment.start : params["crossAxisAlignment"], children: children.isNotEmpty ? children.values.map((widget) { return widget.toWidget(); }).toList() : [], ); } @override Map getParamValuesMap() { return { "mainAxisAlignment": params["mainAxisAlignment"], "crossAxisAlignment": params["crossAxisAlignment"], }; } @override String toCode() { return "Column(\n" "${paramToCode(paramName: "mainAxisAlignment", type: PropertyType.mainAxisAlignment, currentValue: params["mainAxisAlignment"])}" "${paramToCode(paramName: "crossAxisAlignment", type: PropertyType.mainAxisAlignment, currentValue: params["crossAxisAlignment"])}" ''' children: ${children.isNotEmpty ? children.values.map((widget) { return widget.toCode(); }).toList() : []},''' "\n )"; } }
0
mirrored_repositories/MetaFlutter/lib/widget_builder_utilities
mirrored_repositories/MetaFlutter/lib/widget_builder_utilities/widgets/transform_scale_model.dart
import 'package:flutter/material.dart'; import '../model_widget.dart'; import '../property.dart'; /// Provides a model for recreating the [Transform.scale] widget class TransformScaleModel extends ModelWidget { TransformScaleModel() { this.widgetType = WidgetType.TransformScale; this.nodeType = NodeType.SingleChild; this.hasProperties = true; this.hasChildren = true; this.paramNameAndTypes = { "scale": PropertyType.double, "originX": PropertyType.double, "originY": PropertyType.double, }; this.params = { "scale": "0.0", "originX": "0.0", "originY": "0.0", }; } @override Widget toWidget() { return Transform.scale( child: children[0]?.toWidget() ?? Container(), scale: double.tryParse(params["scale"]) ?? 0.0, origin: Offset(double.tryParse(params["originX"]) ?? 0.0, double.tryParse(params["originY"]) ?? 0.0), ); } @override Map getParamValuesMap() { return { "scale": params["scale"], "originX": params["originX"], "originY": params["originY"], }; } @override String toCode() { return '''Transform.scale( child: ${children[0]?.toCode() ?? 'Container()'}, scale: ${double.tryParse(params["scale"]) ?? 0.0}, origin: Offset(${double.tryParse(params["originX"]) ?? 0.0}, ${double.tryParse(params["originY"]) ?? 0.0}), )'''; } }
0
mirrored_repositories/MetaFlutter/lib/widget_builder_utilities
mirrored_repositories/MetaFlutter/lib/widget_builder_utilities/widgets/grid_view_model.dart
import 'package:flutter/material.dart'; import 'package:flutter_app_builder/utils/code_utils.dart'; import '../model_widget.dart'; import '../property.dart'; /// Provides a model for recreating the [GridView] widget class GridViewModel extends ModelWidget { GridViewModel() { this.widgetType = WidgetType.GridView; this.nodeType = NodeType.MultipleChildren; this.hasProperties = true; this.hasChildren = true; this.paramNameAndTypes = { "physics": PropertyType.scrollPhysics, "shrinkWrap": PropertyType.boolean, "crossAxisCount": PropertyType.integer, }; this.params = { "shrinkWrap": false, }; } @override Widget toWidget() { return GridView( children: children.isNotEmpty ? children.values.map((widget) { return widget.toWidget(); }).toList() : [], shrinkWrap: params["shrinkWrap"] ?? false, physics: params["physics"], gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( crossAxisCount: params["crossAxisCount"] ?? 2), ); } @override Map getParamValuesMap() { return { "physics": params["physics"], "shrinkWrap": params["shrinkWrap"], "crossAxisCount": PropertyType.integer, }; } @override String toCode() { return "GridView(\n" "${paramToCode(paramName: "shrinkWrap", currentValue: params["shrinkWrap"], type: PropertyType.boolean)}" "${paramToCode(paramName: "physics", type: PropertyType.scrollPhysics, currentValue: params["physics"])}" '''gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( crossAxisCount: ${params["crossAxisCount"] ?? 2}), children: ${children.isNotEmpty ? children.values.map((widget) { return widget.toCode(); }).toList() : []},''' "\n )"; } }
0
mirrored_repositories/MetaFlutter/lib/widget_builder_utilities
mirrored_repositories/MetaFlutter/lib/widget_builder_utilities/widgets/list_view_model.dart
import 'package:flutter/material.dart'; import 'package:flutter_app_builder/utils/code_utils.dart'; import '../model_widget.dart'; import '../property.dart'; /// Provides a model for recreating the [ListView] widget class ListViewModel extends ModelWidget { ListViewModel() { this.widgetType = WidgetType.ListView; this.nodeType = NodeType.MultipleChildren; this.hasProperties = true; this.hasChildren = true; this.paramNameAndTypes = { "physics": PropertyType.scrollPhysics, "shrinkWrap": PropertyType.boolean, }; this.params = { "shrinkWrap": false, }; } @override Widget toWidget() { return ListView( children: children.isNotEmpty ? children.values.map((widget) { return widget.toWidget(); }).toList() : [], physics: params["physics"] ?? AlwaysScrollableScrollPhysics(), shrinkWrap: params["shrinkWrap"] ?? false, ); } @override Map getParamValuesMap() { return { "physics": params["physics"], "shrinkWrap": params["shrinkWrap"], }; } @override String toCode() { return "ListView(\n" "${paramToCode(paramName: "shrinkWrap", currentValue: params["shrinkWrap"], type: PropertyType.boolean)}" "${paramToCode(paramName: "physics", type: PropertyType.scrollPhysics, currentValue: params["physics"])}" ''' children: ${children.isNotEmpty ? children.values.map((widget) { return widget.toCode(); }).toList() : []},''' "\n )"; } }
0
mirrored_repositories/MetaFlutter/lib/widget_builder_utilities
mirrored_repositories/MetaFlutter/lib/widget_builder_utilities/widgets/safe_area_model.dart
import 'package:flutter/material.dart'; import '../model_widget.dart'; import '../property.dart'; /// Provides a model for recreating the [SafeArea] widget class SafeAreaModel extends ModelWidget { SafeAreaModel() { this.widgetType = WidgetType.SafeArea; this.nodeType = NodeType.SingleChild; this.hasProperties = false; this.hasChildren = true; } @override Widget toWidget() { return SafeArea( child: children[0]?.toWidget() ?? Container(), ); } @override Map getParamValuesMap() { return {}; } @override String toCode() { return '''SafeArea( child: ${children[0]?.toCode() ?? 'Container()'}, )'''; } }
0
mirrored_repositories/MetaFlutter/lib/widget_builder_utilities
mirrored_repositories/MetaFlutter/lib/widget_builder_utilities/widgets/page_view_model.dart
import 'package:flutter/material.dart'; import 'package:flutter_app_builder/utils/code_utils.dart'; import '../model_widget.dart'; import '../property.dart'; /// Provides a model for recreating the [PageView] widget class PageViewModel extends ModelWidget { PageViewModel() { this.widgetType = WidgetType.PageView; this.nodeType = NodeType.MultipleChildren; this.hasProperties = true; this.hasChildren = true; this.paramNameAndTypes = { "physics": PropertyType.scrollPhysics, "scrollDirection": PropertyType.axis, }; this.params = { "scrollDirection": Axis.horizontal, }; } @override Widget toWidget() { return PageView( children: children.isNotEmpty ? children.values.map((widget) { return widget.toWidget(); }).toList() : [], physics: params["physics"] ?? AlwaysScrollableScrollPhysics(), scrollDirection: params["scrollDirection"] ?? Axis.horizontal, ); } @override Map getParamValuesMap() { return { "physics": params["physics"], "scrollDirection": params["scrollDirection"] }; } @override String toCode() { return "PageView(\n" "${paramToCode(paramName: "physics", type: PropertyType.scrollPhysics, currentValue: params["physics"])}" "${paramToCode(paramName: "scrollDirection", type: PropertyType.axis, currentValue: params["scrollDirection"])}" ''' children: ${children.isNotEmpty ? children.values.map((widget) { return widget.toCode(); }).toList() : []},''' "\n )"; } }
0
mirrored_repositories/MetaFlutter/lib/widget_builder_utilities
mirrored_repositories/MetaFlutter/lib/widget_builder_utilities/widgets/stack_model.dart
import 'package:flutter/material.dart'; import '../model_widget.dart'; import '../property.dart'; /// Provides a model for recreating the [Stack] widget class StackModel extends ModelWidget { StackModel() { this.widgetType = WidgetType.Stack; this.nodeType = NodeType.MultipleChildren; this.hasProperties = false; this.hasChildren = true; } @override Widget toWidget() { return Stack( children: children.isNotEmpty ? children.values.map( (widget) { return widget.toWidget(); }, ).toList() : [], ); } @override Map getParamValuesMap() { return {}; } @override String toCode() { return '''Stack( children: ${children.isNotEmpty ? children.values.map( (widget) { return widget.toCode(); }, ).toList() : []}, )'''; } }
0
mirrored_repositories/MetaFlutter/lib/widget_builder_utilities
mirrored_repositories/MetaFlutter/lib/widget_builder_utilities/widgets/container_model.dart
import 'package:flutter/material.dart'; import 'package:flutter_app_builder/utils/code_utils.dart'; import '../model_widget.dart'; import '../property.dart'; /// Provides a model for recreating the [Container] widget class ContainerModel extends ModelWidget { ContainerModel() { this.widgetType = WidgetType.Container; this.nodeType = NodeType.SingleChild; this.hasProperties = true; this.hasChildren = true; this.paramNameAndTypes = { "width": PropertyType.double, "height": PropertyType.double, "color": PropertyType.color, "alignment": PropertyType.alignment }; this.params = { "width": "0.0", "height": "0.0", }; } @override Widget toWidget() { return Container( child: children[0]?.toWidget() ?? Container(), width: double.tryParse(params["width"]), height: double.tryParse(params["height"]), alignment: params["alignment"], decoration: BoxDecoration( color: params["color"], ), ); } @override Map getParamValuesMap() { return { "width": params["width"], "height": params["height"], "color": params["color"], "alignment": params["alignment"], }; } @override String toCode() { return "Container(\n" "${paramToCode(paramName: "width", currentValue: double.tryParse(params["width"]), type: PropertyType.double)}" "${paramToCode(paramName: "height", currentValue: double.tryParse(params["height"]), type: PropertyType.double)}" "${paramToCode(paramName: "alignment", type: PropertyType.alignment, currentValue: params["alignment"])}" " decoration: BoxDecoration(\n" "${paramToCode(paramName: "color", type: PropertyType.color, currentValue: params["color"])}" " )," "\n child: ${children[0]?.toCode() ?? 'Container()'}," "\n )"; } }
0
mirrored_repositories/MetaFlutter/lib/widget_builder_utilities
mirrored_repositories/MetaFlutter/lib/widget_builder_utilities/widgets/transform_rotate_model.dart
import 'package:flutter/material.dart'; import '../model_widget.dart'; import '../property.dart'; /// Provides a model for recreating the [Transform.rotate] widget class TransformRotateModel extends ModelWidget { TransformRotateModel() { this.widgetType = WidgetType.TransformRotate; this.nodeType = NodeType.SingleChild; this.hasProperties = true; this.hasChildren = true; this.paramNameAndTypes = { "angle": PropertyType.double, "originX": PropertyType.double, "originY": PropertyType.double, }; this.params = { "angle": "0.0", "originX": "0.0", "originY": "0.0", }; } @override Widget toWidget() { return Transform.rotate( child: children[0]?.toWidget() ?? Container(), angle: double.tryParse(params["angle"]) ?? 0.0, origin: Offset(double.tryParse(params["originX"]) ?? 0.0, double.tryParse(params["originY"]) ?? 0.0), ); } @override Map getParamValuesMap() { return { "angle": params["angle"], "originX": params["originX"], "originY": params["originY"], }; } @override String toCode() { return '''Transform.rotate( child: ${children[0]?.toCode() ?? 'Container()'}, angle: ${double.tryParse(params["angle"]) ?? 0.0}, origin: Offset(${double.tryParse(params["originX"]) ?? 0.0}, ${double.tryParse(params["originY"]) ?? 0.0}), )'''; } }
0
mirrored_repositories/MetaFlutter/lib/widget_builder_utilities
mirrored_repositories/MetaFlutter/lib/widget_builder_utilities/widgets/text_model.dart
import 'package:flutter/material.dart'; import 'package:flutter_app_builder/utils/code_utils.dart'; import '../model_widget.dart'; import '../property.dart'; /// Provides a model for recreating the [Text] widget class TextModel extends ModelWidget { TextModel() { this.widgetType = WidgetType.Text; this.nodeType = NodeType.End; this.hasProperties = true; this.hasChildren = false; this.paramNameAndTypes = { "text": PropertyType.string, "fontSize": PropertyType.double, "color": PropertyType.color, "fontStyle": PropertyType.fontStyle }; this.params = { "text": "", "fontSize": "14.0", "color": Colors.black, "fontStyle": FontStyle.normal }; } @override Widget toWidget() { return Text( params["text"] ?? "", style: TextStyle( fontSize: double.tryParse(params["fontSize"]) ?? 14.0, color: params["color"] ?? Colors.black, fontStyle: params["fontStyle"] ?? FontStyle.normal), ); } @override Map getParamValuesMap() { return { "text": params["text"], "fontSize": params["fontSize"], "color": params["color"], "fontStyle": params["fontStyle"] }; } @override String toCode() { return "Text(\n" "${paramToCode(isNamed: false, type: PropertyType.string, currentValue: params["text"], defaultValue: "")}" " style: TextStyle(\n" "${paramToCode(paramName: "fontSize", type: PropertyType.double, currentValue: double.tryParse(params["fontSize"]), defaultValue: 14.0.toString())}" "${paramToCode(paramName: "color", type: PropertyType.color, currentValue: params["color"])}" "${paramToCode(paramName: "fontStyle", type: PropertyType.fontStyle, currentValue: params["fontStyle"], defaultValue: "FontStyle.normal")}" " )," "\n)"; } }
0
mirrored_repositories/MetaFlutter/lib/widget_builder_utilities
mirrored_repositories/MetaFlutter/lib/widget_builder_utilities/widgets/padding_model.dart
import 'package:flutter/material.dart'; import 'package:flutter_app_builder/utils/code_utils.dart'; import '../model_widget.dart'; import '../property.dart'; /// Provides a model for recreating the [Padding] widget class PaddingModel extends ModelWidget { PaddingModel() { this.widgetType = WidgetType.Padding; this.nodeType = NodeType.SingleChild; this.hasProperties = true; this.hasChildren = true; this.paramNameAndTypes = { "left": PropertyType.double, "top": PropertyType.double, "right": PropertyType.double, "bottom": PropertyType.double, }; this.params = { "left": "0.0", "top": "0.0", "right": "0.0", "bottom": "0.0", }; } @override Widget toWidget() { return Padding( child: children[0]?.toWidget() ?? Container(), padding: EdgeInsets.fromLTRB( double.tryParse(params["left"]) ?? 0.0, double.tryParse(params["top"]) ?? 0.0, double.tryParse(params["right"]) ?? 0.0, double.tryParse(params["bottom"]) ?? 0.0, ), ); } @override Map getParamValuesMap() { return { "left": params["left"], "top": params["top"], "right": params["right"], "bottom": params["bottom"], }; } @override String toCode() { return "Padding(\n" " padding: EdgeInsets.fromLTRB(\n" "${paramToCode(isNamed: false, type: PropertyType.double, currentValue: params["left"], defaultValue: "0.0")}" "${paramToCode(isNamed: false, type: PropertyType.double, currentValue: params["top"], defaultValue: "0.0")}" "${paramToCode(isNamed: false, type: PropertyType.double, currentValue: params["right"], defaultValue: "0.0")}" "${paramToCode(isNamed: false, type: PropertyType.double, currentValue: params["bottom"], defaultValue: "0.0")}" " ),\n" " child: ${children[0]?.toCode() ?? 'Container()'}," "\n)"; } }
0
mirrored_repositories/MetaFlutter/lib/widget_builder_utilities
mirrored_repositories/MetaFlutter/lib/widget_builder_utilities/widgets/flutter_logo_model.dart
import 'package:flutter/material.dart'; import 'package:flutter_app_builder/utils/code_utils.dart'; import '../model_widget.dart'; import '../property.dart'; /// Provides a model for recreating the [FlutterLogo] widget class FlutterLogoModel extends ModelWidget { FlutterLogoModel() { this.widgetType = WidgetType.FlutterLogo; this.nodeType = NodeType.End; this.hasProperties = true; this.hasChildren = false; this.paramNameAndTypes = { "size": PropertyType.double, }; this.params = { "size": "40.0", }; } @override Widget toWidget() { return FlutterLogo( size: double.tryParse(params["size"]) ?? 40.0, ); } @override Map getParamValuesMap() { return {"size": params["size"]}; } @override String toCode() { return "FlutterLogo(\n" "${paramToCode(paramName: "size", type: PropertyType.double, currentValue: params["size"])}" "\n )"; } }
0
mirrored_repositories/MetaFlutter/lib/widget_builder_utilities
mirrored_repositories/MetaFlutter/lib/widget_builder_utilities/widgets/aspect_ratio_model.dart
import 'package:flutter/material.dart'; import 'package:flutter_app_builder/utils/code_utils.dart'; import '../model_widget.dart'; import '../property.dart'; /// Provides a model for recreating the [AspectRatio] widget class AspectRatioModel extends ModelWidget { AspectRatioModel() { this.widgetType = WidgetType.AspectRatio; this.nodeType = NodeType.SingleChild; this.hasProperties = true; this.hasChildren = true; this.paramNameAndTypes = { "aspectRatio": PropertyType.double, }; this.params = {"aspectRatio": "1.0"}; } @override Widget toWidget() { return AspectRatio( child: children[0]?.toWidget() ?? Container(), aspectRatio: double.tryParse(params["aspectRatio"]) ?? 1.0, ); } @override Map getParamValuesMap() { return { "aspectRatio": params["aspectRatio"], }; } @override String toCode() { return "AspectRatio(\n" "${paramToCode(paramName: "aspectRatio", type: PropertyType.double, currentValue: double.tryParse(params["aspectRatio"]))}" " child: ${children[0]?.toCode() ?? 'Container()'}," "\n )"; } }
0
mirrored_repositories/MetaFlutter/lib/widget_builder_utilities
mirrored_repositories/MetaFlutter/lib/widget_builder_utilities/widgets/center_model.dart
import 'package:flutter/material.dart'; import 'package:flutter_app_builder/utils/code_utils.dart'; import '../model_widget.dart'; import '../property.dart'; /// Provides a model for recreating the [Center] widget class CenterModel extends ModelWidget { CenterModel() { this.widgetType = WidgetType.Center; this.nodeType = NodeType.SingleChild; this.hasProperties = true; this.hasChildren = true; this.paramNameAndTypes = { "widthFactor": PropertyType.double, "heightFactor": PropertyType.double, }; this.params = { "widthFactor": "100.0", "heightFactor": "100.0", }; } @override Widget toWidget() { return Center( child: children[0]?.toWidget() ?? Container(), widthFactor: double.tryParse(params["widthFactor"].toString()), heightFactor: double.tryParse(params["heightFactor"].toString()), ); } @override Map getParamValuesMap() { return { "widthFactor": params["widthFactor"], "heightFactor": params["heightFactor"], }; } @override String toCode() { return "Center(\n" "${paramToCode(paramName: "widthFactor", currentValue: double.tryParse(params["widthFactor"].toString()), type: PropertyType.double)}" "${paramToCode(paramName: "heightFactor", currentValue: double.tryParse(params["heightFactor"].toString()), type: PropertyType.double)}" " child: ${children[0]?.toCode() ?? 'Container()'}," "\n )"; } }
0
mirrored_repositories/MetaFlutter/lib/widget_builder_utilities
mirrored_repositories/MetaFlutter/lib/widget_builder_utilities/widgets/row_model.dart
import 'package:flutter/material.dart'; import 'package:flutter_app_builder/utils/code_utils.dart'; import '../model_widget.dart'; import '../property.dart'; /// Provides a model for recreating the [Row] widget class RowModel extends ModelWidget { RowModel() { this.widgetType = WidgetType.Row; this.nodeType = NodeType.MultipleChildren; this.hasProperties = true; this.hasChildren = true; this.paramNameAndTypes = { "mainAxisAlignment": PropertyType.mainAxisAlignment, "crossAxisAlignment": PropertyType.crossAxisAlignment }; this.params = { "mainAxisAlignment": MainAxisAlignment.start, "crossAxisAlignment": CrossAxisAlignment.start, }; } @override Widget toWidget() { return Row( mainAxisAlignment: params["mainAxisAlignment"] == null ? MainAxisAlignment.start : params["mainAxisAlignment"], crossAxisAlignment: params["crossAxisAlignment"] == null ? CrossAxisAlignment.start : params["crossAxisAlignment"], children: children.isNotEmpty ? children.values.map((widget) { return widget.toWidget(); }).toList() : [], ); } @override Map getParamValuesMap() { return { "mainAxisAlignment": params["mainAxisAlignment"], "crossAxisAlignment": params["crossAxisAlignment"], }; } @override String toCode() { return "Row(\n" "${paramToCode(paramName: "mainAxisAlignment", type: PropertyType.mainAxisAlignment, currentValue: params["mainAxisAlignment"])}" "${paramToCode(paramName: "crossAxisAlignment", type: PropertyType.mainAxisAlignment, currentValue: params["crossAxisAlignment"])}" ''' children: ${children.isNotEmpty ? children.values.map((widget) { return widget.toCode(); }).toList() : []},''' "\n )"; } }
0
mirrored_repositories/MetaFlutter/lib/widget_builder_utilities
mirrored_repositories/MetaFlutter/lib/widget_builder_utilities/widgets/expanded_model.dart
import 'package:flutter/material.dart'; import 'package:flutter_app_builder/utils/code_utils.dart'; import '../model_widget.dart'; import '../property.dart'; /// Provides a model for recreating the [Expanded] widget class ExpandedModel extends ModelWidget { ExpandedModel() { this.widgetType = WidgetType.Expanded; this.nodeType = NodeType.SingleChild; this.hasProperties = true; this.hasChildren = true; this.paramNameAndTypes = { "flex": PropertyType.integer, }; this.params = { "flex": "1", }; } @override Widget toWidget() { return Expanded( child: children[0]?.toWidget() ?? Container(), flex: int.tryParse(params["flex"]), ); } @override Map getParamValuesMap() { return { "flex": params["flex"], }; } @override String toCode() { return "Expanded(\n" "${paramToCode(paramName: "flex", type: PropertyType.integer, currentValue: int.tryParse(params["flex"]))}" " child: ${children[0]?.toCode() ?? 'Container()'}," "\n )"; } }
0
mirrored_repositories/MetaFlutter/lib/widget_builder_utilities
mirrored_repositories/MetaFlutter/lib/widget_builder_utilities/widgets/text_field_model.dart
import 'package:flutter/material.dart'; import 'package:flutter_app_builder/utils/code_utils.dart'; import '../model_widget.dart'; import '../property.dart'; /// Provides a model for recreating the [TextField] widget class TextFieldModel extends ModelWidget { TextFieldModel() { this.widgetType = WidgetType.TextField; this.nodeType = NodeType.End; this.hasProperties = true; this.hasChildren = false; this.paramNameAndTypes = { "hintText": PropertyType.string, }; this.params = { "hintText": "", }; } @override Widget toWidget() { return TextField( decoration: InputDecoration( hintText: params["hintText"] ?? "", border: OutlineInputBorder(), ), ); } @override Map getParamValuesMap() { return { "hintText": params["hintText"], }; } @override String toCode() { return "TextField(\n" " decoration: InputDecoration(\n" "${paramToCode(paramName: "hintText", type: PropertyType.string, currentValue: params["hintText"])}" " border: OutlineInputBorder(),\n" " )," "\n )"; } }
0
mirrored_repositories/MetaFlutter/lib/widget_builder_utilities
mirrored_repositories/MetaFlutter/lib/widget_builder_utilities/widgets/align_model.dart
import 'package:flutter/material.dart'; import 'package:flutter_app_builder/utils/code_utils.dart'; import '../model_widget.dart'; import '../property.dart'; /// Provides a model for recreating the [Align] widget class AlignModel extends ModelWidget { AlignModel() { this.widgetType = WidgetType.Align; this.nodeType = NodeType.SingleChild; this.hasProperties = true; this.hasChildren = true; this.paramNameAndTypes = { "widthFactor": PropertyType.double, "heightFactor": PropertyType.double, "alignment": PropertyType.alignment }; this.params = { "widthFactor": "100.0", "heightFactor": "100.0", }; } @override Widget toWidget() { return Align( child: children[0]?.toWidget() ?? Container(), widthFactor: double.tryParse(params["widthFactor"].toString()) ?? null, heightFactor: double.tryParse(params["heightFactor"].toString()) ?? null, alignment: params["alignment"] ?? Alignment.center, ); } @override Map getParamValuesMap() { return { "widthFactor": params["widthFactor"], "heightFactor": params["heightFactor"], "alignment": params["alignment"], }; } @override String toCode() { return "Align(\n" "${paramToCode(paramName: "widthFactor", type: PropertyType.double, currentValue: double.tryParse(params["widthFactor"].toString()))}" "${paramToCode(paramName: "heightFactor", type: PropertyType.double, currentValue: double.tryParse(params["heightFactor"].toString()))}" "${paramToCode(paramName: "alignment", type: PropertyType.alignment, currentValue: params["alignment"])}" " child: ${children[0]?.toCode() ?? "Container()"}," "\n )"; } }
0
mirrored_repositories/MetaFlutter/lib/widget_builder_utilities
mirrored_repositories/MetaFlutter/lib/widget_builder_utilities/widgets/flat_button_model.dart
import 'package:flutter/material.dart'; import 'package:flutter_app_builder/utils/code_utils.dart'; import '../model_widget.dart'; import '../property.dart'; /// Provides a model for recreating the [FittedBox] widget class FlatButtonModel extends ModelWidget { FlatButtonModel() { this.widgetType = WidgetType.FlatButton; this.nodeType = NodeType.SingleChild; this.hasProperties = true; this.hasChildren = true; this.paramNameAndTypes = { "color": PropertyType.color, }; } @override Widget toWidget() { return FlatButton( child: children[0]?.toWidget() ?? Container(), onPressed: () {}, color: params["color"], ); } @override Map getParamValuesMap() { return { "color": params["color"], }; } @override String toCode() { return "FlatButton(\n" " onPressed: () {},\n" "${paramToCode(paramName: "color", type: PropertyType.color, currentValue: params["color"])}" " child: ${children[0]?.toCode() ?? 'Container()'}," "\n )"; } }
0
mirrored_repositories/MetaFlutter/lib/widget_builder_utilities
mirrored_repositories/MetaFlutter/lib/widget_builder_utilities/widgets/transform_translate_model.dart
import 'package:flutter/material.dart'; import '../model_widget.dart'; import '../property.dart'; /// Provides a model for recreating the [Transform.translate] widget class TransformTranslateModel extends ModelWidget { TransformTranslateModel() { this.widgetType = WidgetType.TransformTranslate; this.nodeType = NodeType.SingleChild; this.hasProperties = true; this.hasChildren = true; this.paramNameAndTypes = { "translationX": PropertyType.double, "translationY": PropertyType.double, }; this.params = { "translationX": "0.0", "translationY": "0.0", }; } @override Widget toWidget() { return Transform.translate( child: children[0]?.toWidget() ?? Container(), offset: Offset(double.tryParse(params["translationX"]) ?? 0.0, double.tryParse(params["translationY"]) ?? 0.0), ); } @override Map getParamValuesMap() { return { "translationX": params["translationX"], "translationY": params["translationY"], }; } @override String toCode() { return '''Transform.translate( child: ${children[0]?.toCode() ?? 'Container()'}, offset: Offset(${double.tryParse(params["translationX"]) ?? 0.0}, ${double.tryParse(params["translationY"]) ?? 0.0}), )'''; } }
0
mirrored_repositories/MetaFlutter/lib
mirrored_repositories/MetaFlutter/lib/pages/about_screen.dart
import 'package:flutter/material.dart'; import 'package:url_launcher/url_launcher.dart'; class AboutScreen extends StatefulWidget { @override _AboutScreenState createState() => _AboutScreenState(); } class _AboutScreenState extends State<AboutScreen> { List<String> contributors = [ "Deven Joshi (Creator and maintainer)", "Tushar Parmar", "sherlockbeard" ]; @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text("About"), ), body: ListView( children: <Widget>[ Image.asset('images/screenshot.png'), Center( child: Text( "MetaFlutter", style: TextStyle(fontSize: 22.0, fontWeight: FontWeight.w300), ), ), SizedBox( height: 8.0, ), Center( child: Padding( padding: const EdgeInsets.all(12.0), child: FittedBox( child: Text( "Experiment with Flutter widgets on your phone!", style: TextStyle(fontWeight: FontWeight.bold, fontSize: 24.0), ), ), ), ), Padding( padding: const EdgeInsets.all(12.0), child: Center( child: Text( '''MetaFlutter allows you to create Flutter layouts using a wide and constantly growing range of Flutter widgets. \nBuild out an idea you had instantly, try out something you've never tried before or just use it as a tool for Flutter layout demonstrations. \nNo login. Free to use. Open-source.'''), ), ), Padding( padding: const EdgeInsets.all(12.0), child: Text( "Authors", style: TextStyle(fontWeight: FontWeight.bold, fontSize: 16.0), ), ), for (var contributor in contributors) Padding( padding: EdgeInsets.symmetric(horizontal: 12.0, vertical: 4.0), child: Text(contributor), ), Padding( padding: const EdgeInsets.all(12.0), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[ Text( "Want to contribute?", style: TextStyle(fontWeight: FontWeight.bold, fontSize: 16.0), ), Padding( padding: const EdgeInsets.symmetric(vertical: 8.0), child: InkWell( child: Text( "Click here", style: TextStyle(color: Colors.blue), ), onTap: () { _launchURL(); }, ), ), ], ), ), ], ), ); } _launchURL() async { const url = 'https://github.com/deven98/MetaFlutter'; if (await canLaunch(url)) { await launch(url); } else { throw 'Could not launch $url'; } } }
0
mirrored_repositories/MetaFlutter/lib
mirrored_repositories/MetaFlutter/lib/pages/widget_structure_screen.dart
import 'package:flutter/material.dart'; import 'package:flutter_app_builder/pages/result_screen.dart'; import 'package:flutter_app_builder/pages/select_widget_dialog.dart'; import 'package:flutter_app_builder/pages/tree_screen.dart'; import 'package:flutter_app_builder/utils/color_utils.dart'; import 'package:flutter_app_builder/widget_builder_utilities/model_widget.dart'; import 'package:flutter_app_builder/widget_builder_utilities/property.dart'; import 'package:unicorndial/unicorndial.dart'; import 'code_screen.dart'; import 'home_screen.dart'; class WidgetStructureScreen extends StatefulWidget { /// Root of the [ModelWidget] tree final ModelWidget root; /// The current expanded node final ModelWidget currNode; const WidgetStructureScreen({Key key, this.root, this.currNode}) : super(key: key); @override _WidgetStructureScreenState createState() => _WidgetStructureScreenState(); } class _WidgetStructureScreenState extends State<WidgetStructureScreen> { /// Root of the [ModelWidget] tree ModelWidget root; /// The current expanded node ModelWidget currNode; GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey(); @override void initState() { super.initState(); root = widget.root; currNode = widget.currNode; } @override Widget build(BuildContext context) { return Scaffold( key: _scaffoldKey, floatingActionButton: root != null ? UnicornDialer( backgroundColor: Color.fromRGBO(255, 255, 255, 0.6), parentButtonBackground: Colors.blue, orientation: UnicornOrientation.VERTICAL, parentButton: Icon(Icons.done), childButtons: [ UnicornButton( currentButton: FloatingActionButton( heroTag: "code", child: Icon(Icons.code), mini: true, onPressed: () { Navigator.push( context, MaterialPageRoute( builder: (context) => CodeScreen(root))); }, ), labelText: "Code", hasLabel: true, ), UnicornButton( currentButton: FloatingActionButton( heroTag: "build", mini: true, child: Icon(Icons.build), onPressed: () { Navigator.push( context, MaterialPageRoute( builder: (context) => ResultScreen(root.toWidget()))); }, ), labelText: "Build", hasLabel: true, ), ], ) : null, body: currNode == null ? _buildAddWidgetPage() : CustomScrollView( slivers: <Widget>[ SliverAppBar( title: Text("Build It!"), leading: IconButton( icon: Icon(Icons.clear), onPressed: _triggerExitPageDialog, ), floating: true, actions: <Widget>[ IconButton( icon: Icon(Icons.device_hub), onPressed: () { Navigator.push( context, MaterialPageRoute( builder: (context) => TreeScreen( rootWidget: root, ), ), ); }, padding: EdgeInsets.all(8.0), ), if (currNode != root) IconButton( icon: Icon(Icons.arrow_upward), onPressed: () { setState( () { if (currNode.parent != null) { currNode = currNode.parent; } else { _scaffoldKey.currentState.showSnackBar( SnackBar( content: Text("Already at the top-most widget!"), ), ); } }, ); }, padding: EdgeInsets.all(8.0), ), if (currNode == root) IconButton( icon: Icon(Icons.delete), color: Colors.red, onPressed: _triggerDeleteLayoutDialog, ), ], ), _buildInfo(), currNode.hasChildren ? _buildChildren() : SliverFillRemaining(), SliverToBoxAdapter( child: SizedBox( height: 80.0, ), ), ], ), resizeToAvoidBottomInset: true, ); } /// If root is null, this page is shown to add a widget /// TODO: Return to the home page button is not shown in this screen Widget _buildAddWidgetPage() { return Stack( children: <Widget>[ Container( decoration: BoxDecoration( gradient: LinearGradient( colors: [Colors.white, Colors.blue[200]], stops: [0.5, 1.0], begin: Alignment.topCenter, end: Alignment.bottomCenter, ), ), child: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ Text( "No widget added yet", style: TextStyle( fontSize: 20.0, fontWeight: FontWeight.w300, ), ), SizedBox( height: 20.0, ), Text( "Click here to add one", style: TextStyle(fontWeight: FontWeight.bold, fontSize: 16.0), ), IconButton( icon: Icon(Icons.add_circle_outline), color: Colors.black45, onPressed: () async { ModelWidget newWidget = await Navigator.of(context) .push(new MaterialPageRoute<ModelWidget>( builder: (BuildContext context) { return new SelectWidgetDialog(); }, fullscreenDialog: true)); setState(() { if (root == null) { root = newWidget; currNode = root; } else { currNode.addChild(newWidget); } }); }, iconSize: 60.0, ), ], ), ), ), Positioned( left: 8.0, top: 8.0, child: SafeArea( child: IconButton( icon: Icon( Icons.clear, color: Colors.black, ), onPressed: _triggerExitPageDialog, ), ), ), ], ); } /// Builds information about the [currNode] widget including properties and children Widget _buildInfo() { return SliverList( delegate: SliverChildListDelegate( [ Container( color: getColorPair(currNode).backgroundColor, child: Column( children: <Widget>[ Padding( padding: const EdgeInsets.symmetric( horizontal: 16.0, vertical: 4.0), child: currNode.parent != null ? Text("Parent: " + currNode.parent.widgetType.toString().split(".")[1]) : Container(), ), ExpansionTile( initiallyExpanded: currNode.hasChildren ? false : true, title: Text( currNode.widgetType.toString().split(".")[1], style: TextStyle(color: getColorPair(currNode).textColor), ), children: <Widget>[ if (currNode.hasProperties) Container() else Padding( padding: EdgeInsets.all(8.0), child: Text( "No properties for this widget", style: TextStyle(fontSize: 16.0), ), ), Padding( padding: const EdgeInsets.all(8.0), child: currNode.hasProperties ? _getAttributes(currNode) : Container(), ), ], ), ], ), ), currNode.hasChildren ? ListTile( title: Text( "Children", textAlign: TextAlign.center, ), trailing: Icon(Icons.add), onTap: () async { ModelWidget widget = await Navigator.of(context) .push(new MaterialPageRoute<ModelWidget>( builder: (BuildContext context) { return new SelectWidgetDialog(); }, fullscreenDialog: true)); setState( () { if (widget != null) { widget.parent = currNode; currNode.addChild(widget); } }, ); }, ) : Container(), ], ), ); } /// Builds a list of children for the [currNode] Widget _buildChildren() { return SliverList( delegate: SliverChildBuilderDelegate((context, position) { return Padding( padding: const EdgeInsets.all(4.0), child: Card( color: getColorPair(currNode.children[position]).backgroundColor, child: InkWell( onLongPress: () { _triggerRemoveChildWidgetDialog(position); }, child: ExpansionTile( title: Center( child: Text( currNode.children[position].widgetType .toString() .split(".")[1], style: TextStyle( color: getColorPair(currNode.children[position]).textColor, ), ), ), children: [ Column( children: <Widget>[ Padding( padding: const EdgeInsets.all(8.0), child: _getAttributes(currNode.children[position]), ), FlatButton( onPressed: () { setState(() { currNode = currNode.children[position]; }); }, child: Text( "Expand", style: TextStyle(color: Colors.white), ), color: Colors.blue, ) ], ), ], ), ), ), ); }, childCount: currNode.children.length), ); } /// Gets all attributes of a given [ModelWidget] Widget _getAttributes(ModelWidget widget) { Map map = widget.getParamValuesMap(); return Column( children: map.entries.map((entry) { return Row( children: <Widget>[ Expanded( child: Text( entry.key, style: TextStyle(fontWeight: FontWeight.bold), textAlign: TextAlign.center, ), flex: 3, ), Expanded( flex: 5, child: Padding( padding: const EdgeInsets.symmetric(vertical: 4.0, horizontal: 4.0), child: Property( widget.paramNameAndTypes[entry.key], (value) { setState(() { widget.params[entry.key] = value; }); }, currentValue: map[entry.key], ), ), ), ], ); }).toList(), ); } /// Dialog to delete the complete layout from root void _triggerDeleteLayoutDialog() { showDialog( context: context, builder: (context) { return AlertDialog( title: Text("Delete the entire layout?"), content: Text( "If you want to delete a child widget instead, long press on a child to delete."), actions: <Widget>[ FlatButton( onPressed: () { Navigator.pop(context); }, child: Text("Cancel")), FlatButton( onPressed: () { setState(() { root = null; currNode = null; }); Navigator.pop(context); }, child: Text("OK"), ), ], ); }, ); } /// Dialog to remove a child of the [currNode] void _triggerRemoveChildWidgetDialog(int position) { showDialog( context: context, builder: (context) { return AlertDialog( title: Text("Remove this widget and all children?"), content: Text("This action cannot be undone"), actions: <Widget>[ FlatButton( onPressed: () { Navigator.pop(context); }, child: Text("Cancel")), FlatButton( onPressed: () { if (currNode.children.length == 1) { currNode.children.remove(position); } else { int i = position; while (currNode.children[i + 1] != null) { currNode.children[i] = currNode.children[i + 1]; i++; } currNode.children.remove(currNode.children.length - 1); } setState(() {}); Navigator.pop(context); }, child: Text("OK"), ), ], ); }, ); } /// Dialog to exit to [HomeScreen] void _triggerExitPageDialog() { showDialog( context: context, builder: (context) { return AlertDialog( title: Text("Return to home screen?"), content: Text("This action cannot be undone"), actions: <Widget>[ FlatButton( onPressed: () { Navigator.pop(context); }, child: Text("Cancel")), FlatButton( onPressed: () { Navigator.of(context).pop(); Navigator.pushReplacement( context, MaterialPageRoute( builder: (context) => HomeScreen(), ), ); }, child: Text("OK"), ), ], ); }, ); } }
0
mirrored_repositories/MetaFlutter/lib
mirrored_repositories/MetaFlutter/lib/pages/home_screen.dart
import 'package:flutter/material.dart'; import 'package:flutter_app_builder/pages/widget_structure_screen.dart'; import 'about_screen.dart'; /// First page to see after splash screen. /// Keep this page as entry for main program, saved templates, etc. class HomeScreen extends StatefulWidget { @override _HomeScreenState createState() => _HomeScreenState(); } class _HomeScreenState extends State<HomeScreen> with TickerProviderStateMixin { @override void initState() { super.initState(); } @override Widget build(BuildContext context) { return Scaffold( body: Container( decoration: BoxDecoration( image: DecorationImage( image: AssetImage('images/home_bg.png'), fit: BoxFit.cover), ), child: Column( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: <Widget>[ _buildTitle(), _buildButtons(), ], ), ), ); } Widget _buildTitle() { return Row( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ Text( "Meta", style: TextStyle(color: Colors.teal, fontSize: 36.0), ), Text( "Flutter", style: TextStyle(color: Colors.blue, fontSize: 36.0), ) ], ); } Widget _buildButtons() { return Container( child: Column( children: <Widget>[ SizedBox( width: 120.0, child: FlatButton( color: Colors.blue, onPressed: () { Navigator.pushReplacement( context, MaterialPageRoute( builder: (context) => WidgetStructureScreen())); }, child: Padding( padding: const EdgeInsets.all(8.0), child: Text( "Start", style: TextStyle(color: Colors.white, fontSize: 18.0), ), ), ), ), SizedBox( height: 8.0, ), SizedBox( width: 120.0, child: FlatButton( color: Colors.blue, onPressed: () { Navigator.push(context, MaterialPageRoute(builder: (context) => AboutScreen())); }, child: Padding( padding: const EdgeInsets.all(8.0), child: Text( "About", style: TextStyle(color: Colors.white, fontSize: 18.0), ), ), ), ), ], ), ); } }
0
mirrored_repositories/MetaFlutter/lib
mirrored_repositories/MetaFlutter/lib/pages/select_widget_dialog.dart
import 'package:flutter/material.dart'; import 'package:flutter_app_builder/utils/color_utils.dart'; import 'package:flutter_app_builder/widget_builder_utilities/model_widget.dart'; /// Page for selecting widget to add to the tree class SelectWidgetDialog extends StatefulWidget { @override _SelectWidgetDialogState createState() => _SelectWidgetDialogState(); } class _SelectWidgetDialogState extends State<SelectWidgetDialog> { /// Controller for search bar TextEditingController _searchController = TextEditingController(); /// The search parameter to search widget name String searchParam = ""; @override Widget build(BuildContext context) { /// Stores result of search List<WidgetType> types = []; /// Perform search if (searchParam.trim() == "") { types = WidgetType.values; } else { WidgetType.values.forEach((type) { if (type.toString().toLowerCase().contains(searchParam.toLowerCase())) { types.add(type); } }); } return Scaffold( appBar: AppBar( title: Text("Select Widget"), ), body: ListView( children: <Widget>[ _buildSearchBar(), GridView.builder( shrinkWrap: true, physics: NeverScrollableScrollPhysics(), gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( crossAxisCount: 2, childAspectRatio: 2.0), itemBuilder: (context, position) { ColorPair pair = getColorPair(getNewModelFromType(WidgetType .values[WidgetType.values.indexOf(types[position])])); return Padding( padding: const EdgeInsets.all(4.0), child: Card( color: pair.backgroundColor, child: InkWell( onTap: () { Navigator.pop( context, getNewModelFromType(WidgetType.values[ WidgetType.values.indexOf(types[position])])); }, child: Center( child: Text( types[position].toString().split(".")[1], style: TextStyle( color: pair.textColor, fontWeight: FontWeight.w500), ), ), ), ), ); }, itemCount: types.length, ), ], ), ); } /// Builds search bar Widget _buildSearchBar() { return Container( margin: EdgeInsets.all(8.0), height: 60.0, child: Row( children: <Widget>[ Expanded( child: Padding( padding: const EdgeInsets.all(8.0), child: TextField( controller: _searchController, decoration: InputDecoration( border: OutlineInputBorder(), labelText: "Search"), ), ), flex: 4, ), Expanded( child: IconButton( icon: Icon(Icons.search), onPressed: () { setState(() { searchParam = _searchController.text.trim(); }); }, ), ), ], ), ); } }
0
mirrored_repositories/MetaFlutter/lib
mirrored_repositories/MetaFlutter/lib/pages/code_screen.dart
import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_app_builder/components/syntax_highlighter.dart'; import 'package:flutter_app_builder/widget_builder_utilities/model_widget.dart'; class CodeScreen extends StatefulWidget { final ModelWidget root; CodeScreen(this.root); @override _CodeScreenState createState() => _CodeScreenState(); } class _CodeScreenState extends State<CodeScreen> { String resultCode = ""; GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey(); @override void initState() { super.initState(); resultCode = widget.root.toCode(); } @override Widget build(BuildContext context) { return Scaffold( backgroundColor: Colors.black, key: _scaffoldKey, appBar: AppBar( title: Text("Your Layout Code"), ), body: SingleChildScrollView( child: Container( padding: EdgeInsets.all(8.0), child: RichText(text: DartSyntaxHighlighter().format(resultCode)), ), ), floatingActionButton: FloatingActionButton.extended( onPressed: () { Clipboard.setData(new ClipboardData(text: resultCode)); _scaffoldKey.currentState.showSnackBar( new SnackBar( content: new Text("Copied to Clipboard"), ), ); }, label: Text("Copy"), icon: Icon( Icons.content_copy, ), ), ); } }
0
mirrored_repositories/MetaFlutter/lib
mirrored_repositories/MetaFlutter/lib/pages/add_property_widget_dialog.dart
import 'package:flutter/material.dart'; import 'package:flutter_app_builder/pages/select_widget_dialog.dart'; import 'package:flutter_app_builder/pages/widget_structure_screen.dart'; import 'package:flutter_app_builder/widget_builder_utilities/model_widget.dart'; import 'package:flutter_app_builder/widget_builder_utilities/property.dart'; /// This page is opened when a widget is to be added a property of another widget and not a child /// TODO: NOT TESTED AS NO CURRENT WIDGET HAS WIDGET AS PROPERTY class AddPropertyWidgetDialog extends StatefulWidget { final ModelWidget widget; const AddPropertyWidgetDialog({Key key, this.widget}) : super(key: key); @override _AddPropertyWidgetDialogState createState() => _AddPropertyWidgetDialogState(); } class _AddPropertyWidgetDialogState extends State<AddPropertyWidgetDialog> { ModelWidget currNode; @override void initState() { super.initState(); currNode = widget.widget; } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text("Add widget as property"), ), floatingActionButton: FloatingActionButton.extended( onPressed: () { Navigator.pop(context, currNode); }, label: Text("Add"), icon: Icon(Icons.done), ), body: currNode == null ? _buildAddWidgetPage() : CustomScrollView( slivers: <Widget>[ SliverAppBar( title: Text("Build It!"), ), _buildInfo(), currNode.hasChildren ? _buildChildren() : SliverFillRemaining(), ], ), ); } Widget _buildChildren() { return SliverList( delegate: SliverChildBuilderDelegate((context, position) { return Card( margin: EdgeInsets.all(8.0), child: InkWell( onTap: () { Navigator.push( context, MaterialPageRoute( builder: (context) => WidgetStructureScreen())); }, child: Column( children: <Widget>[ Padding( padding: const EdgeInsets.all(8.0), child: Text(currNode.children[position].widgetType.toString()), ), Padding( padding: const EdgeInsets.all(8.0), child: _getAttributes(currNode.children[position]), ), FlatButton( onPressed: () { Navigator.push( context, MaterialPageRoute( builder: (context) => WidgetStructureScreen())); }, child: Text( "Expand", style: TextStyle(color: Colors.white), ), color: Colors.blue, ) ], ), ), ); }, childCount: currNode.children.length), ); } Widget _buildAddWidgetPage() { return Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ Text("No widget added yet"), SizedBox( height: 20.0, ), IconButton( icon: Icon(Icons.add_circle_outline), color: Colors.black45, onPressed: () async { ModelWidget newWidget = await Navigator.of(context) .push(new MaterialPageRoute<ModelWidget>( builder: (BuildContext context) { return new SelectWidgetDialog(); }, fullscreenDialog: true)); setState(() { currNode.addChild(newWidget); }); }, iconSize: 60.0, ), ], ), ); } Widget _buildInfo() { return SliverList( delegate: SliverChildListDelegate([ Padding( padding: const EdgeInsets.all(8.0), child: Text("Widget: " + currNode.widgetType.toString().split(".")[1]), ), Padding( padding: const EdgeInsets.all(8.0), child: currNode.hasProperties ? Text("Attributes:") : Container(), ), Padding( padding: const EdgeInsets.all(8.0), child: currNode.hasProperties ? _getAttributes(currNode) : Container(), ), Padding( padding: const EdgeInsets.all(8.0), child: currNode.hasChildren ? Text("Children:") : Container(), ), Padding( padding: const EdgeInsets.all(8.0), child: currNode.hasChildren ? IconButton( icon: Icon(Icons.add_circle_outline), color: Colors.black45, onPressed: () async { ModelWidget widget = await Navigator.of(context) .push(new MaterialPageRoute<ModelWidget>( builder: (BuildContext context) { return new SelectWidgetDialog(); }, fullscreenDialog: true)); setState(() { currNode.addChild(widget); }); }, iconSize: 60.0, ) : Container(), ), ])); } Widget _getAttributes(ModelWidget widget) { Map map = widget.getParamValuesMap(); return Column( children: map.entries.map((entry) { return Row( children: <Widget>[ Expanded( child: Text(entry.key), flex: 3, ), Expanded( flex: 5, child: Padding( padding: const EdgeInsets.symmetric(vertical: 4.0), child: Property(widget.paramNameAndTypes[entry.key], (value) { setState(() { widget.params[entry.key] = value; }); }, currentValue: map[entry.key]), ), ), ], ); }).toList(), ); } }
0
mirrored_repositories/MetaFlutter/lib
mirrored_repositories/MetaFlutter/lib/pages/result_screen.dart
import 'package:flutter/material.dart'; /// Displays the result of the user's selection of widgets /// TODO: Better error handling class ResultScreen extends StatefulWidget { final Widget widget; ResultScreen(this.widget); @override _ResultScreenState createState() => _ResultScreenState(); } class _ResultScreenState extends State<ResultScreen> { @override Widget build(BuildContext context) { return Stack( children: <Widget>[ Scaffold( body: widget.widget, ), SafeArea( child: Container( margin: EdgeInsets.symmetric(horizontal: 8.0), child: GestureDetector( child: Icon( Icons.clear, size: 30.0, ), onTap: () { Navigator.pop(context); }, ), ), ), ], ); } }
0
mirrored_repositories/MetaFlutter/lib
mirrored_repositories/MetaFlutter/lib/pages/tree_screen.dart
import 'package:flutter/material.dart'; import 'package:flutter_app_builder/pages/widget_structure_screen.dart'; import 'package:flutter_app_builder/utils/color_utils.dart'; import 'package:flutter_app_builder/widget_builder_utilities/model_widget.dart'; /// Displays the widget tree of the current selection of widgets of the user class TreeScreen extends StatefulWidget { /// Root widget of the tree final ModelWidget rootWidget; const TreeScreen({Key key, this.rootWidget}) : super(key: key); @override _TreeScreenState createState() => _TreeScreenState(); } class _TreeScreenState extends State<TreeScreen> { /// Stores a list of widgets at every level List<List<ModelWidget>> widgets = []; /// Stores selected widget index at every node of the tree List<int> selectedIndex = []; GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey(); ModelWidget _selectedWidget; @override void initState() { super.initState(); widgets = List.generate(100, (v) => null); widgets[0] = [widget.rootWidget]; widgets[1] = widget.rootWidget.children.values.toList(); selectedIndex = List.generate(100, (v) => -1); selectedIndex[0] = 0; } @override Widget build(BuildContext context) { return Scaffold( key: _scaffoldKey, appBar: AppBar( title: Text("Widget Tree"), ), body: _buildBody(), bottomNavigationBar: _selectedWidget != null ? BottomAppBar( child: ListTile( title: Text("Click here to navigate to widget"), trailing: InkWell( child: Text( "Go", style: TextStyle(color: Colors.blue), ), onTap: () { Navigator.pushAndRemoveUntil( context, MaterialPageRoute( builder: (context) => WidgetStructureScreen( root: this.widget.rootWidget, currNode: _selectedWidget, ), ), (val) => false, ); }, ), ), ) : Container( height: 0.0, ), ); } /// Builds widget tree Widget _buildBody() { return ListView.separated( separatorBuilder: (context, position) { return widgets[position] != null ? Container( color: Colors.black54, width: 0.5, ) : Container( color: Colors.transparent, width: 0.5, ); }, scrollDirection: Axis.horizontal, itemCount: widgets.length, itemBuilder: (context, position) { if (widgets[position] == null) { return Container(); } return Container( width: 120.0, child: ListView( children: widgets[position].map((widget) { return Row( children: <Widget>[ Expanded( child: Divider( color: Colors.black54, )), InkWell( child: Chip( label: Text(widget.widgetType.toString().split(".")[1]), backgroundColor: getColorPair(widget).backgroundColor, ), onTap: () { widgets[position + 1] = null; widgets.replaceRange( position + 1, widgets.length, List.generate( widgets.length - position + 1, (v) => null)); selectedIndex[position] = widgets[position].indexOf(widget); setState(() { widgets[position + 1] = widget.children.values.toList(); }); setState(() { _selectedWidget = widget; }); }, ), Expanded( child: Divider( color: selectedIndex[position] == widgets[position].indexOf(widget) ? Colors.black : Colors.transparent, ), ), ], ); }).toList(), ), ); }, ); } }
0
mirrored_repositories/MetaFlutter/lib
mirrored_repositories/MetaFlutter/lib/pages/splash_screen.dart
import 'package:flutter/material.dart'; import 'home_screen.dart'; /// Splash screen /// TODO: Move splash screen to Android side to initialise before Flutter app starts class SplashScreen extends StatefulWidget { @override _SplashScreenState createState() => _SplashScreenState(); } class _SplashScreenState extends State<SplashScreen> { @override void initState() { super.initState(); Future.delayed(Duration(seconds: 2)).then((val) { Navigator.pushReplacement( context, MaterialPageRoute(builder: (context) => HomeScreen())); }); } @override Widget build(BuildContext context) { return Scaffold( body: Container( color: Colors.white, child: Center( child: ClipRRect( borderRadius: BorderRadius.circular(16.0), child: Image.asset( 'images/app_logo.png', height: 100.0, width: 100.0, ), ), ), ), ); } }
0
mirrored_repositories/MetaFlutter/lib
mirrored_repositories/MetaFlutter/lib/components/selecting_text_editing_controller.dart
import 'package:flutter/material.dart'; /// Retains caret position when widget is rebuilt. Important for [Property] widgets. class SelectingTextEditingController extends TextEditingController { SelectingTextEditingController({String text}) : super(text: text) { if (text != null) setTextAndPosition(text); } void setTextAndPosition(String newText, {int caretPosition}) { int offset = caretPosition != null ? caretPosition : newText.length; value = value.copyWith( text: newText, selection: TextSelection.collapsed(offset: offset), composing: TextRange.empty); } }
0
mirrored_repositories/MetaFlutter/lib
mirrored_repositories/MetaFlutter/lib/components/syntax_highlighter.dart
import 'package:flutter/material.dart'; import 'package:string_scanner/string_scanner.dart'; class SyntaxHighlighterStyle { SyntaxHighlighterStyle({ this.baseStyle, this.numberStyle, this.commentStyle, this.keywordStyle, this.stringStyle, this.punctuationStyle, this.classStyle, this.constantStyle, }); static SyntaxHighlighterStyle lightThemeStyle() { return SyntaxHighlighterStyle( baseStyle: const TextStyle(color: Color(0xFF000000)), numberStyle: const TextStyle(color: Color(0xFF1565C0)), commentStyle: const TextStyle(color: Color(0xFF9E9E9E)), keywordStyle: const TextStyle(color: Color(0xFF9C27B0)), stringStyle: const TextStyle(color: Color(0xFF43A047)), punctuationStyle: const TextStyle(color: Color(0xFF000000)), classStyle: const TextStyle(color: Color(0xFF512DA8)), constantStyle: const TextStyle(color: Color(0xFF795548)), ); } static SyntaxHighlighterStyle darkThemeStyle() { return SyntaxHighlighterStyle( baseStyle: const TextStyle(color: Color(0xFFFFFFFF)), numberStyle: const TextStyle(color: Color(0xFF1565C0)), commentStyle: const TextStyle(color: Color(0xFF9E9E9E)), keywordStyle: const TextStyle(color: Color(0xFF80CBC4)), stringStyle: const TextStyle(color: Color(0xFF009688)), punctuationStyle: const TextStyle(color: Color(0xFFFFFFFF)), classStyle: const TextStyle(color: Color(0xFF009688)), constantStyle: const TextStyle(color: Color(0xFF795548)), ); } final TextStyle baseStyle; final TextStyle numberStyle; final TextStyle commentStyle; final TextStyle keywordStyle; final TextStyle stringStyle; final TextStyle punctuationStyle; final TextStyle classStyle; final TextStyle constantStyle; } abstract class SyntaxHighlighter { TextSpan format(String src); } class DartSyntaxHighlighter extends SyntaxHighlighter { DartSyntaxHighlighter([this._style]) { _spans = <_HighlightSpan>[]; _style ??= SyntaxHighlighterStyle.darkThemeStyle(); } SyntaxHighlighterStyle _style; static const List<String> _keywords = <String>[ 'abstract', 'as', 'assert', 'async', 'await', 'break', 'case', 'catch', 'class', 'const', 'continue', 'default', 'deferred', 'do', 'dynamic', 'else', 'enum', 'export', 'external', 'extends', 'factory', 'false', 'final', 'finally', 'for', 'get', 'if', 'implements', 'import', 'in', 'is', 'library', 'new', 'null', 'operator', 'part', 'rethrow', 'return', 'set', 'static', 'super', 'switch', 'sync', 'this', 'throw', 'true', 'try', 'typedef', 'var', 'void', 'while', 'with', 'yield', ]; static const List<String> _builtInTypes = <String>[ 'int', 'double', 'num', 'bool', ]; String _src; StringScanner _scanner; List<_HighlightSpan> _spans; @override TextSpan format(String src) { _src = src; _scanner = StringScanner(_src); if (_generateSpans()) { // Successfully parsed the code final List<TextSpan> formattedText = <TextSpan>[]; int currentPosition = 0; for (_HighlightSpan span in _spans) { if (currentPosition != span.start) formattedText .add(TextSpan(text: _src.substring(currentPosition, span.start))); formattedText.add(TextSpan( style: span.textStyle(_style), text: span.textForSpan(_src))); currentPosition = span.end; } if (currentPosition != _src.length) formattedText .add(TextSpan(text: _src.substring(currentPosition, _src.length))); return TextSpan(style: _style.baseStyle, children: formattedText); } else { // Parsing failed, return with only basic formatting return TextSpan(style: _style.baseStyle, text: src); } } bool _generateSpans() { int lastLoopPosition = _scanner.position; while (!_scanner.isDone) { // Skip White space _scanner.scan(RegExp(r'\s+')); // Block comments if (_scanner.scan(RegExp(r'/\*(.|\n)*\*/'))) { _spans.add(_HighlightSpan( _HighlightType.comment, _scanner.lastMatch.start, _scanner.lastMatch.end, )); continue; } // Line comments if (_scanner.scan('//')) { final int startComment = _scanner.lastMatch.start; bool eof = false; int endComment; if (_scanner.scan(RegExp(r'.*\n'))) { endComment = _scanner.lastMatch.end - 1; } else { eof = true; endComment = _src.length; } _spans.add(_HighlightSpan( _HighlightType.comment, startComment, endComment, )); if (eof) break; continue; } // Raw r"String" if (_scanner.scan(RegExp(r'r".*"'))) { _spans.add(_HighlightSpan( _HighlightType.string, _scanner.lastMatch.start, _scanner.lastMatch.end, )); continue; } // Raw r'String' if (_scanner.scan(RegExp(r"r'.*'"))) { _spans.add(_HighlightSpan( _HighlightType.string, _scanner.lastMatch.start, _scanner.lastMatch.end, )); continue; } // Multiline """String""" if (_scanner.scan(RegExp(r'"""(?:[^"\\]|\\(.|\n))*"""'))) { _spans.add(_HighlightSpan( _HighlightType.string, _scanner.lastMatch.start, _scanner.lastMatch.end, )); continue; } // Multiline '''String''' if (_scanner.scan(RegExp(r"'''(?:[^'\\]|\\(.|\n))*'''"))) { _spans.add(_HighlightSpan( _HighlightType.string, _scanner.lastMatch.start, _scanner.lastMatch.end, )); continue; } // "String" if (_scanner.scan(RegExp(r'"(?:[^"\\]|\\.)*"'))) { _spans.add(_HighlightSpan( _HighlightType.string, _scanner.lastMatch.start, _scanner.lastMatch.end, )); continue; } // 'String' if (_scanner.scan(RegExp(r"'(?:[^'\\]|\\.)*'"))) { _spans.add(_HighlightSpan( _HighlightType.string, _scanner.lastMatch.start, _scanner.lastMatch.end, )); continue; } // Double if (_scanner.scan(RegExp(r'\d+\.\d+'))) { _spans.add(_HighlightSpan( _HighlightType.number, _scanner.lastMatch.start, _scanner.lastMatch.end, )); continue; } // Integer if (_scanner.scan(RegExp(r'\d+'))) { _spans.add(_HighlightSpan(_HighlightType.number, _scanner.lastMatch.start, _scanner.lastMatch.end)); continue; } // Punctuation if (_scanner.scan(RegExp(r'[\[\]{}().!=<>&\|\?\+\-\*/%\^~;:,]'))) { _spans.add(_HighlightSpan( _HighlightType.punctuation, _scanner.lastMatch.start, _scanner.lastMatch.end, )); continue; } // Meta data if (_scanner.scan(RegExp(r'@\w+'))) { _spans.add(_HighlightSpan( _HighlightType.keyword, _scanner.lastMatch.start, _scanner.lastMatch.end, )); continue; } // Words if (_scanner.scan(RegExp(r'\w+'))) { _HighlightType type; String word = _scanner.lastMatch[0]; if (word.startsWith('_')) word = word.substring(1); if (_keywords.contains(word)) type = _HighlightType.keyword; else if (_builtInTypes.contains(word)) type = _HighlightType.keyword; else if (_firstLetterIsUpperCase(word)) type = _HighlightType.klass; else if (word.length >= 2 && word.startsWith('k') && _firstLetterIsUpperCase(word.substring(1))) type = _HighlightType.constant; if (type != null) { _spans.add(_HighlightSpan( type, _scanner.lastMatch.start, _scanner.lastMatch.end, )); } } // Check if this loop did anything if (lastLoopPosition == _scanner.position) { // Failed to parse this file, abort gracefully return false; } lastLoopPosition = _scanner.position; } _simplify(); return true; } void _simplify() { for (int i = _spans.length - 2; i >= 0; i -= 1) { if (_spans[i].type == _spans[i + 1].type && _spans[i].end == _spans[i + 1].start) { _spans[i] = _HighlightSpan( _spans[i].type, _spans[i].start, _spans[i + 1].end, ); _spans.removeAt(i + 1); } } } bool _firstLetterIsUpperCase(String str) { if (str.isNotEmpty) { final String first = str.substring(0, 1); return first == first.toUpperCase(); } return false; } } enum _HighlightType { number, comment, keyword, string, punctuation, klass, constant } class _HighlightSpan { _HighlightSpan(this.type, this.start, this.end); final _HighlightType type; final int start; final int end; String textForSpan(String src) { return src.substring(start, end); } TextStyle textStyle(SyntaxHighlighterStyle style) { if (type == _HighlightType.number) return style.numberStyle; else if (type == _HighlightType.comment) return style.commentStyle; else if (type == _HighlightType.keyword) return style.keywordStyle; else if (type == _HighlightType.string) return style.stringStyle; else if (type == _HighlightType.punctuation) return style.punctuationStyle; else if (type == _HighlightType.klass) return style.classStyle; else if (type == _HighlightType.constant) return style.constantStyle; else return style.baseStyle; } }
0
mirrored_repositories/MetaFlutter/lib
mirrored_repositories/MetaFlutter/lib/utils/color_utils.dart
import 'package:flutter/material.dart'; import 'package:flutter_app_builder/widget_builder_utilities/model_widget.dart'; /// Helper for color-coding the widgets /// This file helps the UI and not the properties, hence, it is separated from the property_helpers directory class ColorPair { Color textColor; Color backgroundColor; ColorPair(this.textColor, this.backgroundColor); } final backgroundColors = [ ColorPair(Colors.blue, Colors.blue[50]), ColorPair(Colors.pink, Colors.pink[50]), ColorPair(Colors.deepPurple, Colors.deepPurple[50]), ColorPair(Colors.orange, Colors.orange[50]), ColorPair(Colors.green, Colors.green[50]), ]; ColorPair getColorPair(ModelWidget widget) { switch (widget.nodeType) { case NodeType.SingleChild: return backgroundColors[4]; break; case NodeType.MultipleChildren: return backgroundColors[1]; break; case NodeType.End: return backgroundColors[0]; break; default: return null; } }
0
mirrored_repositories/MetaFlutter/lib
mirrored_repositories/MetaFlutter/lib/utils/code_utils.dart
import 'package:flutter/material.dart'; import 'package:flutter_app_builder/widget_builder_utilities/property.dart'; import 'package:flutter_app_builder/widget_builder_utilities/property_helpers/colors_helper.dart'; /// Converts parameters to string values for converting to code String paramToCode( {String paramName, @required PropertyType type, currentValue, String defaultValue, bool isNamed = true}) { String result = ""; if (isNamed) result = "$paramName: "; // If the current value is null, either return default value or return an empty string if default value is also null. if (currentValue == null) { if (defaultValue == null) { return ""; } result = result + defaultValue + ","; return result; } // If switch (type) { case PropertyType.icon: result = result + currentValue.toString(); break; case PropertyType.double: result = result + currentValue.toString(); break; case PropertyType.integer: result = result + currentValue.toString(); break; case PropertyType.string: result = result + '"' + currentValue.toString() + '"'; break; case PropertyType.mainAxisAlignment: result = result + currentValue.toString(); break; case PropertyType.crossAxisAlignment: result = result + currentValue.toString(); break; case PropertyType.widget: // TODO: Widget as a parameter is not supported in the app yet result = result + currentValue.toCode(); break; case PropertyType.color: result = result + getName(currentValue); break; case PropertyType.alignment: result = result + "Alignment." + currentValue.toString(); break; case PropertyType.boxFit: result = result + currentValue.toString(); break; case PropertyType.boolean: result = result + currentValue.toString(); break; case PropertyType.scrollPhysics: result = result + currentValue.toString() + "()"; break; case PropertyType.axis: result = result + currentValue.toString(); break; case PropertyType.fontStyle: result = result + currentValue.toString(); break; } return " " + result + ",\n"; }
0
mirrored_repositories/MetaFlutter
mirrored_repositories/MetaFlutter/test/widget_test.dart
// This is a basic Flutter widget test. // // To perform an interaction with a widget in your test, use the WidgetTester // utility that Flutter provides. For example, you can send tap and scroll // gestures. You can also use WidgetTester to find child widgets in the widget // tree, read text, and verify that the values of widget properties are correct. import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_app_builder/main.dart'; void main() { testWidgets('Counter increments smoke test', (WidgetTester tester) async { // Build our app and trigger a frame. await tester.pumpWidget(MyApp()); // Verify that our counter starts at 0. expect(find.text('0'), findsOneWidget); expect(find.text('1'), findsNothing); // Tap the '+' icon and trigger a frame. await tester.tap(find.byIcon(Icons.add)); await tester.pump(); // Verify that our counter has incremented. expect(find.text('0'), findsNothing); expect(find.text('1'), findsOneWidget); }); }
0
mirrored_repositories/ShopList/shop_list
mirrored_repositories/ShopList/shop_list/lib/main.dart
import 'package:flutter/material.dart'; void main(List<String> args) { runApp(MaterialApp( home: Home(), )); } class Home extends StatefulWidget { @override _HomeState createState() => _HomeState(); } class _HomeState extends State<Home> { @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text("Lista de Compras"), backgroundColor: Colors.indigo[900], centerTitle: true, actions: <Widget>[ IconButton( icon: Icon(Icons.add_circle_outline), iconSize: 35.0, disabledColor: Color.fromRGBO(200, 200, 255, 20), onPressed: _newItemMenu, ) ], ), ); } Future _newItemMenu(){ return showDialog( context: context, builder: (BuildContext context){ return AlertDialog( backgroundColor: Color.fromRGBO(240, 240, 255, 20), title: Text("Cadastrar novo item"), titleTextStyle: TextStyle(fontSize: 15.0, color: Colors.black), ); }, ); } }
0
mirrored_repositories/agenda_de_contatos/contact_book_mobile
mirrored_repositories/agenda_de_contatos/contact_book_mobile/lib/main.dart
import 'package:contact_book_mobile/core/controllers/auth_controller.dart'; import 'package:contact_book_mobile/core/controllers/contact_controller.dart'; import 'package:contact_book_mobile/core/controllers/user_controller.dart'; import 'package:contact_book_mobile/views/add_object_view/page/add_object.dart'; import 'package:contact_book_mobile/views/contact_view/page/contact_view.dart'; import 'package:contact_book_mobile/views/home_view/page/home_page.dart'; import 'package:contact_book_mobile/views/login_view/page/login_screen.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; void main() { runApp(MyApp()); } class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { // A provider is a wrapper around InheritedWidget to make them easier to use and more reusable return MultiProvider( providers: [ ChangeNotifierProvider(create: (_) => AuthController()), ChangeNotifierProvider(create: (_) => UserController()), ChangeNotifierProvider(create: (_) => ContactController()), ], child: MaterialApp( title: 'Contact Book', debugShowCheckedModeBanner: false, initialRoute: '/', // All routes to app main pages routes: { '/': (context) => Login(), // These routes depend on specific parameters for calls // '/second': Home Home.routeName: (context) => Home(), // '/third': AddObjectView AddObjectView.routeName: (context) => AddObjectView(), '/fourth': (context) => ContactView(), }, ), ); } }
0
mirrored_repositories/agenda_de_contatos/contact_book_mobile/lib/shared
mirrored_repositories/agenda_de_contatos/contact_book_mobile/lib/shared/colors/colors.dart
import 'package:flutter/material.dart'; // All application default colors const Color defaultWhite = Colors.white; const Color lightBlue = Color(0xff00BCD4); const Color defaultBlue = Color(0xff3fa1ff); const Color darkBlue = Color(0xff031019);
0
mirrored_repositories/agenda_de_contatos/contact_book_mobile/lib/shared
mirrored_repositories/agenda_de_contatos/contact_book_mobile/lib/shared/widgets/default_text.dart
import 'package:contact_book_mobile/shared/colors/colors.dart'; import 'package:flutter/material.dart'; import 'package:google_fonts/google_fonts.dart'; // Simple Text widget with Google style font class DefaultText extends StatelessWidget { final String text; final Color fontColor; final double fontSize; final TextAlign textAlign; DefaultText(this.text, {this.fontColor = darkBlue, this.fontSize = 16.0, this.textAlign = TextAlign.start}); @override Widget build(BuildContext context) { return Text( text, textAlign: textAlign, style: GoogleFonts.lato( color: fontColor, fontSize: fontSize, fontWeight: FontWeight.w600), ); } }
0
mirrored_repositories/agenda_de_contatos/contact_book_mobile/lib/views/login_view
mirrored_repositories/agenda_de_contatos/contact_book_mobile/lib/views/login_view/widgets/sign_in_widget.dart
import 'package:contact_book_mobile/shared/colors/colors.dart'; import 'package:contact_book_mobile/shared/widgets/default_text.dart'; import 'package:contact_book_mobile/views/login_view/data/login_services.dart'; import 'package:flutter/material.dart'; import 'package:fluttertoast/fluttertoast.dart'; import 'package:google_fonts/google_fonts.dart'; class SignInWidget extends StatefulWidget { const SignInWidget({Key? key}) : super(key: key); @override _SignInWidgetState createState() => _SignInWidgetState(); } class _SignInWidgetState extends State<SignInWidget> { final formKey = GlobalKey<FormState>(); String? name = ''; String? email = ''; String? password = ''; static bool showPassword = false; @override Widget build(BuildContext context) { return Scaffold( backgroundColor: Color.fromRGBO(0, 0, 0, 0.1), body: SimpleDialog( contentPadding: EdgeInsets.all(0), shape: RoundedRectangleBorder( side: BorderSide(width: 0.5, color: darkBlue), borderRadius: new BorderRadius.circular(10.0)), children: <Widget>[ Container( margin: EdgeInsets.all(0), height: 50, decoration: BoxDecoration( borderRadius: new BorderRadius.only( topLeft: const Radius.circular(10.0), topRight: const Radius.circular(10.0)), color: darkBlue, ), child: Center( child: Row( children: [ IconButton( onPressed: () => Navigator.of(context).pop(), icon: Icon( Icons.arrow_back, color: defaultWhite, size: 20.0, )), DefaultText( "ContactsBook Sign In", fontColor: defaultWhite, ), ], )), ), Container( height: 260.0, child: SingleChildScrollView( child: Form( key: formKey, child: Container( child: Column( children: [ Padding( padding: const EdgeInsets.all(10.0), child: Container( width: 250, height: 50.0, child: TextFormField( validator: (value) { if (value!.isEmpty) return 'Enter with a name'; }, decoration: InputDecoration( filled: true, fillColor: defaultWhite, enabledBorder: OutlineInputBorder( borderSide: BorderSide(color: darkBlue), borderRadius: BorderRadius.circular(50.0), ), border: OutlineInputBorder( borderSide: BorderSide(color: darkBlue), borderRadius: BorderRadius.circular(50.0), ), labelText: 'Name', labelStyle: GoogleFonts.lato( color: darkBlue, fontSize: 18.0, fontWeight: FontWeight.w600)), onSaved: (value) => setState(() => name = value!), ), ), ), Padding( padding: const EdgeInsets.all(10.0), child: Container( width: 250, height: 50.0, child: TextFormField( keyboardType: TextInputType.emailAddress, validator: (value) { // Validator to enter with a valid email final pattern = r'(^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$)'; final regExp = RegExp(pattern); if (value!.isEmpty) return 'Enter with an email'; else if (value != '') { if (!regExp.hasMatch(value)) { return 'Enter with a valid email'; } else { return null; } } }, decoration: InputDecoration( filled: true, fillColor: defaultWhite, enabledBorder: OutlineInputBorder( borderSide: BorderSide(color: darkBlue), borderRadius: BorderRadius.circular(50.0), ), border: OutlineInputBorder( borderSide: BorderSide(color: darkBlue), borderRadius: BorderRadius.circular(50.0), ), labelText: 'Email', labelStyle: GoogleFonts.lato( color: darkBlue, fontSize: 18.0, fontWeight: FontWeight.w600)), onSaved: (value) => setState(() => email = value!), ), ), ), Padding( padding: const EdgeInsets.all(10.0), child: Container( width: 250, height: 50.0, child: TextFormField( validator: (value) { if (value!.isEmpty) return 'Enter with a password'; }, decoration: InputDecoration( filled: true, fillColor: defaultWhite, enabledBorder: OutlineInputBorder( borderSide: BorderSide(color: darkBlue), borderRadius: BorderRadius.circular(50.0), ), border: OutlineInputBorder( borderSide: BorderSide(color: darkBlue), borderRadius: BorderRadius.circular(50.0), ), labelText: 'Password', labelStyle: GoogleFonts.lato( color: darkBlue, fontSize: 18.0, fontWeight: FontWeight.w600), suffixIcon: IconButton( iconSize: 16.0, color: darkBlue, icon: Icon(showPassword ? Icons.visibility : Icons.visibility_off), onPressed: () { setState(() { showPassword = !showPassword; }); }, ), ), onSaved: (value) => setState(() => password = value!), obscureText: !showPassword, obscuringCharacter: "*", ), ), ), Container( height: 40.0, width: 150.0, child: ElevatedButton( onPressed: () { final isValid = formKey.currentState!.validate(); if (isValid) { formKey.currentState!.save(); onSigInSubmit(name, email, password); } }, child: DefaultText( 'Sign In Now!', fontColor: defaultWhite, ), style: ElevatedButton.styleFrom( primary: darkBlue, ), ), ) ], ), ), ), ), ), ], ), ); } Future<void> onSigInSubmit( String? name, String? email, String? password) async { try { var resp = await LoginServices().createUser(name, email, password); Fluttertoast.showToast( msg: resp['message'], toastLength: Toast.LENGTH_SHORT, gravity: ToastGravity.BOTTOM, timeInSecForIosWeb: 1, backgroundColor: resp['status'] ? Colors.green : Colors.red, textColor: Colors.white, fontSize: 10.0); if (resp['status']) Navigator.pop(context); } catch (error) { print(error); } } }
0
mirrored_repositories/agenda_de_contatos/contact_book_mobile/lib/views/login_view
mirrored_repositories/agenda_de_contatos/contact_book_mobile/lib/views/login_view/widgets/custom_form_field.dart
import 'package:contact_book_mobile/shared/colors/colors.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:google_fonts/google_fonts.dart'; // ignore: must_be_immutable class CustomFormField extends StatefulWidget { bool isPassword; TextEditingController controller; CustomFormField({required this.controller, required this.isPassword}); @override CustomFormFieldState createState() { return CustomFormFieldState(); } } class CustomFormFieldState extends State<CustomFormField> { static bool showPassword = false; @override Widget build(BuildContext context) { return ConstrainedBox( constraints: BoxConstraints( maxHeight: 45.0, minHeight: 30.0, maxWidth: 300.0, minWidth: 200.0, ), child: Container( child: TextFormField( controller: widget.controller, style: GoogleFonts.lato( color: darkBlue, fontSize: 16.0, fontWeight: FontWeight.w400, ), decoration: InputDecoration( hintText: widget.isPassword ? "Password" : "Email", labelText: widget.isPassword ? "Password" : "Email", filled: true, prefixIcon: widget.isPassword ? Icon( Icons.lock, size: 16.0, color: darkBlue, ) : Icon( Icons.verified_user_rounded, size: 16.0, color: darkBlue, ), suffixIcon: widget.isPassword ? IconButton( iconSize: 16.0, color: darkBlue, icon: Icon( showPassword ? Icons.visibility : Icons.visibility_off), onPressed: () { setState(() { showPassword = !showPassword; }); }, ) : null, fillColor: defaultWhite, enabledBorder: OutlineInputBorder( borderSide: BorderSide(color: darkBlue), borderRadius: BorderRadius.circular(50.0), ), focusedBorder: OutlineInputBorder( borderSide: BorderSide(color: defaultBlue), borderRadius: BorderRadius.circular(50.0), ), contentPadding: EdgeInsets.only(top: 5.0, left: 15.0), ), obscureText: widget.isPassword ? !showPassword : false, obscuringCharacter: "*", ), ), ); } }
0
mirrored_repositories/agenda_de_contatos/contact_book_mobile/lib/views/login_view
mirrored_repositories/agenda_de_contatos/contact_book_mobile/lib/views/login_view/page/login_screen.dart
import 'package:contact_book_mobile/core/controllers/auth_controller.dart'; import 'package:contact_book_mobile/core/controllers/people_api_controller.dart'; import 'package:contact_book_mobile/core/controllers/user_controller.dart'; import 'package:contact_book_mobile/core/models/helpers/google_login.dart'; import 'package:contact_book_mobile/core/models/people_api.dart'; import 'package:contact_book_mobile/core/models/user.dart'; import 'package:contact_book_mobile/shared/colors/colors.dart'; import 'package:contact_book_mobile/shared/widgets/default_text.dart'; import 'package:contact_book_mobile/views/home_view/page/home_page.dart'; import 'package:contact_book_mobile/views/login_view/data/login_services.dart'; import 'package:contact_book_mobile/views/login_view/widgets/custom_form_field.dart'; import 'package:contact_book_mobile/views/login_view/widgets/sign_in_widget.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_svg/svg.dart'; import 'package:fluttertoast/fluttertoast.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:google_sign_in/google_sign_in.dart'; // This file contains the entire page and call your widgets class Login extends StatefulWidget { const Login({Key? key}) : super(key: key); @override _LoginState createState() => _LoginState(); } class _LoginState extends State<Login> { TextEditingController emailController = TextEditingController(); TextEditingController passwordController = TextEditingController(); // It's necessary enable People Api to login: // https://console.cloud.google.com/apis/library/people.googleapis.com GoogleSignIn? _googleSignIn; GoogleSignInAccount? _currentUser; GoogleContacts? contacts; @override void initState() { super.initState(); // GoogleSigIn object to access contacts // See all possible scopes by the link // https://developers.google.com/identity/protocols/oauth2/scopes#people // /auth/contacts.readonly: "See and download your contacts" // /auth/contacts: "See, edit, download, and permanently delete your contacts" _googleSignIn = GoogleSignIn(scopes: [ "https://www.googleapis.com/auth/contacts", ]); // Get the users to Sign In _googleSignIn!.onCurrentUserChanged.listen((user) async { setState(() { _currentUser = user!; }); // With a user you can now login with your Google account if (user != null) { contacts = await LoginServices().getGoogleContacts(_currentUser); } }); } @override Widget build(BuildContext context) { return Material( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Column( children: [ Text( "Your Contact's Book", style: GoogleFonts.pacifico(color: darkBlue, fontSize: 30.0), ), SvgPicture.asset( 'assets/images/login_img.svg', height: 150.0, ), ], ), Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Padding( padding: const EdgeInsets.only(bottom: 8.0, top: 50.0), child: CustomFormField( controller: emailController, isPassword: false), ), Padding( padding: const EdgeInsets.all(8.0), child: CustomFormField( controller: passwordController, isPassword: true), ), Padding( padding: const EdgeInsets.only(right: 11.0), child: IconButton( alignment: Alignment.center, icon: Icon( Icons.arrow_forward_rounded, color: darkBlue, size: 40.0, ), onPressed: () => onLoginSubmit( emailController.text, passwordController.text), ), ), ], ), Padding(padding: EdgeInsets.all(8.0)), Container( height: 40.0, width: 180.0, child: ElevatedButton( onPressed: () => showDialog( context: context, builder: (context) => SignInWidget(), ), style: ElevatedButton.styleFrom(primary: darkBlue), child: DefaultText( "Sign in", fontSize: 15.0, fontColor: defaultWhite, ), ), ), Padding(padding: EdgeInsets.all(8.0)), Container( height: 40.0, width: 180.0, child: ElevatedButton.icon( icon: SvgPicture.asset( 'assets/images/google_icon.svg', height: 30.0, ), onPressed: () async { await onLoginWithGoogle(); try { // If click out the alert will be throw an Exception // Then it's be necessary choose an account or create one // Issue on cancel login https://github.com/flutter/flutter/issues/44431 await _googleSignIn!.signIn(); } on Exception catch (error) { print(error); } }, style: ElevatedButton.styleFrom(primary: defaultWhite), label: DefaultText( "Google Sign In", fontSize: 15.0, fontColor: darkBlue, ), ), ), ], ), ); } // On comunm login Future<void> onLoginSubmit(String email, String password) async { try { // Login service is called var resp = await LoginServices().login(email, password); if (resp['status']) { User user = User.fromJson(resp['user']); // The token is added to the AuthController AuthController.instance.addToken(resp['token']); // The user is added to the UserController UserController.instance.addUser(user); // Go to home page as comun login GoogleLogin args = GoogleLogin(isGoogleLogin: false); Navigator.of(context).pushNamed(Home.routeName, arguments: args); } else { Fluttertoast.showToast( msg: resp['message'], toastLength: Toast.LENGTH_SHORT, gravity: ToastGravity.BOTTOM, timeInSecForIosWeb: 1, backgroundColor: Colors.red, textColor: Colors.white, fontSize: 10.0); } } catch (error) { print(error); } } Future<void> onLoginWithGoogle() async { // Without authentication and permission will get an error to login // https: //console.firebase.google.com/.../authentication/providers if (contacts != null) { PeopleApiController.instance.addCurrentSignIn(_googleSignIn!); PeopleApiController.instance.addCurrentUser(_currentUser!); PeopleApiController.instance.addContacts(contacts!); GoogleLogin args = GoogleLogin(isGoogleLogin: true); Navigator.of(context).pushNamed(Home.routeName, arguments: args); Fluttertoast.showToast( msg: 'Your Google account has been successfully linked', toastLength: Toast.LENGTH_SHORT, gravity: ToastGravity.BOTTOM, timeInSecForIosWeb: 1, backgroundColor: Colors.green, textColor: Colors.white, fontSize: 10.0); } } }
0
mirrored_repositories/agenda_de_contatos/contact_book_mobile/lib/views/login_view
mirrored_repositories/agenda_de_contatos/contact_book_mobile/lib/views/login_view/data/login_services.dart
import 'package:contact_book_mobile/core/models/people_api.dart'; import 'package:contact_book_mobile/core/services/people_api_services.dart'; import 'package:contact_book_mobile/core/services/user_services.dart'; import 'package:google_sign_in/google_sign_in.dart'; // This file contains just the services calls used in LoginScreen main page and their widgets class LoginServices { Future<dynamic> login(String email, String password) async { return await UserServices().login(email, password); } Future<dynamic> createUser( String? name, String? email, String? password) async { return await UserServices().createUser(name, email, password); } Future<GoogleContacts?> getGoogleContacts( GoogleSignInAccount? currentUser) async { return await PeopleApiServices().getGoogleContacts(currentUser!); } }
0
mirrored_repositories/agenda_de_contatos/contact_book_mobile/lib/views/home_view
mirrored_repositories/agenda_de_contatos/contact_book_mobile/lib/views/home_view/widgets/people_api_widget.dart
import 'package:contact_book_mobile/core/controllers/people_api_controller.dart'; import 'package:contact_book_mobile/core/models/people_api.dart'; import 'package:flutter/material.dart'; class PeopleApiWidget extends StatefulWidget { const PeopleApiWidget({Key? key}) : super(key: key); @override _PeopleApiWidgetState createState() => _PeopleApiWidgetState(); } class _PeopleApiWidgetState extends State<PeopleApiWidget> { @override Widget build(BuildContext context) { GoogleContacts? contacts = PeopleApiController.instance.contacts; return ListView.separated( itemBuilder: (BuildContext context, int index) { final currentContact = contacts!.connections[index]; return ListTile( leading: Container( width: 40.0, height: 40.0, // Catch image from https://picsum.photos/ child: ClipOval( child: Image.network('https://picsum.photos/id/${index + 30}/200'), ), ), title: Text("${currentContact.names!.first.displayName}"), subtitle: Text("${currentContact.phoneNumbers!.first.value}"), ); }, separatorBuilder: (context, index) => Divider(), itemCount: contacts!.connections.length, ); } }
0
mirrored_repositories/agenda_de_contatos/contact_book_mobile/lib/views/home_view
mirrored_repositories/agenda_de_contatos/contact_book_mobile/lib/views/home_view/widgets/add_group_widget.dart
import 'package:contact_book_mobile/core/controllers/auth_controller.dart'; import 'package:contact_book_mobile/core/controllers/user_controller.dart'; import 'package:contact_book_mobile/shared/colors/colors.dart'; import 'package:contact_book_mobile/shared/widgets/default_text.dart'; import 'package:contact_book_mobile/views/home_view/data/home_services.dart'; import 'package:flutter/material.dart'; import 'package:fluttertoast/fluttertoast.dart'; import 'package:google_fonts/google_fonts.dart'; class AddGroupWidget extends StatefulWidget { const AddGroupWidget({Key? key}) : super(key: key); @override _AddGroupWidgetState createState() => _AddGroupWidgetState(); } class _AddGroupWidgetState extends State<AddGroupWidget> { final formKey = GlobalKey<FormState>(); String? name = ''; @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text('Create a group'), backgroundColor: darkBlue, ), body: Container( color: defaultWhite, child: Center( child: Form( key: formKey, child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Container( width: MediaQuery.of(context).size.width * 0.8, height: 60.0, child: TextFormField( validator: (value) { if (value!.isEmpty) return 'Enter with a name for the group'; }, style: GoogleFonts.lato( color: darkBlue, fontSize: 18.0, fontWeight: FontWeight.w600), decoration: InputDecoration( filled: true, fillColor: defaultWhite, enabledBorder: OutlineInputBorder( borderSide: BorderSide(color: darkBlue), borderRadius: BorderRadius.circular(50.0), ), border: OutlineInputBorder( borderSide: BorderSide(color: darkBlue), borderRadius: BorderRadius.circular(50.0), ), labelText: 'Group name', labelStyle: GoogleFonts.lato( color: darkBlue, fontSize: 18.0, fontWeight: FontWeight.w600)), onSaved: (value) => setState(() => name = value!), ), ), Row( mainAxisAlignment: MainAxisAlignment.end, children: [ Padding( padding: const EdgeInsets.only(right: 40.0), child: ElevatedButton( onPressed: () async { final isValid = formKey.currentState!.validate(); if (isValid) { formKey.currentState!.save(); String body = '{"name":"$name"}'; var resp; int? userId = UserController.instance.user.id; String? token = AuthController.instance.token; try { resp = await HomePageServices() .createGroup(userId, body, token); Fluttertoast.showToast( msg: resp['message'], toastLength: Toast.LENGTH_SHORT, gravity: ToastGravity.BOTTOM, timeInSecForIosWeb: 1, backgroundColor: resp['status'] ? Colors.green : Colors.red, textColor: Colors.white, fontSize: 10.0); if (resp['status']) Navigator.pop(context); } catch (error) { print(error); } } }, child: DefaultText( 'Create!', fontSize: 18.0, fontColor: defaultWhite, ), style: ElevatedButton.styleFrom(primary: darkBlue), ), ) ], ) ], ), ), ), ), ); } }
0
mirrored_repositories/agenda_de_contatos/contact_book_mobile/lib/views/home_view
mirrored_repositories/agenda_de_contatos/contact_book_mobile/lib/views/home_view/widgets/groups_tab.dart
import 'package:contact_book_mobile/core/controllers/auth_controller.dart'; import 'package:contact_book_mobile/core/controllers/group_controller.dart'; import 'package:contact_book_mobile/core/controllers/user_controller.dart'; import 'package:contact_book_mobile/core/models/group.dart'; import 'package:contact_book_mobile/core/models/user.dart'; import 'package:contact_book_mobile/shared/colors/colors.dart'; import 'package:contact_book_mobile/shared/widgets/default_text.dart'; import 'package:contact_book_mobile/views/home_view/data/home_services.dart'; import 'package:contact_book_mobile/views/home_view/widgets/group_members_widget.dart'; import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:fluttertoast/fluttertoast.dart'; class GroupsTab extends StatefulWidget { const GroupsTab({Key? key}) : super(key: key); @override _GroupsTabState createState() => _GroupsTabState(); } class _GroupsTabState extends State<GroupsTab> { User user = UserController.instance.user; String? token = AuthController.instance.token; late List<Group> groups = []; @override Widget build(BuildContext context) { return Container( color: defaultWhite, child: FutureBuilder( future: HomePageServices().getAllGroupsByUserId(user.id, token), builder: (BuildContext context, AsyncSnapshot snapshot) { if (snapshot.hasData) { return RefreshIndicator( backgroundColor: darkBlue, color: defaultWhite, strokeWidth: 2.0, onRefresh: () async { setState(() {}); }, child: snapshot.data.length == 0 ? Center( child: ConstrainedBox( constraints: BoxConstraints( maxHeight: 300.0, minHeight: 200.0, maxWidth: MediaQuery.of(context).size.width * 0.8, minWidth: MediaQuery.of(context).size.width * 0.5, ), child: Center( child: Column( children: [ SvgPicture.asset( 'assets/images/any_group_img.svg', height: 150.0, ), Padding(padding: EdgeInsets.all(8.0)), DefaultText( "You don't have any group yet try to create one!", fontSize: 23.0, textAlign: TextAlign.center, ), IconButton( onPressed: () { setState(() {}); }, icon: Icon( Icons.refresh_outlined, color: darkBlue, ), ) ], ), ), ), ) : Padding( padding: const EdgeInsets.only(top: 8.0), child: ListView.builder( itemCount: snapshot.data.length, itemBuilder: (BuildContext context, int index) { return Container( width: MediaQuery.of(context).size.width * 0.8, child: Column( children: [ ListTile( leading: ConstrainedBox( constraints: BoxConstraints( maxHeight: 60.0, maxWidth: 60.0, minHeight: 40.0, minWidth: 40.0, ), child: ClipOval( child: Image.network( 'https://picsum.photos/id/${snapshot.data[index].id + 20}/200'), ), ), title: DefaultText( "${snapshot.data[index].name}", ), onTap: () { GroupController.instance .addGroup(snapshot.data[index]); showDialog( context: context, builder: (context) => GroupMembersWidget( isAdding: false)); }, trailing: Container( height: 50.0, width: 100.0, child: Row( mainAxisSize: MainAxisSize.min, children: [ IconButton( onPressed: () { GroupController.instance .addGroup(snapshot.data[index]); showDialog( context: context, builder: (context) => GroupMembersWidget( isAdding: true)); }, icon: Icon( Icons.person_add_alt_1, color: darkBlue, size: 20.0, ), ), IconButton( onPressed: () => _showDialog( context, snapshot.data[index].id), icon: Icon( Icons.delete, color: darkBlue, size: 20.0, ), ), ], ), ), ), Container( width: MediaQuery.of(context).size.width * 0.9, child: Divider( color: darkBlue, thickness: 1.1, ), ), ], ), ); }, ), ), ); } else { return Center( child: CircularProgressIndicator( backgroundColor: defaultWhite, color: darkBlue, strokeWidth: 2.0, )); } }, ), ); } void _showDialog(BuildContext context, int? groupId) { showDialog( context: context, builder: (BuildContext context) { return AlertDialog( backgroundColor: darkBlue, title: DefaultText( "Alert!", fontColor: defaultWhite, fontSize: 25.0, ), content: DefaultText( "Do you really want to delete this group?", fontColor: defaultWhite, ), actions: <Widget>[ TextButton( onPressed: () => Navigator.pop(context), child: DefaultText( 'No', fontSize: 20, fontColor: defaultWhite, ), ), TextButton( onPressed: () { deleteGroup(groupId); Navigator.of(context).pop(); }, child: DefaultText( 'Yes', fontSize: 20, fontColor: defaultWhite, ), ), ], ); }, ); } Future<void> deleteGroup(int? groupId) async { try { var resp = await HomePageServices().deleteGroup(groupId, token); Fluttertoast.showToast( msg: resp['message'], toastLength: Toast.LENGTH_SHORT, gravity: ToastGravity.BOTTOM, timeInSecForIosWeb: 1, backgroundColor: resp['status'] ? Colors.green : Colors.red, textColor: Colors.white, fontSize: 10.0); if (resp['status']) setState(() {}); } catch (error) { print(error); } } }
0
mirrored_repositories/agenda_de_contatos/contact_book_mobile/lib/views/home_view
mirrored_repositories/agenda_de_contatos/contact_book_mobile/lib/views/home_view/widgets/custom_fab.dart
import 'dart:math'; import 'package:contact_book_mobile/core/models/helpers/screen_arguments.dart'; import 'package:contact_book_mobile/shared/colors/colors.dart'; import 'package:contact_book_mobile/views/add_object_view/page/add_object.dart'; import 'package:contact_book_mobile/views/home_view/widgets/add_group_widget.dart'; import 'package:flutter/material.dart'; class CustomFab extends StatefulWidget { const CustomFab({Key? key}) : super(key: key); @override _CustomFabState createState() => _CustomFabState(); } class _CustomFabState extends State<CustomFab> with SingleTickerProviderStateMixin { static bool toggle = true; late AnimationController controller; late Animation<double> animation; Alignment addPersonAlignment = Alignment(0.0, 0.0); Alignment addGroupAlignment = Alignment(0.0, 0.0); @override void initState() { super.initState(); controller = AnimationController( vsync: this, duration: Duration(milliseconds: 250), reverseDuration: Duration(milliseconds: 175)); animation = CurvedAnimation( parent: controller, curve: Curves.easeOut, reverseCurve: Curves.easeIn); controller.addListener(() { setState(() {}); }); } @override void dispose() { super.dispose(); } @override Widget build(BuildContext context) { return Align( alignment: FractionalOffset.bottomRight, child: Container( height: 250.0, width: 70.0, child: Stack( children: [ AnimatedAlign( alignment: addPersonAlignment + Alignment.bottomCenter, curve: toggle ? Curves.easeIn : Curves.elasticOut, duration: toggle ? Duration(milliseconds: 175) : Duration(milliseconds: 775), child: AnimatedContainer( duration: Duration(milliseconds: 375), curve: toggle ? Curves.easeIn : Curves.easeOut, height: 50.0, width: 50.0, decoration: BoxDecoration( color: darkBlue, borderRadius: BorderRadius.circular(40.0), boxShadow: [ BoxShadow( color: Colors.grey.withOpacity(0.8), spreadRadius: 1.0, blurRadius: 5.0, offset: Offset(0.0, 0.0), // changes position of shadow ), ], ), child: Material( color: Colors.transparent, borderRadius: BorderRadius.circular(40.0), child: IconButton( splashColor: Colors.black54, splashRadius: 31.0, tooltip: "Add a new contact", icon: Icon( Icons.person_add_alt_1, color: defaultWhite, size: 21.0, ), onPressed: () { ScreenArguments args = ScreenArguments(contactId: 0, isAddingContact: true); Navigator.of(context) .pushNamed(AddObjectView.routeName, arguments: args); }, ), ), ), ), AnimatedAlign( alignment: addGroupAlignment + Alignment.bottomCenter, curve: toggle ? Curves.easeIn : Curves.elasticOut, duration: toggle ? Duration(milliseconds: 175) : Duration(milliseconds: 775), child: AnimatedContainer( duration: Duration(milliseconds: 275), curve: toggle ? Curves.easeIn : Curves.easeOut, height: 50.0, width: 50.0, decoration: BoxDecoration( color: darkBlue, borderRadius: BorderRadius.circular(40.0), boxShadow: [ BoxShadow( color: Colors.grey.withOpacity(0.8), spreadRadius: 1.0, blurRadius: 5.0, offset: Offset(0.0, 0.0), // changes position of shadow ), ], ), child: Material( color: Colors.transparent, borderRadius: BorderRadius.circular(40.0), child: IconButton( splashColor: Colors.black54, splashRadius: 31.0, tooltip: "Add a new group", icon: Icon( Icons.group_add, color: defaultWhite, size: 21.0, ), onPressed: () { showModalBottomSheet<void>( context: context, builder: (BuildContext context) { return AddGroupWidget(); }, ); }, ), ), ), ), Align( alignment: Alignment.bottomCenter, child: Transform.rotate( angle: animation.value * pi * (3 / 4), child: AnimatedContainer( duration: Duration(milliseconds: 275), curve: Curves.easeOut, height: 65.0, width: 65.0, decoration: BoxDecoration( color: darkBlue, borderRadius: BorderRadius.circular(60.0), boxShadow: [ BoxShadow( color: Colors.grey.withOpacity(0.8), spreadRadius: 2.0, blurRadius: 4.0, offset: Offset(0.0, 0.0), // changes position of shadow ), ], ), child: Material( color: Colors.transparent, child: IconButton( splashColor: Colors.black54, splashRadius: 31.0, onPressed: () { if (!toggle) { toggle = !toggle; controller.forward(); Future.delayed(Duration(milliseconds: 50), () { addGroupAlignment = Alignment(0.0, -0.75); }); Future.delayed(Duration(milliseconds: 100), () { addPersonAlignment = Alignment(0.0, -1.3); }); } else { toggle = !toggle; controller.reverse(); addPersonAlignment = Alignment(0.0, 0.0); addGroupAlignment = Alignment(0.0, 0.0); } }, icon: Icon( Icons.add, color: defaultWhite, size: 27.0, )), )), ), ) ], ), ), ); } }
0
mirrored_repositories/agenda_de_contatos/contact_book_mobile/lib/views/home_view
mirrored_repositories/agenda_de_contatos/contact_book_mobile/lib/views/home_view/widgets/contacts_tab.dart
import 'package:contact_book_mobile/core/controllers/auth_controller.dart'; import 'package:contact_book_mobile/core/controllers/contact_controller.dart'; import 'package:contact_book_mobile/core/controllers/user_controller.dart'; import 'package:contact_book_mobile/core/models/contact.dart'; import 'package:contact_book_mobile/shared/colors/colors.dart'; import 'package:contact_book_mobile/shared/widgets/default_text.dart'; import 'package:contact_book_mobile/views/home_view/data/home_services.dart'; import 'package:contact_book_mobile/views/home_view/widgets/people_api_widget.dart'; import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:google_fonts/google_fonts.dart'; // ignore: must_be_immutable class ContactsTab extends StatefulWidget { bool isGoogleLogin = false; ContactsTab({Key? key, required this.isGoogleLogin}) : super(key: key); @override _ContactsTabState createState() => _ContactsTabState(); } class _ContactsTabState extends State<ContactsTab> { TextEditingController searchInputController = TextEditingController(); late List<Contact> contacts = []; late List<Contact> foudContacts = []; @override void dispose() { searchInputController.dispose(); super.dispose(); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( backgroundColor: darkBlue, automaticallyImplyLeading: false, title: Container( height: 33.0, child: TextField( controller: searchInputController, onChanged: onSearchTextChanged, style: GoogleFonts.lato( color: darkBlue, fontSize: 13.0, fontWeight: FontWeight.w600), decoration: InputDecoration( filled: true, suffixIcon: IconButton( onPressed: () { setState(() { if (!isControllerEmpty()) { searchInputController.clear(); foudContacts = contacts; } }); }, icon: isControllerEmpty() ? Icon(Icons.search) : Icon(Icons.search_off), iconSize: 20.0, padding: EdgeInsets.only(bottom: 2.0), color: darkBlue, ), fillColor: defaultWhite, enabledBorder: OutlineInputBorder( borderSide: BorderSide(color: defaultWhite), borderRadius: BorderRadius.circular(50.0), ), focusedBorder: OutlineInputBorder( borderSide: BorderSide(color: defaultWhite), borderRadius: BorderRadius.circular(50.0), ), contentPadding: EdgeInsets.only(top: 5.0, left: 15.0), hintText: "Search for a contact", )), ), ), body: Container( child: widget.isGoogleLogin ? PeopleApiWidget() : FutureBuilder( future: HomePageServices().getAllContactsByUserId( UserController.instance.user.id, AuthController.instance.token), builder: (BuildContext context, AsyncSnapshot snapshot) { if (snapshot.hasData) { contacts = snapshot.data; return RefreshIndicator( backgroundColor: darkBlue, color: defaultWhite, strokeWidth: 2.0, onRefresh: () async { setState(() {}); }, child: contacts.length == 0 ? Center( child: ConstrainedBox( constraints: BoxConstraints( maxHeight: 300.0, minHeight: 200.0, maxWidth: MediaQuery.of(context).size.width * 0.8, minWidth: MediaQuery.of(context).size.width * 0.5, ), child: Center( child: Column( children: [ SvgPicture.asset( 'assets/images/any_contact_img.svg', height: 150.0, ), Padding(padding: EdgeInsets.all(8.0)), DefaultText( "You don't have any contacts yet try to add someone!", fontSize: 23.0, textAlign: TextAlign.center, ), IconButton( onPressed: () { setState(() {}); }, icon: Icon( Icons.refresh_outlined, color: darkBlue, ), ) ], ), ), ), ) : Padding( padding: const EdgeInsets.only(top: 8.0), child: ListView.builder( itemCount: isControllerEmpty() ? contacts.length : foudContacts.length, itemBuilder: (BuildContext context, int index) { return Container( width: MediaQuery.of(context).size.width * 0.8, child: Container( height: MediaQuery.of(context).size.height * (1 / 7.7), child: Column( children: [ ListTile( leading: ConstrainedBox( constraints: BoxConstraints( maxHeight: 60.0, maxWidth: 60.0, minHeight: 40.0, minWidth: 40.0, ), child: Container( // Catch image from https://picsum.photos/ child: ClipOval( child: Image.network( 'https://picsum.photos/id/${contacts[index].id}/200'), ), ), ), title: DefaultText( isControllerEmpty() ? "${contacts[index].name}" : "${foudContacts[index].name}", fontColor: darkBlue, fontSize: 21.0, ), subtitle: DefaultText( isControllerEmpty() ? "${contacts[index].phone}" : "${foudContacts[index].phone}", fontColor: darkBlue, fontSize: 15.0, ), onTap: () => { ContactController.instance .addContact( isControllerEmpty() ? contacts[index] : foudContacts[ index]), Navigator.pushNamed( context, '/fourth') }, ), Container( width: MediaQuery.of(context) .size .width * 0.9, child: Divider( color: darkBlue, thickness: 1.1, ), ), ], ), ), ); }, ), ), ); } else { return Center( child: CircularProgressIndicator( backgroundColor: defaultWhite, color: darkBlue, strokeWidth: 2.0, )); } }, ), ), ); } void onSearchTextChanged(String text) async { setState(() { var iterable = contacts.where((element) => (element.name!.toLowerCase().contains(searchInputController.text))); foudContacts = iterable.toList(); }); } bool isControllerEmpty() { return searchInputController.text == "" ? true : false; } }
0
mirrored_repositories/agenda_de_contatos/contact_book_mobile/lib/views/home_view
mirrored_repositories/agenda_de_contatos/contact_book_mobile/lib/views/home_view/widgets/group_members_widget.dart
import 'package:contact_book_mobile/core/controllers/auth_controller.dart'; import 'package:contact_book_mobile/core/controllers/group_controller.dart'; import 'package:contact_book_mobile/core/controllers/user_controller.dart'; import 'package:contact_book_mobile/core/models/contact.dart'; import 'package:contact_book_mobile/core/models/group.dart'; import 'package:contact_book_mobile/shared/colors/colors.dart'; import 'package:contact_book_mobile/shared/widgets/default_text.dart'; import 'package:contact_book_mobile/views/home_view/data/home_services.dart'; import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:fluttertoast/fluttertoast.dart'; // ignore: must_be_immutable class GroupMembersWidget extends StatefulWidget { bool isAdding = false; GroupMembersWidget({Key? key, required this.isAdding}) : super(key: key); @override _GroupMembersWidgetState createState() => _GroupMembersWidgetState(); } class _GroupMembersWidgetState extends State<GroupMembersWidget> { Group group = GroupController.instance.group; int? userId = UserController.instance.user.id; String? token = AuthController.instance.token; late Future<List<Contact>> contactsGroup; late Future<List<Contact>> membersOutGroup; @override Widget build(BuildContext context) { membersOutGroup = HomePageServices().getMembersOutGroup(userId, group.id, token); contactsGroup = HomePageServices().getGroup(group.id, token); return Scaffold( backgroundColor: Color.fromRGBO(0, 0, 0, 0.1), body: SimpleDialog( contentPadding: EdgeInsets.all(0), shape: RoundedRectangleBorder( side: BorderSide(width: 0.5, color: darkBlue), borderRadius: new BorderRadius.circular(10.0)), children: <Widget>[ Container( margin: EdgeInsets.all(0), height: 50, decoration: BoxDecoration( borderRadius: new BorderRadius.only( topLeft: const Radius.circular(10.0), topRight: const Radius.circular(10.0)), color: darkBlue, ), child: Center( child: Row( children: [ IconButton( onPressed: () => Navigator.of(context).pop(), icon: Icon( Icons.arrow_back, color: defaultWhite, size: 20.0, )), DefaultText( widget.isAdding ? 'Add contact to ${group.name}' : "${group.name} members", fontColor: defaultWhite, ), ], ), ), ), Container( height: 260.0, child: SingleChildScrollView( child: Container( width: 100.0, height: 250.0, child: FutureBuilder( future: widget.isAdding ? membersOutGroup : contactsGroup, builder: (BuildContext context, AsyncSnapshot snapshot) { if (snapshot.hasData) { return snapshot.data.length == 0 ? Column( mainAxisAlignment: MainAxisAlignment.center, children: [ SvgPicture.asset( 'assets/images/any_contact_in_group_img.svg', height: 100.0, ), Padding(padding: EdgeInsets.all(8.0)), ConstrainedBox( constraints: BoxConstraints( maxHeight: 200.0, minHeight: 100.0, maxWidth: 200.0, minWidth: 150.0, ), child: DefaultText( widget.isAdding ? "No contacts available to add, create more and add then!" : "This group has no contacts yet, add someone!", fontSize: 20.0, textAlign: TextAlign.center, ), ), ], ) : ListView.builder( itemCount: snapshot.data.length, itemBuilder: (BuildContext context, int index) { return ListTile( leading: Container( width: 40.0, height: 40.0, // Catch image from https://picsum.photos/ child: ClipOval( child: Image.network( 'https://picsum.photos/id/${snapshot.data[index].id}/200'), ), ), title: Text("${snapshot.data[index].name}"), subtitle: Text("${snapshot.data[index].phone}"), trailing: IconButton( icon: Icon( widget.isAdding ? Icons.add : Icons.remove, color: darkBlue, ), onPressed: () { addOrDeleteToGroup( snapshot.data[index].id, group.name); }, ), ); }, ); } else { return Center(child: CircularProgressIndicator()); } }, ), ), ), ), ], ), ); } Future<void> addOrDeleteToGroup(int? contactId, String? name) async { try { var resp; if (widget.isAdding) { resp = await HomePageServices().addContactToGroup(contactId, name, token); } else { resp = await HomePageServices() .deleteContactFromGroup(contactId, name, token); } Fluttertoast.showToast( msg: resp['message'], toastLength: Toast.LENGTH_SHORT, gravity: ToastGravity.BOTTOM, timeInSecForIosWeb: 1, backgroundColor: resp['status'] ? Colors.green : Colors.red, textColor: Colors.white, fontSize: 10.0); if (resp['status']) setState(() {}); } catch (error) { print(error); } } }
0
mirrored_repositories/agenda_de_contatos/contact_book_mobile/lib/views/home_view
mirrored_repositories/agenda_de_contatos/contact_book_mobile/lib/views/home_view/page/home_page.dart
import 'package:contact_book_mobile/shared/colors/colors.dart'; import 'package:contact_book_mobile/shared/widgets/default_text.dart'; import 'package:flutter/material.dart'; import 'package:contact_book_mobile/core/controllers/people_api_controller.dart'; import 'package:contact_book_mobile/core/controllers/user_controller.dart'; import 'package:contact_book_mobile/core/models/helpers/google_login.dart'; import 'package:contact_book_mobile/core/models/user.dart'; import 'package:contact_book_mobile/views/home_view/widgets/contacts_tab.dart'; import 'package:contact_book_mobile/views/home_view/widgets/custom_fab.dart'; import 'package:contact_book_mobile/views/home_view/widgets/groups_tab.dart'; import 'package:google_fonts/google_fonts.dart'; class Home extends StatefulWidget { static const routeName = '/second'; Home({Key? key}) : super(key: key); @override _HomeState createState() => _HomeState(); } class _HomeState extends State<Home> { bool willPop = false; @override Widget build(BuildContext context) { final args = ModalRoute.of(context)!.settings.arguments as GoogleLogin; User user = UserController.instance.user; return Material( child: DefaultTabController( length: 2, child: WillPopScope( onWillPop: () async { _showDialog(context, args); return willPop; }, child: Scaffold( appBar: PreferredSize( preferredSize: Size.fromHeight(100.0), child: AppBar( title: Text( args.isGoogleLogin ? "Google Contact's Book" : "${user.name} Contact's Book", style: GoogleFonts.pacifico( color: defaultWhite, fontSize: 25.0, ), ), backgroundColor: darkBlue, bottom: TabBar( indicatorWeight: 1.0, tabs: [ Tab( icon: Icon( Icons.person, size: 18.0, color: defaultWhite, ), ), Tab( icon: Icon( Icons.group, size: 18.0, color: defaultWhite, ), ) ], ), ), ), body: TabBarView( children: [ ContactsTab(isGoogleLogin: args.isGoogleLogin), GroupsTab() ], ), floatingActionButton: CustomFab(), ), ), ), ); } void _showDialog(BuildContext context, args) { showDialog( context: context, builder: (BuildContext context) { return AlertDialog( backgroundColor: darkBlue, title: DefaultText( "Alert!", fontColor: defaultWhite, fontSize: 25.0, ), content: DefaultText( "Do you really want to loggout?", fontColor: defaultWhite, ), actions: <Widget>[ TextButton( onPressed: () { willPop = false; Navigator.pop(context); }, child: DefaultText( 'No', fontSize: 20, fontColor: defaultWhite, ), ), TextButton( onPressed: () async { try { // If logged with a Google account then sign out if (args.isGoogleLogin) await PeopleApiController.instance.googleSignIn! .signOut(); willPop = true; Navigator.of(context).pop(); Navigator.of(context).pop(); } on Exception catch (error) { print(error); } }, child: DefaultText( 'Yes', fontSize: 20, fontColor: defaultWhite, )), ], ); }, ); } }
0
mirrored_repositories/agenda_de_contatos/contact_book_mobile/lib/views/home_view
mirrored_repositories/agenda_de_contatos/contact_book_mobile/lib/views/home_view/data/home_services.dart
import 'package:contact_book_mobile/core/models/contact.dart'; import 'package:contact_book_mobile/core/models/group.dart'; import 'package:contact_book_mobile/core/services/contact_services.dart'; import 'package:contact_book_mobile/core/services/group_services.dart'; // This file contains just the services calls used in Home main page and their widgets class HomePageServices { Future<List<Contact>> getAllContactsByUserId( int? userId, String? token) async { return await ContactServices().getAllContactsByUserId(userId, token); } Future<dynamic> createGroup(int? userId, String token, String body) async { return await GroupServices().createGroup(userId, token, body); } Future<List<Contact>> getGroup(int? groupId, String? token) async { return await GroupServices().getGroup(groupId, token); } Future<List<Group>> getAllGroupsByUserId(int? userId, String? token) async { return await GroupServices().getAllGroupsByUserId(userId, token); } Future<List<Contact>> getMembersOutGroup( int? userId, int? groupId, String? token) async { return await GroupServices().getMembersOutGroup(userId, groupId, token); } Future<dynamic> addContactToGroup( int? contactId, String? name, String? token) async { return await GroupServices().addContactToGroup(contactId, name, token); } Future<dynamic> deleteContactFromGroup( int? contactId, String? name, String? token) async { return await GroupServices().deleteContactFromGroup(contactId, name, token); } Future<dynamic> deleteGroup(int? groupId, String? token) async { return await GroupServices().deleteGroup(groupId, token); } }
0
mirrored_repositories/agenda_de_contatos/contact_book_mobile/lib/views/add_object_view
mirrored_repositories/agenda_de_contatos/contact_book_mobile/lib/views/add_object_view/page/add_object.dart
import 'package:contact_book_mobile/core/controllers/auth_controller.dart'; import 'package:contact_book_mobile/core/controllers/user_controller.dart'; import 'package:contact_book_mobile/core/models/helpers/screen_arguments.dart'; import 'package:contact_book_mobile/shared/colors/colors.dart'; import 'package:contact_book_mobile/shared/widgets/default_text.dart'; import 'package:contact_book_mobile/views/add_object_view/data/add_object_services.dart'; import 'package:flutter/material.dart'; import 'package:fluttertoast/fluttertoast.dart'; import 'package:google_fonts/google_fonts.dart'; // ignore: must_be_immutable class AddObjectView extends StatefulWidget { static const routeName = '/third'; @override _AddObjectViewState createState() => _AddObjectViewState(); } class _AddObjectViewState extends State<AddObjectView> { TextEditingController zipCodeController = TextEditingController(); final formKey = GlobalKey<FormState>(); String name = ''; String phone = ''; String email = ''; String zipCode = ''; String street = ''; String number = ''; String district = ''; String city = ''; String uf = ''; // Variables that turn the text fields enabled or not // according to the use of the zip code API bool isStreetEnable = true; bool isDistrictEnable = true; bool isCityEnable = true; bool isUfEnable = true; // The controllers to change the text fields values after a zip code search TextEditingController streetInitialValue = TextEditingController(); TextEditingController districtInitialValue = TextEditingController(); TextEditingController cityInitialValue = TextEditingController(); TextEditingController ufInitialValue = TextEditingController(); // How all text fields has almost the same style, // part of this is created here to avoid code repeat InputDecoration getInputDecoration(String hintText, IconData iconData) { return InputDecoration( contentPadding: EdgeInsets.only(top: 7.0), enabledBorder: UnderlineInputBorder( borderSide: BorderSide(color: defaultWhite), ), focusedBorder: UnderlineInputBorder( borderSide: BorderSide(color: defaultWhite), ), disabledBorder: UnderlineInputBorder( borderSide: BorderSide(color: lightBlue), ), prefixIcon: Icon( iconData, color: defaultWhite, size: 16.0, ), hintText: hintText, hintStyle: TextStyle(color: defaultWhite, fontSize: 13.0), filled: true, ); } @override Widget build(BuildContext context) { final args = ModalRoute.of(context)!.settings.arguments as ScreenArguments; return Scaffold( appBar: AppBar( title: Text( args.isAddingContact ? 'Add a new Contact' : 'Add an new Address', textAlign: TextAlign.end, style: GoogleFonts.pacifico( color: defaultWhite, fontSize: 25.0, ), ), backgroundColor: darkBlue, elevation: 1.0, ), body: Center( child: Container( color: darkBlue, child: Center( child: Form( key: formKey, child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Padding(padding: EdgeInsets.all(8.0)), args.isAddingContact ? Container( width: MediaQuery.of(context).size.width * 0.9, height: 40.0, child: TextFormField( decoration: getInputDecoration('Name', Icons.person), validator: (value) { if (value!.isEmpty) return 'Enter with some name'; }, onSaved: (value) => setState(() => name = value!), style: TextStyle(color: defaultWhite))) : Container(), Padding(padding: EdgeInsets.all(8.0)), Container( width: MediaQuery.of(context).size.width * 0.9, height: 40.0, child: TextFormField( decoration: getInputDecoration('Phone', Icons.phone), keyboardType: TextInputType.phone, validator: (value) { // Simple phone validator (Brazil only) final pattern = r'(^[0-9]{2}-[0-9]{4}-[0-9]{4}$)'; final regExp = RegExp(pattern); if (value!.isEmpty) { return 'Enter a phone'; } else if (!regExp.hasMatch(value)) { return 'Enter a valid phone'; } else { return null; } }, onSaved: (value) => setState(() => phone = value!), style: TextStyle(color: defaultWhite))), Padding(padding: EdgeInsets.all(8.0)), Container( width: MediaQuery.of(context).size.width * 0.9, height: 40.0, child: TextFormField( decoration: getInputDecoration('Email', Icons.email), keyboardType: TextInputType.emailAddress, validator: (value) { // Simple email validator final pattern = r'(^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$)'; final regExp = RegExp(pattern); if (value != '') { if (!regExp.hasMatch(value!)) { return 'Enter a valid email'; } else { return null; } } }, onSaved: (value) => setState(() => email = value!), style: TextStyle(color: defaultWhite))), Padding(padding: EdgeInsets.all(8.0)), Container( width: MediaQuery.of(context).size.width * 0.9, height: 50.0, child: Row( children: [ Container( height: 40.0, width: MediaQuery.of(context).size.width * 0.60, child: TextFormField( decoration: getInputDecoration( 'Zip code', Icons.post_add), keyboardType: TextInputType.phone, controller: zipCodeController, onSaved: (value) => setState(() => zipCode = value!), style: TextStyle(color: defaultWhite)), ), Padding( padding: EdgeInsets.only(left: 10.0), child: Container( width: 100.0, height: 30.0, child: ElevatedButton.icon( icon: Icon( Icons.search, color: darkBlue, size: 18.0, ), label: DefaultText( 'Search', fontSize: 13.0, fontColor: darkBlue, ), style: ElevatedButton.styleFrom( primary: defaultWhite, ), onPressed: () { onSearchZipCode(); }, ), ), ) ], ), ), Container( width: MediaQuery.of(context).size.width * 0.9, height: 50.0, child: Row( children: [ Container( height: 40.0, width: MediaQuery.of(context).size.width * 0.55, child: TextFormField( enabled: isStreetEnable ? true : false, controller: streetInitialValue, decoration: getInputDecoration( 'Street', Icons.add_road_sharp), onSaved: (value) => setState(() => street = value!), style: TextStyle(color: defaultWhite)), ), Padding(padding: EdgeInsets.only(left: 10.0)), Container( height: 40.0, width: MediaQuery.of(context).size.width * 0.30, child: TextFormField( decoration: getInputDecoration( 'N°', Icons.confirmation_number), onSaved: (value) => setState(() => number = value!), style: TextStyle(color: defaultWhite)), ) ], )), Padding(padding: EdgeInsets.all(8.0)), Container( height: 50.0, width: MediaQuery.of(context).size.width * 0.9, child: Row( children: [ Container( height: 40.0, width: MediaQuery.of(context).size.width * 0.55, child: TextFormField( enabled: isCityEnable ? true : false, controller: cityInitialValue, decoration: getInputDecoration( 'City', Icons.location_city), onSaved: (value) => setState(() => city = value!), style: TextStyle(color: defaultWhite))), Padding(padding: EdgeInsets.only(left: 10.0)), Container( height: 40.0, width: MediaQuery.of(context).size.width * 0.3, child: TextFormField( enabled: isUfEnable ? true : false, controller: ufInitialValue, decoration: getInputDecoration('UF', Icons.account_balance), onSaved: (value) => setState(() => uf = value!), style: TextStyle(color: defaultWhite), ), ), ], ), ), Padding(padding: EdgeInsets.all(8.0)), Container( height: 40.0, width: MediaQuery.of(context).size.width * 0.9, child: TextFormField( enabled: isDistrictEnable ? true : false, controller: districtInitialValue, decoration: getInputDecoration('District', Icons.home_filled), onSaved: (value) => setState(() => district = value!), style: TextStyle(color: defaultWhite))), Padding( padding: const EdgeInsets.all(10.0), child: TextButton( onPressed: () async { final isValid = formKey.currentState!.validate(); if (isValid) { formKey.currentState!.save(); onSubmit(args); } }, child: Text( 'Create!', style: GoogleFonts.pacifico( color: defaultWhite, fontSize: 25.0, ), ), ), ) ], ), ), ), ), ), ); } void onSearchZipCode() async { // Get the response from zipCode API and repass for the variables var resp = await AddObjectServices().getAddressByZipCode(zipCodeController.text); if (resp != null) { setState( () { // The controllers receive the values streetInitialValue.text = resp["logradouro"]; districtInitialValue.text = resp["bairro"]; cityInitialValue.text = resp["localidade"]; ufInitialValue.text = resp["uf"]; // If any value is found by the API the user can't modify it isStreetEnable = streetInitialValue.text == "" ? true : false; isDistrictEnable = districtInitialValue.text == "" ? true : false; isCityEnable = cityInitialValue.text == "" ? true : false; isUfEnable = ufInitialValue.text == "" ? true : false; }, ); } } void onSubmit(args) async { String body = '{"name":"$name",' + '"phone":"$phone",' + '"email":"$email",' + '"zip_code":"$zipCode",' + '"street":"$street",' + '"number":"$number",' + '"district":"$district",' + '"city":"$city",' + '"uf":"$uf"}'; var resp; int? userId = UserController.instance.user.id; String token = AuthController.instance.token; try { if (args.isAddingContact) { resp = await AddObjectServices().createContact(userId, body, token); } else { resp = await AddObjectServices() .createAddress(args.contactId, body, token); } Fluttertoast.showToast( msg: resp['message'], toastLength: Toast.LENGTH_SHORT, gravity: ToastGravity.BOTTOM, timeInSecForIosWeb: 1, backgroundColor: resp['status'] ? Colors.green : Colors.red, textColor: defaultWhite, fontSize: 10.0); if (resp['status']) Navigator.pop(context); } catch (error) { print(error); } } }
0
mirrored_repositories/agenda_de_contatos/contact_book_mobile/lib/views/add_object_view
mirrored_repositories/agenda_de_contatos/contact_book_mobile/lib/views/add_object_view/data/add_object_services.dart
import 'package:contact_book_mobile/core/services/address_services.dart'; import 'package:contact_book_mobile/core/services/api_correios_services.dart'; import 'package:contact_book_mobile/core/services/contact_services.dart'; // This file contains just the services calls used in AddObjectView main page and their widgets class AddObjectServices { Future<dynamic> createContact(int? userId, String body, String? token) async { return await ContactServices().createContact(userId, body, token); } Future<dynamic> createAddress( int? contactId, String body, String? token) async { return await AddressServices().createAddress(contactId, body, token); } Future<dynamic> getAddressByZipCode(String zipCode) async { return await ApiCorreiosServices().getAddressByZipCode(zipCode); } }
0
mirrored_repositories/agenda_de_contatos/contact_book_mobile/lib/views/contact_view
mirrored_repositories/agenda_de_contatos/contact_book_mobile/lib/views/contact_view/widgets/custom_row.dart
import 'package:contact_book_mobile/shared/colors/colors.dart'; import 'package:contact_book_mobile/shared/widgets/default_text.dart'; import 'package:flutter/material.dart'; // ignore: must_be_immutable class CustomRow extends StatelessWidget { String? textOne, textTwo; IconData iconOne, iconTwo; CustomRow( {Key? key, required this.textOne, required this.textTwo, required this.iconOne, required this.iconTwo}) : super(key: key); @override Widget build(BuildContext context) { return Container( child: Row( mainAxisAlignment: MainAxisAlignment.start, children: [ SizedBox( width: MediaQuery.of(context).size.width * 0.35, child: Row( mainAxisAlignment: MainAxisAlignment.start, children: [ Icon(iconOne, color: darkBlue, size: 15.0), DefaultText(" $textOne", fontSize: 15.0), ], ), ), Padding(padding: EdgeInsets.only(left: 8.0)), SizedBox( width: MediaQuery.of(context).size.width * 0.30, child: Row( mainAxisAlignment: MainAxisAlignment.start, children: [ Icon(iconTwo, color: darkBlue, size: 15.0), DefaultText(" $textTwo", fontSize: 15.0), ], ), ), ], ), ); } }
0
mirrored_repositories/agenda_de_contatos/contact_book_mobile/lib/views/contact_view
mirrored_repositories/agenda_de_contatos/contact_book_mobile/lib/views/contact_view/widgets/custom_pop_menu.dart
import 'package:contact_book_mobile/core/controllers/auth_controller.dart'; import 'package:contact_book_mobile/shared/colors/colors.dart'; import 'package:contact_book_mobile/shared/widgets/default_text.dart'; import 'package:contact_book_mobile/views/contact_view/data/contact_view_services.dart'; import 'package:flutter/material.dart'; import 'package:fluttertoast/fluttertoast.dart'; // ignore: must_be_immutable class CustomPopMenu extends StatefulWidget { int? objectId; bool isContact = true; CustomPopMenu({Key? key, required this.objectId, required this.isContact}) : super(key: key); @override _CustomPopMenuState createState() => _CustomPopMenuState(); } enum Father { edit, delete } class _CustomPopMenuState extends State<CustomPopMenu> { @override Widget build(BuildContext context) { return PopupMenuButton<Father>( color: widget.isContact ? defaultWhite : darkBlue, icon: Icon(Icons.more_vert, color: widget.isContact ? defaultWhite : darkBlue), onSelected: (Father result) { if (result.index == 1) { widget.isContact ? _showDialog(context, widget.objectId) : deleteObject(widget.objectId); } }, itemBuilder: (BuildContext context) => <PopupMenuEntry<Father>>[ PopupMenuItem<Father>( value: Father.edit, child: ListTile( leading: Icon( Icons.edit, color: widget.isContact ? darkBlue : defaultWhite, size: 20.0, ), title: DefaultText('Edit', fontColor: widget.isContact ? darkBlue : defaultWhite, fontSize: 15.0), ), ), PopupMenuItem<Father>( value: Father.delete, child: ListTile( leading: Icon( Icons.delete, color: widget.isContact ? darkBlue : defaultWhite, size: 20.0, ), title: DefaultText( 'Delete', fontColor: widget.isContact ? darkBlue : defaultWhite, fontSize: 15.0, ), ), ) ], ); } void _showDialog(BuildContext context, int? objectId) { showDialog( context: context, builder: (BuildContext context) { return AlertDialog( title: DefaultText( "Alert!", fontSize: 25.0, ), content: DefaultText("Do you really want to delete this contact?"), actions: <Widget>[ TextButton( onPressed: () => Navigator.pop(context), child: DefaultText( 'No', fontSize: 20, )), TextButton( onPressed: () => deleteObject(objectId), child: DefaultText( 'Yes', fontSize: 20, )), ], ); }, ); } Future<void> deleteObject(int? objectId) async { try { var resp; if (widget.isContact) { resp = await ContactViewServices() .deleteContact(objectId, AuthController.instance.token); } else { resp = await ContactViewServices() .deleteAddress(objectId, AuthController.instance.token); } Fluttertoast.showToast( msg: resp['message'], toastLength: Toast.LENGTH_SHORT, gravity: ToastGravity.BOTTOM, timeInSecForIosWeb: 1, backgroundColor: resp['status'] ? Colors.green : Colors.red, textColor: defaultWhite, fontSize: 10.0); if (resp['status']) { if (widget.isContact) { Navigator.of(context).pop(); Navigator.of(context).pop(); } } } catch (error) { print(error); } } }
0
mirrored_repositories/agenda_de_contatos/contact_book_mobile/lib/views/contact_view
mirrored_repositories/agenda_de_contatos/contact_book_mobile/lib/views/contact_view/page/contact_view.dart
import 'package:contact_book_mobile/core/controllers/auth_controller.dart'; import 'package:contact_book_mobile/core/controllers/contact_controller.dart'; import 'package:contact_book_mobile/core/models/address.dart'; import 'package:contact_book_mobile/core/models/contact.dart'; import 'package:contact_book_mobile/core/models/helpers/screen_arguments.dart'; import 'package:contact_book_mobile/shared/colors/colors.dart'; import 'package:contact_book_mobile/shared/widgets/default_text.dart'; import 'package:contact_book_mobile/views/add_object_view/page/add_object.dart'; import 'package:contact_book_mobile/views/contact_view/data/contact_view_services.dart'; import 'package:contact_book_mobile/views/contact_view/widgets/custom_pop_menu.dart'; import 'package:contact_book_mobile/views/contact_view/widgets/custom_row.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:google_fonts/google_fonts.dart'; class ContactView extends StatefulWidget { const ContactView({Key? key}) : super(key: key); @override _ContactViewState createState() => _ContactViewState(); } class _ContactViewState extends State<ContactView> { Contact contact = ContactController.instance.contact; List<Address> address = []; @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( backgroundColor: darkBlue, title: Text( "${contact.name} profile", style: GoogleFonts.pacifico( color: defaultWhite, fontSize: 25.0, ), ), actions: [ CustomPopMenu(objectId: contact.id, isContact: true), ], elevation: 1.0, ), body: Container( color: darkBlue, child: Column( children: [ Container( width: MediaQuery.of(context).size.width, height: MediaQuery.of(context).size.height * 0.20, color: darkBlue, child: Row( children: [ Padding( padding: const EdgeInsets.all(15.0), child: Container( width: 80.0, height: 80.0, child: // Catch image from https://picsum.photos/ ClipOval( child: Image.network( 'https://picsum.photos/id/${contact.id}/200', fit: BoxFit.fill, ), ), ), ), Padding( padding: const EdgeInsets.all(5.0), child: Container( width: MediaQuery.of(context).size.width * 0.6, height: 100.0, child: Column(children: [ Padding( padding: const EdgeInsets.all(5.0), child: Row( mainAxisAlignment: MainAxisAlignment.start, children: [ Icon( Icons.person, color: defaultWhite, size: 20.0, ), Padding(padding: EdgeInsets.only(right: 10.0)), DefaultText('${contact.name}', fontColor: defaultWhite, fontSize: 20.0), ], ), ), Padding( padding: const EdgeInsets.all(5.0), child: Row( mainAxisAlignment: MainAxisAlignment.start, children: [ Icon( Icons.phone, color: defaultWhite, size: 20.0, ), Padding(padding: EdgeInsets.only(right: 10.0)), DefaultText('${contact.phone}', fontColor: defaultWhite, fontSize: 16.0), ], ), ), Padding( padding: const EdgeInsets.all(5.0), child: Row( mainAxisAlignment: MainAxisAlignment.start, children: [ Icon( Icons.email, color: defaultWhite, size: 20.0, ), Padding(padding: EdgeInsets.only(right: 10.0)), DefaultText('${contact.email}', fontColor: defaultWhite, fontSize: 20.0), ], ), ), ]), ), ), ], ), ), Divider( thickness: 1.0, ), Container( width: MediaQuery.of(context).size.width, height: MediaQuery.of(context).size.height * 0.05, color: darkBlue, child: Padding( padding: const EdgeInsets.only(left: 15.0, right: 15.0), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ DefaultText('Address', fontColor: defaultWhite, fontSize: 20.0), IconButton( onPressed: () { ScreenArguments args = ScreenArguments( contactId: contact.id, isAddingContact: false); Navigator.of(context).pushNamed(AddObjectView.routeName, arguments: args); }, padding: EdgeInsets.only(bottom: 15.0), icon: Icon( Icons.add, color: defaultWhite, size: 30.0, ), ) ], ), ), ), Divider( thickness: 1.0, ), Container( height: MediaQuery.of(context).size.height * 0.55, color: darkBlue, child: FutureBuilder( future: ContactViewServices().getAllAddressByContactId( ContactController.instance.contact.id, AuthController.instance.token), builder: (BuildContext context, AsyncSnapshot snapshot) { if (snapshot.hasData) { address = snapshot.data; return RefreshIndicator( backgroundColor: darkBlue, color: defaultWhite, strokeWidth: 2.0, onRefresh: () async { setState(() {}); }, child: Container( width: MediaQuery.of(context).size.width * 0.95, child: ListView.builder( itemCount: address.length, itemBuilder: (BuildContext context, int index) { return Card( elevation: 5.0, // color: darkBlue, child: ListTile( title: Container( child: Column( children: [ Padding(padding: EdgeInsets.all(5.0)), Row( mainAxisAlignment: MainAxisAlignment.start, children: [ Icon( Icons.phone, color: darkBlue, size: 15.0, ), DefaultText( " ${address[index].phone}", fontColor: darkBlue, fontSize: 15.0), ], ), Padding(padding: EdgeInsets.all(5.0)), Row( mainAxisAlignment: MainAxisAlignment.start, children: [ Icon( Icons.email, color: darkBlue, size: 15.0, ), DefaultText( " ${address[index].email}", fontColor: darkBlue, fontSize: 15.0), ], ), ], ), ), subtitle: Container( child: Column( children: [ Divider( color: darkBlue, thickness: 1.0, ), CustomRow( iconOne: Icons.post_add, iconTwo: Icons.account_balance, textOne: address[index].zipCode, textTwo: address[index].uf), Padding(padding: EdgeInsets.all(5.0)), CustomRow( iconOne: Icons.location_city, iconTwo: Icons.home_filled, textOne: address[index].city, textTwo: address[index].district), Padding(padding: EdgeInsets.all(5.0)), CustomRow( iconOne: Icons.add_road_sharp, iconTwo: Icons.confirmation_number, textOne: address[index].street, textTwo: address[index].number), Padding(padding: EdgeInsets.all(5.0)), ], ), ), trailing: CustomPopMenu( objectId: address[index].id, isContact: false)), ); }, ), ), ); } else { return Center(child: CircularProgressIndicator()); } }, ), ), ], ), ), ); } }
0
mirrored_repositories/agenda_de_contatos/contact_book_mobile/lib/views/contact_view
mirrored_repositories/agenda_de_contatos/contact_book_mobile/lib/views/contact_view/data/contact_view_services.dart
import 'package:contact_book_mobile/core/services/address_services.dart'; import 'package:contact_book_mobile/core/services/contact_services.dart'; // This file contains just the services calls used in ContactView main page and their widgets class ContactViewServices { Future<dynamic> getAllAddressByContactId( int? contactId, String? token) async { return await AddressServices().getAllAddressByContactId(contactId, token); } Future<dynamic> deleteContact(int? contactId, String? token) async { return await ContactServices().deleteContact(contactId, token); } Future<dynamic> deleteAddress(int? addressId, String? token) async { return await AddressServices().deleteAddress(addressId, token); } }
0
mirrored_repositories/agenda_de_contatos/contact_book_mobile/lib/core
mirrored_repositories/agenda_de_contatos/contact_book_mobile/lib/core/controllers/user_controller.dart
import 'package:contact_book_mobile/core/models/user.dart'; import 'package:flutter/cupertino.dart'; // Simple controller used to hold the current logged user, works as an inherited widget extends provider class UserController extends ChangeNotifier { // Instance to access their parameters and methods static UserController instance = UserController(); // Current user User user = User(); // Replaces the user with the logged in void addUser(User content) { user = content; // Notify all listeners about the new value of the parameter notifyListeners(); } }
0
mirrored_repositories/agenda_de_contatos/contact_book_mobile/lib/core
mirrored_repositories/agenda_de_contatos/contact_book_mobile/lib/core/controllers/people_api_controller.dart
import 'package:contact_book_mobile/core/models/people_api.dart'; import 'package:flutter/cupertino.dart'; import 'package:google_sign_in/google_sign_in.dart'; // For the code to login with a Google account and use the People API, only 3 objects were used: // The Sign In: It's necessary a register to access the platform and their functions // The own Account: A Google account that has data access permissions // And the contacts: The contacts objects that will be request class PeopleApiController extends ChangeNotifier { // Instance to access their parameters and methods static PeopleApiController instance = PeopleApiController(); // The Sign In object GoogleSignIn? googleSignIn; // The Google account object GoogleSignInAccount? currentUser; // The whole contacts object GoogleContacts? contacts; // Replaces the Sign In with a new value void addCurrentSignIn(GoogleSignIn? content) { googleSignIn = content; // Notify all listeners about the new value of the parameter notifyListeners(); } // Replaces the Google account with a new value void addCurrentUser(GoogleSignInAccount? content) { currentUser = content; // Notify all listeners about the new value of the parameter notifyListeners(); } // Replaces the contacts with a new value void addContacts(GoogleContacts? content) { contacts = content; // Notify all listeners about the new value of the parameter notifyListeners(); } }
0
mirrored_repositories/agenda_de_contatos/contact_book_mobile/lib/core
mirrored_repositories/agenda_de_contatos/contact_book_mobile/lib/core/controllers/group_controller.dart
import 'package:contact_book_mobile/core/models/group.dart'; import 'package:flutter/cupertino.dart'; // Simple controller used to hold a whole group object, works as an inherited widget extends provider class GroupController extends ChangeNotifier { // Instance to access their parameters and methods static GroupController instance = GroupController(); // Selected group Group group = Group(); // Replaces the group with a new value void addGroup(Group content) { group = content; // Notify all listeners about the new value of the parameter notifyListeners(); } }
0
mirrored_repositories/agenda_de_contatos/contact_book_mobile/lib/core
mirrored_repositories/agenda_de_contatos/contact_book_mobile/lib/core/controllers/contact_controller.dart
import 'package:contact_book_mobile/core/models/contact.dart'; import 'package:flutter/cupertino.dart'; // Simple controller used to hold a whole contact object, works as an inherited widget extends provider class ContactController extends ChangeNotifier { // Instance to access their parameters and methods static ContactController instance = ContactController(); // Selected contact Contact contact = Contact(); // Replaces the contact with a new value void addContact(Contact content) { contact = content; // Notify all listeners about the new value of the parameter notifyListeners(); } }
0
mirrored_repositories/agenda_de_contatos/contact_book_mobile/lib/core
mirrored_repositories/agenda_de_contatos/contact_book_mobile/lib/core/controllers/auth_controller.dart
import 'package:flutter/cupertino.dart'; // Simple controller used to hold the token, works as an inherited widget extends provider class AuthController extends ChangeNotifier { // Instance to access their parameters and methods static AuthController instance = AuthController(); // Token to be held String token = ''; // Replaces the token with a new value void addToken(String content) { token = content; // Notify all listeners about the new value of the parameter notifyListeners(); } }
0
mirrored_repositories/agenda_de_contatos/contact_book_mobile/lib/core
mirrored_repositories/agenda_de_contatos/contact_book_mobile/lib/core/models/group.dart
import 'dart:convert'; import 'package:contact_book_mobile/core/models/contact.dart'; // The class that models a Group object // All the parameters can be accessed and the toJson() e fromJson() methods // allows obtaining the object by service requests // // For more models formats: // https://app.quicktype.io/ can be used to convert a json file to a Dart object Group groupFromJson(String str) => Group.fromJson(json.decode(str)); String groupToJson(Group data) => json.encode(data.toJson()); class Group { // Group default constructor Group({ this.id, this.name, this.userId, this.updatedAt, this.createdAt, this.contact, }); // All class parameters int? id; String? name; DateTime? updatedAt; DateTime? createdAt; // DB Relationship: // (User) 1 : N (Groups) int? userId; // (Contacts) N : M (Groups) List<Contact>? contact; factory Group.fromJson(Map<String, dynamic> json) => Group( id: json["id"] == null ? null : json["id"], name: json["name"] == null ? null : json["name"], userId: json["user_id"] == null ? null : json["user_id"], updatedAt: json["updatedAt"] == null ? null : DateTime.parse(json["updatedAt"]), createdAt: json["createdAt"] == null ? null : DateTime.parse(json["createdAt"]), contact: json["contact"] == null ? null : List<Contact>.from( json["contact"]?.map((x) => Contact.fromJson(x))), ); Map<String, dynamic> toJson() => { "id": id == null ? null : id, "name": name == null ? null : name, "user_id": userId == null ? null : userId, "updatedAt": updatedAt == null ? null : updatedAt?.toIso8601String(), "createdAt": createdAt == null ? null : createdAt?.toIso8601String(), "contact": contact == null ? null : List<dynamic>.from(contact!.map((x) => x.toJson())), }; }
0
mirrored_repositories/agenda_de_contatos/contact_book_mobile/lib/core
mirrored_repositories/agenda_de_contatos/contact_book_mobile/lib/core/models/address.dart
import 'dart:convert'; // The class that models an Address object // All the parameters can be accessed and the toJson() e fromJson() methods // allows obtaining the object by service requests // // For more models formats: // https://app.quicktype.io/ can be used to convert a json file to a Dart object Address addressFromJson(String str) => Address.fromJson(json.decode(str)); String addressToJson(Address data) => json.encode(data.toJson()); class Address { // Address default constructor Address({ this.id, this.phone, this.email, this.zipCode, this.street, this.number, this.district, this.city, this.uf, this.createdAt, this.updatedAt, this.contactId, }); // All class parameters int? id; String? phone; String? email; String? zipCode; String? street; String? number; String? district; String? city; String? uf; DateTime? createdAt; DateTime? updatedAt; // DB Relationship: // (Contact) 1 : N (Addresses) int? contactId; factory Address.fromJson(Map<String, dynamic> json) => Address( id: json["id"] == null ? null : json["id"], phone: json["phone"] == null ? null : json["phone"], email: json["email"] == null ? null : json["email"], zipCode: json["zip_code"] == null ? null : json["zip_code"], street: json["street"] == null ? null : json["street"], number: json["number"] == null ? null : json["number"], district: json["district"] == null ? null : json["district"], city: json["city"] == null ? null : json["city"], uf: json["uf"] == null ? null : json["uf"], createdAt: json["createdAt"] == null ? null : DateTime.parse(json["createdAt"]), updatedAt: json["updatedAt"] == null ? null : DateTime.parse(json["updatedAt"]), contactId: json["contact_id"] == null ? null : json["contact_id"], ); Map<String, dynamic> toJson() => { "id": id == null ? null : id, "phone": phone == null ? null : phone, "email": email == null ? null : email, "zip_code": zipCode == null ? null : zipCode, "street": street == null ? null : street, "number": number == null ? null : number, "district": district == null ? null : district, "city": city == null ? null : city, "uf": uf == null ? null : uf, "createdAt": createdAt == null ? null : createdAt?.toIso8601String(), "updatedAt": updatedAt == null ? null : updatedAt?.toIso8601String(), "contact_id": contactId == null ? null : contactId, }; }
0
mirrored_repositories/agenda_de_contatos/contact_book_mobile/lib/core
mirrored_repositories/agenda_de_contatos/contact_book_mobile/lib/core/models/people_api.dart
import 'dart:convert'; // This class models the Google contacts object used in a Google account login // All the parameters can be accessed and the toJson() e fromJson() methods // allows obtaining the object by service requests // The model contains the request body from: // https://people.googleapis.com/v1/people/me/connections?personFields=names,phoneNumbers // For others specific models and requests you can access: // https://developers.google.com/people/api/rest // And their authorizations in: // https://developers.google.com/people/api/rest/v1/people/get#authorization-scopes GoogleContacts googleContactsFromJson(String str) => GoogleContacts.fromJson(json.decode(str)); String googleContactsToJson(GoogleContacts data) => json.encode(data.toJson()); class GoogleContacts { GoogleContacts({ required this.connections, required this.nextPageToken, required this.totalPeople, required this.totalItems, }); List<Connection> connections; String nextPageToken; int totalPeople; int totalItems; factory GoogleContacts.fromJson(Map<String, dynamic> json) => GoogleContacts( connections: List<Connection>.from( json["connections"].map((x) => Connection.fromJson(x))), nextPageToken: json["nextPageToken"], totalPeople: json["totalPeople"], totalItems: json["totalItems"], ); Map<String, dynamic> toJson() => { "connections": List<dynamic>.from(connections.map((x) => x.toJson())), "nextPageToken": nextPageToken, "totalPeople": totalPeople, "totalItems": totalItems, }; } class Connection { Connection({ required this.resourceName, required this.etag, required this.names, required this.phoneNumbers, }); String resourceName; String etag; List<Name>? names; List<PhoneNumber>? phoneNumbers; factory Connection.fromJson(Map<String, dynamic> json) => Connection( resourceName: json["resourceName"], etag: json["etag"], names: json["names"] == null ? null : List<Name>.from(json["names"].map((x) => Name.fromJson(x))), phoneNumbers: json["phoneNumbers"] == null ? null : List<PhoneNumber>.from( json["phoneNumbers"].map((x) => PhoneNumber.fromJson(x))), ); Map<String, dynamic> toJson() => { "resourceName": resourceName, "etag": etag, "names": names == null ? null : List<dynamic>.from(names!.map((x) => x.toJson())), "phoneNumbers": phoneNumbers == null ? null : List<dynamic>.from(phoneNumbers!.map((x) => x.toJson())), }; } class Name { Name({ required this.metadata, required this.displayName, required this.familyName, required this.givenName, required this.displayNameLastFirst, required this.unstructuredName, required this.middleName, }); Metadata metadata; String displayName; String? familyName; String givenName; String displayNameLastFirst; String unstructuredName; String? middleName; factory Name.fromJson(Map<String, dynamic> json) => Name( metadata: Metadata.fromJson(json["metadata"]), displayName: json["displayName"], familyName: json["familyName"] == null ? null : json["familyName"], givenName: json["givenName"], displayNameLastFirst: json["displayNameLastFirst"], unstructuredName: json["unstructuredName"], middleName: json["middleName"] == null ? null : json["middleName"], ); Map<String, dynamic> toJson() => { "metadata": metadata.toJson(), "displayName": displayName, "familyName": familyName == null ? null : familyName, "givenName": givenName, "displayNameLastFirst": displayNameLastFirst, "unstructuredName": unstructuredName, "middleName": middleName == null ? null : middleName, }; } class Metadata { Metadata({ required this.primary, required this.source, }); bool? primary; Source source; factory Metadata.fromJson(Map<String, dynamic> json) => Metadata( primary: json["primary"] == null ? null : json["primary"], source: Source.fromJson(json["source"]), ); Map<String, dynamic> toJson() => { "primary": primary == null ? null : primary, "source": source.toJson(), }; } class Source { Source({ required this.type, required this.id, }); SourceType? type; String id; factory Source.fromJson(Map<String, dynamic> json) => Source( type: sourceTypeValues.map[json["type"]], id: json["id"], ); Map<String, dynamic> toJson() => { "type": sourceTypeValues.reverse![type], "id": id, }; } enum SourceType { CONTACT } final sourceTypeValues = EnumValues({"CONTACT": SourceType.CONTACT}); class PhoneNumber { PhoneNumber({ required this.metadata, required this.value, required this.canonicalForm, required this.type, required this.formattedType, }); Metadata metadata; String value; String? canonicalForm; PhoneNumberType? type; FormattedType? formattedType; factory PhoneNumber.fromJson(Map<String, dynamic> json) => PhoneNumber( metadata: Metadata.fromJson(json["metadata"]), value: json["value"], canonicalForm: json["canonicalForm"] == null ? null : json["canonicalForm"], type: phoneNumberTypeValues.map[json["type"]], formattedType: formattedTypeValues.map[json["formattedType"]], ); Map<String, dynamic> toJson() => { "metadata": metadata.toJson(), "value": value, "canonicalForm": canonicalForm == null ? null : canonicalForm, "type": phoneNumberTypeValues.reverse![type], "formattedType": formattedTypeValues.reverse![formattedType], }; } enum FormattedType { MOBILE } final formattedTypeValues = EnumValues({"Mobile": FormattedType.MOBILE}); enum PhoneNumberType { MOBILE } final phoneNumberTypeValues = EnumValues({"mobile": PhoneNumberType.MOBILE}); class EnumValues<T> { Map<String, T> map; Map<T, String>? reverseMap; EnumValues(this.map); Map<T, String>? get reverse { if (reverseMap == null) { reverseMap = map.map((k, v) => new MapEntry(v, k)); } return reverseMap; } }
0
mirrored_repositories/agenda_de_contatos/contact_book_mobile/lib/core
mirrored_repositories/agenda_de_contatos/contact_book_mobile/lib/core/models/contact.dart
import 'dart:convert'; import 'package:contact_book_mobile/core/models/address.dart'; import 'package:contact_book_mobile/core/models/group.dart'; // The class that models a Contact object // All the parameters can be accessed and the toJson() e fromJson() methods // allows obtaining the object by service requests // // For more models formats: // https://app.quicktype.io/ can be used to convert a json file to a Dart object Contact contactFromJson(String str) => Contact.fromJson(json.decode(str)); String contactToJson(Contact data) => json.encode(data.toJson()); class Contact { // Contact default constructor Contact( {this.id, this.name, this.phone, this.email, this.zipCode, this.street, this.number, this.district, this.city, this.uf, this.createdAt, this.updatedAt, this.userId, this.address, this.group}); // All class parameters int? id; String? name; String? phone; String? email; String? zipCode; String? street; String? number; String? district; String? city; String? uf; DateTime? createdAt; DateTime? updatedAt; // DB Relationship: // (User) 1 : N (Contacts) int? userId; // (Contact) 1 : N (Addresses) List<Address>? address; // (Contacts) N : M (Groups) List<Group>? group; factory Contact.fromJson(Map<String, dynamic> json) => Contact( id: json["id"] == null ? null : json["id"], name: json["name"] == null ? null : json["name"], phone: json["phone"] == null ? null : json["phone"], email: json["email"] == null ? null : json["email"], zipCode: json["zip_code"] == null ? null : json["zip_code"], street: json["street"] == null ? null : json["street"], number: json["number"] == null ? null : json["number"], district: json["district"] == null ? null : json["district"], city: json["city"] == null ? null : json["city"], uf: json["uf"] == null ? null : json["uf"], createdAt: json["createdAt"] == null ? null : DateTime.parse(json["createdAt"]), updatedAt: json["updatedAt"] == null ? null : DateTime.parse(json["updatedAt"]), userId: json["user_id"] == null ? null : json["user_id"], address: json["address"] == null ? null : List<Address>.from(json["address"]?.map((x) => x)), group: json["group"] == null ? null : List<Group>.from(json["group"]?.map((x) => x)), ); Map<String, dynamic> toJson() => { "id": id == null ? null : id, "name": name == null ? null : name, "phone": phone == null ? null : phone, "email": email == null ? null : email, "zip_code": zipCode == null ? null : zipCode, "street": street == null ? null : street, "number": number == null ? null : number, "district": district == null ? null : district, "city": city == null ? null : city, "uf": uf == null ? null : uf, "createdAt": createdAt == null ? null : createdAt?.toIso8601String(), "updatedAt": updatedAt == null ? null : updatedAt?.toIso8601String(), "user_id": userId == null ? null : userId, "address": address == null ? null : List<dynamic>.from(address!.map((x) => x.toJson())), "group": group == null ? null : List<dynamic>.from(group!.map((x) => x.toJson())) }; }
0
mirrored_repositories/agenda_de_contatos/contact_book_mobile/lib/core
mirrored_repositories/agenda_de_contatos/contact_book_mobile/lib/core/models/user.dart
import 'dart:convert'; import 'package:contact_book_mobile/core/models/contact.dart'; import 'package:contact_book_mobile/core/models/group.dart'; // The class that models a User object // All the parameters can be accessed and the toJson() e fromJson() methods // allows obtaining the object by service requests // // For more models formats: // https://app.quicktype.io/ can be used to convert a json file to a Dart object User userFromJson(String str) => User.fromJson(json.decode(str)); String userToJson(User data) => json.encode(data.toJson()); class User { // User default constructor User( {this.id, this.name, this.email, this.createdAt, this.updatedAt, this.contact, this.group}); // All class parameters int? id; String? name; String? email; DateTime? createdAt; DateTime? updatedAt; // DB Relationship: // (User) 1 : N (Contacts) List<Contact>? contact; // (User) 1 : N (Groups) List<Group>? group; factory User.fromJson(Map<String, dynamic> json) => User( id: json["id"] == null ? null : json["id"], name: json["name"] == null ? null : json["name"], email: json["email"] == null ? null : json["email"], createdAt: json["createdAt"] == null ? null : DateTime.parse(json["createdAt"]), updatedAt: json["updatedAt"] == null ? null : DateTime.parse(json["updatedAt"]), contact: json["contact"] == null ? null : List<Contact>.from( json["contact"]?.map((x) => Contact.fromJson(x))), group: json["group"] == null ? null : List<Group>.from(json["group"]?.map((x) => Contact.fromJson(x))), ); Map<String, dynamic> toJson() => { "id": id == null ? null : id, "name": name == null ? null : name, "email": email == null ? null : email, "createdAt": createdAt == null ? null : createdAt?.toIso8601String(), "updatedAt": updatedAt == null ? null : updatedAt?.toIso8601String(), "contact": contact == null ? null : List<dynamic>.from(contact!.map((x) => x.toJson())), }; }
0