Brother Cat said
This is a component that automatically manages the response interface processing, and is more suitable for flutter web projects.
It automatically manages your resizing, maximum and minimum size, and scaling, but I didn't find the layout control, but this is already very good, and you can write less code.
- Minimum size effect
https://gallery.codelessly.com/flutterwebsites/minimal/?utm_medium=link&utm_campaign=demo#/
- Flutter.dev official website
https://gallery.codelessly.com/flutterwebsites/flutterwebsite/?utm_medium=link&utm_campaign=demo
Old iron remember to forward, Brother Mao will present more Flutter good articles~~~~
WeChat group ducafecat
b Station https://space.bilibili.com/404904528
original
https://medium.com/flutterdevs/responsive-framework-in-flutter-74b8b2a360a9
Code
https://github.com/ducafecat/getx_quick_start
refer to
text
Flutter is Google's treasure trove of user interface tools for generating excellent, locally compiled iOS and Android applications from a code base. To build any application, we start with widgets-the building blocks of Flutter applications. Widgets describe what their views should be similar based on their current design and state. It integrates a text widget, row widget, column widget, container widget and so on.
This article uses the Flutter response framework package to study the Flutter response framework. With the help of the software package, we can easily implement a responsive screen. So let's get started.
Responsive framework
The responsive framework will automatically adjust your user interface to fit different screen sizes. Create your user interface once and have it display pixel-perfect mobile, tablet and desktop!
Supporting multiple display sizes usually means recreating the same layout multiple times. Under the traditional Bootstrap approach, building a responsive UI is time-consuming, frustrating, and repetitive. In addition, it is almost impossible to make everything pixel perfect, and simple editing takes several hours.
implementation plan
- Step 1: add dependencies
Add dependencies to the pubspec.yaml file.
Dependency:
dependencies:
responsive_framework: ^0.1.4
- Step 2: Import
import 'package:responsive_framework/responsive_framework.dart';
- Step 3: Enable AndriodX
org.gradle.jvmargs=-Xmx1536M
android.enableR8=true
android.useAndroidX=true
android.enableJetifier=true
Code
You need to implement it in your code separately
Before creating a UI similar to a responsive framework, we added ResponsiveWrapper.builder() to the Material application part of main. Initialize the List type of MaxWith, MinWith and Breakpoints in the file, adjust the size of the device inside it, such as mobile devices, tablets, desktops, and the automatic scaling value is defined, let us understand it and the following code reference.
ResponsiveWrapper.builder(
BouncingScrollWrapper.builder(context, widget!),
maxWidth: 1200,
minWidth: 450,
defaultScale: true,
breakpoints: [
ResponsiveBreakpoint.resize(450, name: MOBILE),
ResponsiveBreakpoint.autoScale(800, name: MOBILE),
ResponsiveBreakpoint.autoScale(800, name: TABLET),
ResponsiveBreakpoint.autoScale(1000, name: TABLET),
ResponsiveBreakpoint.resize(1200, name: DESKTOP),
ResponsiveBreakpoint.autoScale(2460, name: "4K"),
],
background: Container(color: Color(0xFFF5F5F5))
),
Auto-scaling shrinks and expands the layout proportionally, maintaining the precise appearance of the UI. This eliminates the need to manually adjust the layout to fit mobile devices, tablets, and desktops.
After this, we created a user profile screen, which is an image of the user, and two different types of lists, where the image and some text have been given.
All codes
import 'package:flutter/material.dart';
import 'package:responsive_framwork_demo/Constants/Constants.dart';
import 'package:responsive_framwork_demo/device_size.dart';
import 'package:responsive_framwork_demo/model/popular_course_model.dart';
import 'package:responsive_framwork_demo/model/result_model.dart';
class ProfileScreen extends StatefulWidget {
@override
_ProfileScreenState createState() => _ProfileScreenState();
}
class _ProfileScreenState extends State<ProfileScreen> {
late List<PopularCourseModel> popularCourseModel;
late List<ResultModel> resultModel;
@override
void initState() {
popularCourseModel = Constants.getPopularCourseModel();
resultModel = Constants.getResultModel();
super.initState();
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.white,
appBar: AppBar(
backgroundColor: Colors.white,
elevation: 0.0,
title: Text(
'PROFILE',
style: TextStyle(
fontFamily: 'Poppins Medium',
color: Colors.black,
fontSize: 15,
fontWeight: FontWeight.bold,
letterSpacing: 0.5),
),
centerTitle: true,
),
body: SingleChildScrollView(
child: Container(
padding: EdgeInsets.only(top: 20),
child: Column(
children: [
ClipOval(
child: CircleAvatar(
maxRadius: 50,
child: Image.asset(
'assets/images/mans_img.jpeg',
width: DeviceSize.width(context),
fit: BoxFit.fill,
),
),
),
SizedBox(
height: 30,
),
Text(
'Crowley Singer',
style: TextStyle(
fontFamily: 'Poppins Medium',
color: Colors.black,
fontSize: 15,
fontWeight: FontWeight.bold,
letterSpacing: 0.3),
),
Container(
margin: EdgeInsets.only(top: 25, left: 20, right: 20),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
Column(
children: [
Text(
'22',
style: TextStyle(
fontFamily: 'Poppins Medium',
color: Colors.black,
fontSize: 15,
fontWeight: FontWeight.bold,
letterSpacing: 0.5),
),
SizedBox(
height: 10,
),
Text(
'Courses',
style: TextStyle(
fontFamily: 'Poppins Regular',
color: Colors.black45,
fontSize: 11,
fontWeight: FontWeight.bold,
letterSpacing: 0.3),
),
],
),
Container(
height: 32,
width: 1,
color: Colors.black12,
),
Column(
children: [
Text(
'32',
style: TextStyle(
fontFamily: 'Poppins Medium',
color: Colors.black,
fontSize: 15,
fontWeight: FontWeight.bold,
letterSpacing: 0.5),
),
SizedBox(
height: 10,
),
Text(
'Mentors',
style: TextStyle(
fontFamily: 'Poppins Regular',
color: Colors.black45,
fontSize: 11,
fontWeight: FontWeight.bold,
letterSpacing: 0.3),
),
],
),
Container(
height: 32,
width: 1,
color: Colors.black12,
),
Column(
children: [
Text(
'48',
style: TextStyle(
fontFamily: 'Poppins Medium',
color: Colors.black,
fontSize: 15,
fontWeight: FontWeight.bold,
letterSpacing: 0.5),
),
SizedBox(
height: 10,
),
Text(
'Friends',
style: TextStyle(
fontFamily: 'Poppins Regular',
color: Colors.black45,
fontSize: 11,
fontWeight: FontWeight.bold,
letterSpacing: 0.3),
),
],
),
],
),
),
Container(
margin: EdgeInsets.only(top: 30, left: 20, right: 20),
height: 1,
color: Colors.black12,
width: DeviceSize.width(context),
),
Container(
margin: EdgeInsets.only(top: 30, left: 20, right: 20),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
'YOUR COURSES',
style: TextStyle(
fontFamily: 'Poppins Medium',
color: Colors.black,
fontSize: 12,
fontWeight: FontWeight.w700,
letterSpacing: 0.5),
),
Icon(Icons.more_horiz),
],
),
),
Container(
margin: EdgeInsets.only(top: 10, left: 20, right: 20),
height: DeviceSize.height(context) / 7,
// color:Colors.purple,
child: ListView.separated(
separatorBuilder: (BuildContext context, int index) {
return SizedBox(width: 10);
},
scrollDirection: Axis.horizontal,
// padding:EdgeInsets.only(left:10),
//shrinkWrap: true,
itemCount: popularCourseModel.length,
itemBuilder: (BuildContext context, int index) {
return _buildYourCourseModel(
popularCourseModel[index], index);
},
),
),
Container(
margin: EdgeInsets.only(top: 30, left: 20, right: 20),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
'YOUR PROGRESS',
style: TextStyle(
fontFamily: 'Poppins Medium',
color: Colors.black,
fontSize: 12,
fontWeight: FontWeight.w700,
letterSpacing: 0.5),
),
Icon(Icons.more_horiz),
],
),
),
Container(
// height:DeviceSize.height(context),
width: DeviceSize.width(context),
margin: EdgeInsets.only(top: 20),
child: ListView.separated(
separatorBuilder: (BuildContext context, int index) {
return SizedBox(height: 10);
},
scrollDirection: Axis.vertical,
// padding:EdgeInsets.only(left:10),
physics: NeverScrollableScrollPhysics(),
shrinkWrap: true,
itemCount: resultModel.length,
itemBuilder: (BuildContext context, int index) {
return _buildResultModel(resultModel[index], index);
},
),
),
],
),
),
),
);
}
Widget _buildYourCourseModel(PopularCourseModel items, int index) {
return Container(
width: 70,
child: Column(
//mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
Container(
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Colors.white,
boxShadow: [
BoxShadow(
color: Colors.blueGrey.shade50,
offset: const Offset(
5.0,
5.0,
),
blurRadius: 10.0,
spreadRadius: 2.0,
), //BoxShadow
BoxShadow(
color: Colors.white,
offset: const Offset(0.0, 0.0),
blurRadius: 0.0,
spreadRadius: 0.0,
), //BoxShadow
],
),
child: ClipOval(
child: CircleAvatar(
backgroundColor: Colors.white,
maxRadius: 30,
// child:Image.asset('assets/images/earth.png',height:45,color:Colors.blueAccent,) ,
child: Padding(
padding: EdgeInsets.all(4),
child: Image.asset(
items.img,
fit: BoxFit.cover,
scale: 7,
),
),
),
),
),
Expanded(
child: Container(
padding: EdgeInsets.only(top: 0),
alignment: Alignment.center,
child: Text(
items.title,
style: TextStyle(
fontFamily: 'Poppins Medium',
fontWeight: FontWeight.w700,
letterSpacing: 0.3,
fontSize: 11,
color: Colors.black),
),
),
),
],
),
);
}
Widget _buildResultModel(ResultModel items, int index) {
return Container(
margin: EdgeInsets.only(left: 20, right: 20),
height: DeviceSize.height(context) / 9,
// / color:Colors.pink,
child: Row(
children: [
Container(
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Colors.white,
boxShadow: [
BoxShadow(
color: Colors.blueGrey.shade50,
offset: const Offset(
5.0,
5.0,
),
blurRadius: 10.0,
spreadRadius: 2.0,
), //BoxShadow
BoxShadow(
color: Colors.white,
offset: const Offset(0.0, 0.0),
blurRadius: 0.0,
spreadRadius: 0.0,
), //BoxShadow
],
),
child: ClipOval(
child: CircleAvatar(
backgroundColor: Colors.white,
maxRadius: 28,
// child:Image.asset('assets/images/earth.png',height:45,color:Colors.blueAccent,) ,
child: Padding(
padding: EdgeInsets.all(4),
child: Image.asset(
items.img,
fit: BoxFit.cover,
scale: 7,
),
),
),
),
),
SizedBox(
width: 20,
),
Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
items.title,
style: TextStyle(
fontFamily: 'Poppins Medium',
color: Colors.black,
fontSize: 11.5,
fontWeight: FontWeight.w700,
letterSpacing: 0.5),
),
SizedBox(
height: 5,
),
Text(
items.subTitle,
style: TextStyle(
fontFamily: 'Poppins Regular',
color: Colors.black45,
fontSize: 11,
fontWeight: FontWeight.w700,
letterSpacing: 0.5),
),
],
),
],
),
);
}
}
Summarize
In this article, I explained that in the Flutter response framework, you can modify and experiment according to your own. This small introduction is from our Flutter response framework demonstration.
© Cat brother
Past
Open source
GetX Quick Start
https://github.com/ducafecat/getx_quick_start
News client
https://github.com/ducafecat/flutter_learn_news
strapi manual translation
WeChat discussion group ducafecat
Series collection
Translation
https://ducafecat.tech/categories/%E8%AF%91%E6%96%87/
Open source project
https://ducafecat.tech/categories/%E5%BC%80%E6%BA%90/
Dart programming language basics
https://space.bilibili.com/404904528/channel/detail?cid=111585
Getting started with Flutter zero foundation
https://space.bilibili.com/404904528/channel/detail?cid=123470
Flutter actual combat from scratch news client
https://space.bilibili.com/404904528/channel/detail?cid=106755
Flutter component development
https://space.bilibili.com/404904528/channel/detail?cid=144262
Flutter Bloc
https://space.bilibili.com/404904528/channel/detail?cid=177519
Flutter Getx4
https://space.bilibili.com/404904528/channel/detail?cid=177514
Docker Yapi
https://space.bilibili.com/404904528/channel/detail?cid=130578
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。